Commit 768ad328 authored by Clint Rogers's avatar Clint Rogers

Closes #4481, moves editing tools off into their own unit.

parent e0fddc24
......@@ -66,7 +66,6 @@ UNUNITIZED_SRC_FILES = \
Resources.vala \
Debug.vala \
ColorTransformation.vala \
EditingTools.vala \
Properties.vala \
CustomComponents.vala \
Event.vala \
......
......@@ -772,9 +772,9 @@ public class AdjustColorsCommand : GenericPhotoTransformationCommand {
}
public class RedeyeCommand : GenericPhotoTransformationCommand {
private RedeyeInstance redeye_instance;
private EditingTools.RedeyeInstance redeye_instance;
public RedeyeCommand(Photo photo, RedeyeInstance redeye_instance, string name,
public RedeyeCommand(Photo photo, EditingTools.RedeyeInstance redeye_instance, string name,
string explanation) {
base(photo, name, explanation);
......
......@@ -2675,15 +2675,15 @@ public abstract class Photo : PhotoSource, Dateable {
}
// All instances are against the coordinate system of the unscaled, unrotated photo.
private RedeyeInstance[] get_raw_redeye_instances() {
private EditingTools.RedeyeInstance[] get_raw_redeye_instances() {
KeyValueMap map = get_transformation("redeye");
if (map == null)
return new RedeyeInstance[0];
return new EditingTools.RedeyeInstance[0];
int num_points = map.get_int("num_points", -1);
assert(num_points > 0);
RedeyeInstance[] res = new RedeyeInstance[num_points];
EditingTools.RedeyeInstance[] res = new EditingTools.RedeyeInstance[num_points];
Gdk.Point default_point = {0};
default_point.x = -1;
......@@ -2709,7 +2709,7 @@ public abstract class Photo : PhotoSource, Dateable {
}
// All instances are against the coordinate system of the unrotated photo.
private void add_raw_redeye_instance(RedeyeInstance redeye) {
private void add_raw_redeye_instance(EditingTools.RedeyeInstance redeye) {
KeyValueMap map = get_transformation("redeye");
if (map == null) {
map = new KeyValueMap("redeye");
......@@ -2965,7 +2965,7 @@ public abstract class Photo : PhotoSource, Dateable {
Dimensions scaled_image, scaled_to_viewport;
Dimensions original = Dimensions();
Dimensions scaled = Dimensions();
RedeyeInstance[] redeye_instances = null;
EditingTools.RedeyeInstance[] redeye_instances = null;
Box crop;
double straightening_angle;
PixelTransformer transformer = null;
......@@ -3023,7 +3023,7 @@ public abstract class Photo : PhotoSource, Dateable {
#if MEASURE_PIPELINE
timer.start();
#endif
foreach (RedeyeInstance instance in redeye_instances) {
foreach (EditingTools.RedeyeInstance instance in redeye_instances) {
// redeye is stored in raw coordinates; need to scale to scaled image coordinates
if (is_scaled) {
instance.center = coord_scaled_in_space(instance.center.x, instance.center.y,
......@@ -3760,15 +3760,15 @@ public abstract class Photo : PhotoSource, Dateable {
set_raw_straighten(theta);
}
public void add_redeye_instance(RedeyeInstance inst_unscaled) {
Gdk.Rectangle bounds_rect_unscaled = RedeyeInstance.to_bounds_rect(inst_unscaled);
public void add_redeye_instance(EditingTools.RedeyeInstance inst_unscaled) {
Gdk.Rectangle bounds_rect_unscaled = EditingTools.RedeyeInstance.to_bounds_rect(inst_unscaled);
Gdk.Rectangle bounds_rect_raw = unscaled_to_raw_rect(bounds_rect_unscaled);
RedeyeInstance inst = RedeyeInstance.from_bounds_rect(bounds_rect_raw);
EditingTools.RedeyeInstance inst = EditingTools.RedeyeInstance.from_bounds_rect(bounds_rect_raw);
add_raw_redeye_instance(inst);
}
private Gdk.Pixbuf do_redeye(Gdk.Pixbuf pixbuf, RedeyeInstance inst) {
private Gdk.Pixbuf do_redeye(Gdk.Pixbuf pixbuf, EditingTools.RedeyeInstance inst) {
/* we remove redeye within a circular region called the "effect
extent." the effect extent is inscribed within its "bounding
rectangle." */
......
......@@ -371,7 +371,7 @@ public abstract class EditingHostPage : SinglePhotoPage {
public const int PIXBUF_CACHE_COUNT = 5;
public const int ORIGINAL_PIXBUF_CACHE_COUNT = 5;
private class EditingHostCanvas : PhotoCanvas {
private class EditingHostCanvas : EditingTools.PhotoCanvas {
private EditingHostPage host_page;
public EditingHostCanvas(EditingHostPage host_page) {
......@@ -399,7 +399,7 @@ public abstract class EditingHostPage : SinglePhotoPage {
private Gtk.HScale zoom_slider = null;
private Gtk.ToolButton prev_button = new Gtk.ToolButton.from_stock(Gtk.Stock.GO_BACK);
private Gtk.ToolButton next_button = new Gtk.ToolButton.from_stock(Gtk.Stock.GO_FORWARD);
private EditingTool current_tool = null;
private EditingTools.EditingTool current_tool = null;
private Gtk.ToggleToolButton current_editing_toggle = null;
private Gdk.Pixbuf cancel_editing_pixbuf = null;
private bool photo_missing = false;
......@@ -1322,9 +1322,9 @@ public abstract class EditingHostPage : SinglePhotoPage {
Scaling scaling = get_canvas_scaling();
rotate_button.sensitive = photo != null ? is_rotate_available(photo) : false;
crop_button.sensitive = photo != null ? CropTool.is_available(photo, scaling) : false;
redeye_button.sensitive = photo != null ? RedeyeTool.is_available(photo, scaling) : false;
adjust_button.sensitive = photo != null ? AdjustTool.is_available(photo, scaling) : false;
crop_button.sensitive = photo != null ? EditingTools.CropTool.is_available(photo, scaling) : false;
redeye_button.sensitive = photo != null ? EditingTools.RedeyeTool.is_available(photo, scaling) : false;
adjust_button.sensitive = photo != null ? EditingTools.AdjustTool.is_available(photo, scaling) : false;
enhance_button.sensitive = photo != null ? is_enhance_available(photo) : false;
base.update_actions(selected_count, count);
......@@ -1397,7 +1397,7 @@ public abstract class EditingHostPage : SinglePhotoPage {
}
}
private void activate_tool(EditingTool tool) {
private void activate_tool(EditingTools.EditingTool tool) {
// cancel any zoom -- we don't currently allow tools to be used when an image is zoomed,
// though we may at some point in the future.
save_zoom_state();
......@@ -1434,7 +1434,7 @@ public abstract class EditingHostPage : SinglePhotoPage {
set_pixbuf(unscaled, max_dim);
// create the PhotoCanvas object for a two-way interface to the tool
PhotoCanvas photo_canvas = new EditingHostCanvas(this);
EditingTools.PhotoCanvas photo_canvas = new EditingHostCanvas(this);
// hook tool into event system and activate it
current_tool = tool;
......@@ -1452,7 +1452,7 @@ public abstract class EditingHostPage : SinglePhotoPage {
if (current_tool == null)
return;
EditingTool tool = current_tool;
EditingTools.EditingTool tool = current_tool;
current_tool = null;
// deactivate with the tool taken out of the hooks
......@@ -1639,7 +1639,7 @@ public abstract class EditingHostPage : SinglePhotoPage {
private void track_tool_window() {
// if editing tool window is present and the user hasn't touched it, it moves with the window
if (current_tool != null) {
EditingToolWindow tool_window = current_tool.get_tool_window();
EditingTools.EditingToolWindow tool_window = current_tool.get_tool_window();
if (tool_window != null && !tool_window.has_user_moved())
place_tool_window();
}
......@@ -1959,7 +1959,7 @@ public abstract class EditingHostPage : SinglePhotoPage {
return base.on_ctrl_released(event);
}
protected void on_tool_button_toggled(Gtk.ToggleToolButton toggle, EditingTool.Factory factory) {
protected void on_tool_button_toggled(Gtk.ToggleToolButton toggle, EditingTools.EditingTool.Factory factory) {
// if the button is an activate, deactivate any current tool running; if the button is
// a deactivate, deactivate the current tool and exit
bool deactivating_only = (!toggle.active && current_editing_toggle == toggle);
......@@ -1975,7 +1975,7 @@ public abstract class EditingHostPage : SinglePhotoPage {
current_editing_toggle = toggle;
// create the tool, hook its signals, and activate
EditingTool tool = factory();
EditingTools.EditingTool tool = factory();
tool.activated.connect(on_tool_activated);
tool.deactivated.connect(on_tool_deactivated);
tool.applied.connect(on_tool_applied);
......@@ -2027,15 +2027,15 @@ public abstract class EditingHostPage : SinglePhotoPage {
}
private void on_crop_toggled() {
on_tool_button_toggled(crop_button, CropTool.factory);
on_tool_button_toggled(crop_button, EditingTools.CropTool.factory);
}
private void on_redeye_toggled() {
on_tool_button_toggled(redeye_button, RedeyeTool.factory);
on_tool_button_toggled(redeye_button, EditingTools.RedeyeTool.factory);
}
private void on_adjust_toggled() {
on_tool_button_toggled(adjust_button, AdjustTool.factory);
on_tool_button_toggled(adjust_button, EditingTools.AdjustTool.factory);
}
public bool is_enhance_available(Photo photo) {
......@@ -2046,7 +2046,7 @@ public abstract class EditingHostPage : SinglePhotoPage {
// because running multiple tools at once is not currently supported, deactivate any current
// tool; however, there is a special case of running enhancement while the AdjustTool is
// open, so allow for that
if (!(current_tool is AdjustTool)) {
if (!(current_tool is EditingTools.AdjustTool)) {
deactivate_tool();
cancel_zoom();
......@@ -2055,7 +2055,7 @@ public abstract class EditingHostPage : SinglePhotoPage {
if (!has_photo())
return;
AdjustTool adjust_tool = current_tool as AdjustTool;
EditingTools.AdjustTool adjust_tool = current_tool as EditingTools.AdjustTool;
if (adjust_tool != null) {
adjust_tool.enhance();
......@@ -2070,7 +2070,7 @@ public abstract class EditingHostPage : SinglePhotoPage {
if (current_tool == null)
return;
EditingToolWindow tool_window = current_tool.get_tool_window();
EditingTools.EditingToolWindow tool_window = current_tool.get_tool_window();
if (tool_window == null)
return;
......@@ -2119,7 +2119,7 @@ public abstract class EditingHostPage : SinglePhotoPage {
tool_alloc.height - TOOL_WINDOW_SEPARATOR;
// put larger adjust tool off to the side
if (current_tool is AdjustTool) {
if (current_tool is EditingTools.AdjustTool) {
x = x * 3 / 4;
} else {
x = (x - tool_alloc.width) / 2;
......@@ -2646,8 +2646,8 @@ public class LibraryPhotoPage : EditingHostPage {
set_action_sensitive("FlipVertically", rotate_possible);
if (has_photo()) {
set_action_sensitive("Crop", CropTool.is_available(get_photo(), Scaling.for_original()));
set_action_sensitive("RedEye", RedeyeTool.is_available(get_photo(),
set_action_sensitive("Crop", EditingTools.CropTool.is_available(get_photo(), Scaling.for_original()));
set_action_sensitive("RedEye", EditingTools.RedeyeTool.is_available(get_photo(),
Scaling.for_original()));
}
......
......@@ -361,8 +361,8 @@ public class DirectPhotoPage : EditingHostPage {
set_action_sensitive("SetBackground", has_photo());
if (has_photo()) {
set_action_sensitive("Crop", CropTool.is_available(get_photo(), Scaling.for_original()));
set_action_sensitive("RedEye", RedeyeTool.is_available(get_photo(),
set_action_sensitive("Crop", EditingTools.CropTool.is_available(get_photo(), Scaling.for_original()));
set_action_sensitive("RedEye", EditingTools.RedeyeTool.is_available(get_photo(),
Scaling.for_original()));
}
......
/* Copyright 2009-2011 Yorba Foundation
/* Copyright 2011 Yorba Foundation
*
* This software is licensed under the GNU LGPL (version 2.1 or later).
* See the COPYING file in this distribution.
* This software is licensed under the GNU Lesser General Public License
* (version 2.1 or later). See the COPYING file in this distribution.
*/
/* This file is the master unit file for the EditingTools unit. It should be edited to include
* whatever code is deemed necessary.
*
* The init() and terminate() methods are mandatory.
*
* If the unit needs to be configured prior to initialization, add the proper parameters to
* the preconfigure() method, implement it, and ensure in init() that it's been called.
*/
namespace EditingTools {
// preconfigure may be deleted if not used.
public void preconfigure() {
}
public void init() throws Error {
}
public void terminate() {
}
public abstract class EditingToolWindow : Gtk.Window {
private const int FRAME_BORDER = 6;
......@@ -2414,7 +2435,7 @@ public struct RedeyeInstance {
radius = DEFAULT_RADIUS;
}
public static Gdk.Rectangle to_bounds_rect(RedeyeInstance inst) {
public static Gdk.Rectangle to_bounds_rect(EditingTools.RedeyeInstance inst) {
Gdk.Rectangle result = {0};
result.x = inst.center.x - inst.radius;
result.y = inst.center.y - inst.radius;
......@@ -3444,3 +3465,6 @@ public class AdjustTool : EditingTool {
}
}
}
# UNIT_NAME is the Vala namespace. A file named UNIT_NAME.vala must be in this directory with
# a init() and terminate() function declared in the namespace.
UNIT_NAME := EditingTools
# UNIT_DIR should match the subdirectory the files are located in. Generally UNIT_NAME in all
# lowercase. The name of this file should be UNIT_DIR.mk.
UNIT_DIR := editing_tools
# All Vala files in the unit should be listed here with no subdirectory prefix.
#
# NOTE: Do *not* include the unit's master file, i.e. UNIT_NAME.vala.
UNIT_FILES :=
# Any unit this unit relies upon (and should be initialized before it's initialized) should
# be listed here using its Vala namespace.
#
# NOTE: All units are assumed to rely upon the unit-unit. Do not include that here.
UNIT_USES :=
# List any additional files that are used in the build process as a part of this unit that should
# be packaged in the tarball. File names should be relative to the unit's home directory.
UNIT_RC :=
# unitize.mk must be called at the end of each UNIT_DIR.mk file.
include unitize.mk
......@@ -11,6 +11,7 @@ UNITS = \
util \
threads \
db \
editing_tools \
plugins \
slideshow \
photos \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment