summaryrefslogtreecommitdiff
path: root/src/editing_tools
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff.email>2023-06-28 21:35:52 +0200
committerJörg Frings-Fürst <debian@jff.email>2023-06-28 21:35:52 +0200
commitb86540b743f1a87a163ffb811c8fe22a01fefa38 (patch)
treeb47cb3bb83c2377234226fb3987ab3320a987dd9 /src/editing_tools
parentac6e0b731b9f0b2efd392e3309a5c07e2a66adad (diff)
parente905d8e16eec152d19797937f13ba3cf4b8f8aca (diff)
Merge branch 'release/debian/0.32.1-1'debian/0.32.1-1
Diffstat (limited to 'src/editing_tools')
-rw-r--r--src/editing_tools/EditingTools.vala83
-rw-r--r--src/editing_tools/StraightenTool.vala14
2 files changed, 54 insertions, 43 deletions
diff --git a/src/editing_tools/EditingTools.vala b/src/editing_tools/EditingTools.vala
index 02e366a..0042d57 100644
--- a/src/editing_tools/EditingTools.vala
+++ b/src/editing_tools/EditingTools.vala
@@ -87,7 +87,8 @@ public abstract class EditingToolWindow : Gtk.Window {
}
public override void realize() {
- (this as Gtk.Widget).set_opacity(Resources.TRANSIENT_WINDOW_OPACITY);
+ // Force the use of gtk_widget_set_opacity; gtk_window_set_opacity is deprecated
+ ((Gtk.Widget) this).set_opacity(Resources.TRANSIENT_WINDOW_OPACITY);
base.realize();
}
@@ -381,12 +382,13 @@ public abstract class PhotoCanvas {
}
public void erase_horizontal_line(int x, int y, int width) {
+ var scale = Application.get_scale();
default_ctx.save();
default_ctx.set_operator(Cairo.Operator.SOURCE);
default_ctx.set_source_surface(scaled, scaled_position.x, scaled_position.y);
default_ctx.rectangle(scaled_position.x + x, scaled_position.y + y,
- width - 1, 1);
+ width - 1, 1 * scale);
default_ctx.fill();
default_ctx.restore();
@@ -404,6 +406,8 @@ public abstract class PhotoCanvas {
public void erase_vertical_line(int x, int y, int height) {
default_ctx.save();
+ var scale = Application.get_scale();
+
// Ticket #3146 - artifacting when moving the crop box or
// enlarging it from the lower right.
// We now no longer subtract one from the height before choosing
@@ -411,7 +415,7 @@ public abstract class PhotoCanvas {
default_ctx.set_operator(Cairo.Operator.SOURCE);
default_ctx.set_source_surface(scaled, scaled_position.x, scaled_position.y);
default_ctx.rectangle(scaled_position.x + x, scaled_position.y + y,
- 1, height);
+ 1 * scale, height);
default_ctx.fill();
default_ctx.restore();
@@ -427,12 +431,19 @@ public abstract class PhotoCanvas {
public void invalidate_area(Box area) {
Gdk.Rectangle rect = area.get_rectangle();
+
rect.x += scaled_position.x;
rect.y += scaled_position.y;
drawing_window.invalidate_rect(rect, false);
}
+ public void set_cursor(Gdk.CursorType cursor_type) {
+ var display = get_drawing_window().get_display();
+ var cursor = new Gdk.Cursor.for_display (display, cursor_type);
+ get_drawing_window().set_cursor(cursor);
+ }
+
private Cairo.Surface pixbuf_to_surface(Cairo.Context default_ctx, Gdk.Pixbuf pixbuf,
Gdk.Rectangle pos) {
Cairo.Surface surface = new Cairo.Surface.similar(default_ctx.get_target(),
@@ -1220,11 +1231,7 @@ public class CropTool : EditingTool {
// make sure the cursor isn't set to a modify indicator
if (canvas != null) {
- var drawing_window = canvas.get_drawing_window ();
- var display = drawing_window.get_display ();
- var cursor = new Gdk.Cursor.for_display (display,
- Gdk.CursorType.LEFT_PTR);
- drawing_window.set_cursor (cursor);
+ canvas.set_cursor (Gdk.CursorType.LEFT_PTR);
}
crop_surface = null;
@@ -1244,20 +1251,22 @@ public class CropTool : EditingTool {
}
private void prepare_ctx(Cairo.Context ctx, Dimensions dim) {
+ var scale = Application.get_scale();
wide_black_ctx = new Cairo.Context(ctx.get_target());
set_source_color_from_string(wide_black_ctx, "#000");
- wide_black_ctx.set_line_width(1);
+ wide_black_ctx.set_line_width(1 * scale);
wide_white_ctx = new Cairo.Context(ctx.get_target());
set_source_color_from_string(wide_white_ctx, "#FFF");
- wide_white_ctx.set_line_width(1);
+ wide_white_ctx.set_line_width(1 * scale);
thin_white_ctx = new Cairo.Context(ctx.get_target());
set_source_color_from_string(thin_white_ctx, "#FFF");
- thin_white_ctx.set_line_width(0.5);
+ thin_white_ctx.set_line_width(0.5 * scale);
text_ctx = new Cairo.Context(ctx.get_target());
text_ctx.select_font_face("Sans", Cairo.FontSlant.NORMAL, Cairo.FontWeight.NORMAL);
+ text_ctx.set_font_size(10.0 * scale);
}
private void on_resized_pixbuf(Dimensions old_dim, Gdk.Pixbuf scaled, Gdk.Rectangle scaled_position) {
@@ -1286,7 +1295,8 @@ public class CropTool : EditingTool {
Box offset_scaled_crop = scaled_crop.get_offset(scaled_pixbuf_pos.x, scaled_pixbuf_pos.y);
// determine where the mouse down landed and store for future events
- in_manipulation = offset_scaled_crop.approx_location(x, y);
+ in_manipulation = offset_scaled_crop.approx_location((int)Math.lround(x * Application.get_scale()),
+ (int)Math.lround(y * Application.get_scale()));
last_grab_x = x -= scaled_pixbuf_pos.x;
last_grab_y = y -= scaled_pixbuf_pos.y;
@@ -1314,19 +1324,21 @@ public class CropTool : EditingTool {
// only deal with manipulating the crop tool when click-and-dragging one of the edges
// or the interior
if (in_manipulation != BoxLocation.OUTSIDE)
- on_canvas_manipulation(x, y);
+ on_canvas_manipulation((int)Math.lround(x * Application.get_scale()),
+ (int)Math.lround(y * Application.get_scale()));
update_cursor(x, y);
canvas.repaint();
}
public override void paint(Cairo.Context default_ctx) {
+ var scale = Application.get_scale();
// fill region behind the crop surface with neutral color
int w = canvas.get_drawing_window().get_width();
int h = canvas.get_drawing_window().get_height();
default_ctx.set_source_rgba(0.0, 0.0, 0.0, 1.0);
- default_ctx.rectangle(0, 0, w, h);
+ default_ctx.rectangle(0, 0, w * scale, h * scale);
default_ctx.fill();
default_ctx.paint();
@@ -1376,7 +1388,8 @@ public class CropTool : EditingTool {
Box offset_scaled_crop = scaled_crop.get_offset(scaled_pos.x, scaled_pos.y);
Gdk.CursorType cursor_type = Gdk.CursorType.LEFT_PTR;
- switch (offset_scaled_crop.approx_location(x, y)) {
+ switch (offset_scaled_crop.approx_location((int)Math.lround(x * Application.get_scale()),
+ (int)Math.lround(y * Application.get_scale()))) {
case BoxLocation.LEFT_SIDE:
cursor_type = Gdk.CursorType.LEFT_SIDE;
break;
@@ -1419,10 +1432,7 @@ public class CropTool : EditingTool {
}
if (cursor_type != current_cursor_type) {
- var drawing_window = canvas.get_drawing_window ();
- var display = drawing_window.get_display ();
- var cursor = new Gdk.Cursor.for_display (display, cursor_type);
- drawing_window.set_cursor (cursor);
+ canvas.set_cursor(cursor_type);
current_cursor_type = cursor_type;
}
}
@@ -1893,8 +1903,6 @@ public class RedeyeTool : EditingTool {
private bool is_reticle_move_in_progress = false;
private Gdk.Point reticle_move_mouse_start_point;
private Gdk.Point reticle_move_anchor;
- private Gdk.Cursor cached_arrow_cursor;
- private Gdk.Cursor cached_grab_cursor;
private Gdk.Rectangle old_scaled_pixbuf_position;
private Gdk.Pixbuf current_pixbuf = null;
@@ -1928,13 +1936,14 @@ public class RedeyeTool : EditingTool {
}
private void prepare_ctx(Cairo.Context ctx, Dimensions dim) {
+ var scale = Application.get_scale();
wider_gray_ctx = new Cairo.Context(ctx.get_target());
set_source_color_from_string(wider_gray_ctx, "#111");
- wider_gray_ctx.set_line_width(3);
+ wider_gray_ctx.set_line_width(3 * scale);
thin_white_ctx = new Cairo.Context(ctx.get_target());
set_source_color_from_string(thin_white_ctx, "#FFF");
- thin_white_ctx.set_line_width(1);
+ thin_white_ctx.set_line_width(1 * scale);
}
private void draw_redeye_instance(RedeyeInstance inst) {
@@ -2044,10 +2053,6 @@ public class RedeyeTool : EditingTool {
bind_window_handlers();
- var display = canvas.get_drawing_window().get_display();
- cached_arrow_cursor = new Gdk.Cursor.for_display(display, Gdk.CursorType.LEFT_PTR);
- cached_grab_cursor = new Gdk.Cursor.for_display(display, Gdk.CursorType.FLEUR);
-
DataCollection? owner = canvas.get_photo().get_membership();
if (owner != null)
owner.items_altered.connect(on_photos_altered);
@@ -2112,13 +2117,17 @@ public class RedeyeTool : EditingTool {
}
public override void on_left_click(int x, int y) {
+ var scale = Application.get_scale();
+
Gdk.Rectangle bounds_rect =
RedeyeInstance.to_bounds_rect(user_interaction_instance);
- if (coord_in_rectangle(x, y, bounds_rect)) {
+
+ if (coord_in_rectangle((int)Math.lround(x * scale), (int)Math.lround(y * scale), bounds_rect)) {
+ print("Motion in progress!!\n");
is_reticle_move_in_progress = true;
- reticle_move_mouse_start_point.x = x;
- reticle_move_mouse_start_point.y = y;
+ reticle_move_mouse_start_point.x = (int)Math.lround(x * scale);
+ reticle_move_mouse_start_point.y = (int)Math.lround(y * scale);
reticle_move_anchor = user_interaction_instance.center;
}
}
@@ -2128,6 +2137,8 @@ public class RedeyeTool : EditingTool {
}
public override void on_motion(int x, int y, Gdk.ModifierType mask) {
+ var scale = Application.get_scale();
+
if (is_reticle_move_in_progress) {
Gdk.Rectangle active_region_rect =
@@ -2144,8 +2155,8 @@ public class RedeyeTool : EditingTool {
active_region_rect.y + active_region_rect.height -
user_interaction_instance.radius - 1;
- int delta_x = x - reticle_move_mouse_start_point.x;
- int delta_y = y - reticle_move_mouse_start_point.y;
+ int delta_x = (int)Math.lround(x * scale) - reticle_move_mouse_start_point.x;
+ int delta_y = (int)Math.lround(y * scale) - reticle_move_mouse_start_point.y;
user_interaction_instance.center.x = reticle_move_anchor.x +
delta_x;
@@ -2164,10 +2175,10 @@ public class RedeyeTool : EditingTool {
Gdk.Rectangle bounds =
RedeyeInstance.to_bounds_rect(user_interaction_instance);
- if (coord_in_rectangle(x, y, bounds)) {
- canvas.get_drawing_window().set_cursor(cached_grab_cursor);
+ if (coord_in_rectangle((int)Math.lround(x * scale), (int)Math.lround(y * scale), bounds)) {
+ canvas.set_cursor(Gdk.CursorType.FLEUR);
} else {
- canvas.get_drawing_window().set_cursor(cached_arrow_cursor);
+ canvas.set_cursor(Gdk.CursorType.LEFT_PTR);
}
}
}
@@ -2251,7 +2262,7 @@ public class AdjustTool : EditingTool {
slider_organizer.attach(saturation_label, 0, 2, 1, 1);
slider_organizer.attach(saturation_slider, 1, 2, 1, 1);
saturation_slider.set_size_request(SLIDER_WIDTH, -1);
- saturation_slider.set_draw_value(false);
+ saturation_slider.set_value_pos(Gtk.PositionType.RIGHT);
saturation_slider.set_margin_end(0);
Gtk.Label tint_label = new Gtk.Label.with_mnemonic(_("Tint:"));
diff --git a/src/editing_tools/StraightenTool.vala b/src/editing_tools/StraightenTool.vala
index f427b99..2b0591a 100644
--- a/src/editing_tools/StraightenTool.vala
+++ b/src/editing_tools/StraightenTool.vala
@@ -80,13 +80,13 @@ public class StraightenTool : EditingTool {
// different backgrounds.
ctx.set_source_rgba(0.0, 0.0, 0.0, alpha);
ctx.set_dash(GUIDE_DASH, GUIDE_DASH[0] / 2);
- ctx.move_to(x[0] + 0.5, y[0] + 0.5);
- ctx.line_to(x[1] + 0.5, y[1] + 0.5);
+ ctx.move_to(x[0] * Application.get_scale() + 0.5, y[0]* Application.get_scale() + 0.5);
+ ctx.line_to(x[1] * Application.get_scale()+ 0.5, y[1]* Application.get_scale() + 0.5);
ctx.stroke();
ctx.set_dash(GUIDE_DASH, -GUIDE_DASH[0] / 2);
ctx.set_source_rgba(1.0, 1.0, 1.0, alpha);
- ctx.move_to(x[0] + 0.5, y[0] + 0.5);
- ctx.line_to(x[1] + 0.5, y[1] + 0.5);
+ ctx.move_to(x[0] * Application.get_scale()+ 0.5, y[0]* Application.get_scale() + 0.5);
+ ctx.line_to(x[1] * Application.get_scale()+ 0.5, y[1] * Application.get_scale()+ 0.5);
ctx.stroke();
}
}
@@ -456,7 +456,7 @@ public class StraightenTool : EditingTool {
*/
private void update_rotated_surface() {
draw_rotated_source(photo_surf, rotate_ctx, view_width, view_height, photo_angle);
- rotate_ctx.set_line_width(1.0);
+ rotate_ctx.set_line_width(1.0 * Application.get_scale());
draw_superimposed_grid(rotate_ctx, view_width, view_height);
}
@@ -468,8 +468,8 @@ public class StraightenTool : EditingTool {
* it's not used.
*/
public override void paint(Cairo.Context ctx) {
- int w = canvas.get_drawing_window().get_width();
- int h = canvas.get_drawing_window().get_height();
+ var w = canvas.get_drawing_window().get_width() * Application.get_scale();
+ var h = canvas.get_drawing_window().get_height() * Application.get_scale();
// fill region behind the rotation surface with neutral color.
canvas.get_default_ctx().identity_matrix();