Skip to content

Commit

Permalink
Subclass DrawingArea
Browse files Browse the repository at this point in the history
  • Loading branch information
danirabbit committed Dec 30, 2023
1 parent a389bf5 commit 3b6554b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Widgets/CropView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Marvin Beckers <beckersmarvin@gmail.com>
*/

public class SwitchboardPlugUserAccounts.Widgets.CropView : Gtk.EventBox {
public class SwitchboardPlugUserAccounts.Widgets.CropView : Gtk.DrawingArea {
public Gdk.Pixbuf pixbuf { get; construct; }
public int pixel_size { get; construct; }

Expand Down Expand Up @@ -86,8 +86,6 @@ public class SwitchboardPlugUserAccounts.Widgets.CropView : Gtk.EventBox {
}

construct {
add_events (Gdk.EventMask.POINTER_MOTION_MASK | Gdk.EventMask.BUTTON_MOTION_MASK);

// Use a default selection of 75% in the center of the image
int area_dimension = int.min (pixbuf.get_width (), pixbuf.get_height ()) * 3 / 4;
int area_position_x = (pixbuf.get_width () - area_dimension) / 2;
Expand All @@ -104,6 +102,8 @@ public class SwitchboardPlugUserAccounts.Widgets.CropView : Gtk.EventBox {
width_request = int.min (pixel_size, pixel_size * pixbuf.get_width () / pixbuf.get_height ());
height_request = int.min (pixel_size, pixel_size * pixbuf.get_height () / pixbuf.get_width ());

add_events (Gdk.EventMask.POINTER_MOTION_MASK | Gdk.EventMask.BUTTON_MOTION_MASK);

click_gesture = new Gtk.GestureMultiPress (this);
click_gesture.pressed.connect (gesture_press_event);
click_gesture.released.connect (gesture_release_event);
Expand Down

0 comments on commit 3b6554b

Please sign in to comment.