Commit ce1b9857 authored by Patrick Tierney's avatar Patrick Tierney

#2396: made zoom icons clickable

parent e0d03f9f
......@@ -217,8 +217,14 @@ public abstract class CollectionPage : CheckerboardPage {
Gtk.Image zoom_out = new Gtk.Image.from_pixbuf(Resources.load_icon(Resources.ICON_ZOOM_OUT,
Resources.ICON_ZOOM_SCALE));
Gtk.EventBox zoom_out_box = new Gtk.EventBox();
zoom_out_box.set_above_child(true);
zoom_out_box.set_visible_window(false);
zoom_out_box.add(zoom_out);
zoom_group.pack_start(zoom_out, false, false, 0);
zoom_out_box.button_press_event.connect(on_zoom_out_pressed);
zoom_group.pack_start(zoom_out_box, false, false, 0);
// thumbnail size slider
slider = new Gtk.HScale(slider_adjustment);
......@@ -231,8 +237,14 @@ public abstract class CollectionPage : CheckerboardPage {
Gtk.Image zoom_in = new Gtk.Image.from_pixbuf(Resources.load_icon(Resources.ICON_ZOOM_IN,
Resources.ICON_ZOOM_SCALE));
Gtk.EventBox zoom_in_box = new Gtk.EventBox();
zoom_in_box.set_above_child(true);
zoom_in_box.set_visible_window(false);
zoom_in_box.add(zoom_in);
zoom_in_box.button_press_event.connect(on_zoom_in_pressed);
zoom_group.pack_start(zoom_in, false, false, 0);
zoom_group.pack_start(zoom_in_box, false, false, 0);
Gtk.ToolItem group_wrapper = new Gtk.ToolItem();
group_wrapper.add(zoom_group);
......@@ -934,6 +946,24 @@ public abstract class CollectionPage : CheckerboardPage {
public void decrease_thumb_size() {
set_thumb_size(scale - MANUAL_STEPPING);
}
private bool on_zoom_out_pressed(Gdk.EventButton event) {
snap_zoom_to_min();
return true;
}
private bool on_zoom_in_pressed(Gdk.EventButton event) {
snap_zoom_to_max();
return true;
}
protected void snap_zoom_to_min() {
slider.set_value(scale_to_slider(Thumbnail.MIN_SCALE));
}
protected void snap_zoom_to_max() {
slider.set_value(scale_to_slider(Thumbnail.MAX_SCALE));
}
public void set_thumb_size(int new_scale) {
if (scale == new_scale || !is_in_view())
......
......@@ -455,29 +455,45 @@ public abstract class EditingHostPage : SinglePhotoPage {
separator.set_draw(false);
toolbar.insert(separator, -1);
Gtk.ToolItem zoom_out_wrapper = new Gtk.ToolItem();
Gtk.HBox zoom_group = new Gtk.HBox(false, 0);
Gtk.Image zoom_out = new Gtk.Image.from_pixbuf(Resources.load_icon(Resources.ICON_ZOOM_OUT,
Resources.ICON_ZOOM_SCALE));
zoom_out_wrapper.add(zoom_out);
toolbar.insert(zoom_out_wrapper, -1);
Gtk.EventBox zoom_out_box = new Gtk.EventBox();
zoom_out_box.set_above_child(true);
zoom_out_box.set_visible_window(false);
zoom_out_box.add(zoom_out);
zoom_out_box.button_press_event.connect(on_zoom_out_pressed);
zoom_group.pack_start(zoom_out_box, false, false, 0);
// zoom slider
zoom_slider = new Gtk.HScale(new Gtk.Adjustment(0.0, 0.0, 1.1, 0.1, 0.1, 0.1));
zoom_slider.set_draw_value(false);
Gtk.ToolItem zoom_slider_wrapper = new Gtk.ToolItem();
zoom_slider_wrapper.add(zoom_slider);
toolbar.insert(zoom_slider_wrapper, -1);
zoom_slider.set_size_request(120, -1);
zoom_slider.value_changed.connect(on_zoom_slider_value_changed);
zoom_slider.button_press_event.connect(on_zoom_slider_drag_begin);
zoom_slider.button_release_event.connect(on_zoom_slider_drag_end);
zoom_slider.key_press_event.connect(on_zoom_slider_key_press);
zoom_group.pack_start(zoom_slider, false, false, 0);
Gtk.ToolItem zoom_in_wrapper = new Gtk.ToolItem();
Gtk.Image zoom_in = new Gtk.Image.from_pixbuf(Resources.load_icon(Resources.ICON_ZOOM_IN,
Resources.ICON_ZOOM_SCALE));
zoom_in_wrapper.add(zoom_in);
toolbar.insert(zoom_in_wrapper, -1);
Gtk.EventBox zoom_in_box = new Gtk.EventBox();
zoom_in_box.set_above_child(true);
zoom_in_box.set_visible_window(false);
zoom_in_box.add(zoom_in);
zoom_in_box.button_press_event.connect(on_zoom_in_pressed);
zoom_group.pack_start(zoom_in_box, false, false, 0);
Gtk.ToolItem group_wrapper = new Gtk.ToolItem();
group_wrapper.add(zoom_group);
toolbar.insert(group_wrapper, -1);
// previous button
prev_button.set_tooltip_text(_("Previous photo"));
......@@ -536,7 +552,17 @@ public abstract class EditingHostPage : SinglePhotoPage {
return false;
}
private bool on_zoom_out_pressed(Gdk.EventButton event) {
snap_zoom_to_min();
return true;
}
private bool on_zoom_in_pressed(Gdk.EventButton event) {
snap_zoom_to_max();
return true;
}
private Gdk.Point get_cursor_wrt_viewport(Gdk.EventScroll event) {
Gdk.Point cursor_wrt_canvas = {0};
cursor_wrt_canvas.x = (int) event.x;
......
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