Commit f91926c2 authored by Jim Nelson's avatar Jim Nelson

#341: Zoom level shared between events and Photos view.

parent cddd2d7a
......@@ -53,6 +53,8 @@ public class CollectionPage : CheckerboardPage {
}
}
private static Gtk.Adjustment slider_adjustment = null;
private Gtk.Toolbar toolbar = new Gtk.Toolbar();
private Gtk.HScale slider = null;
private Gtk.ToolButton rotate_button = null;
......@@ -117,6 +119,11 @@ public class CollectionPage : CheckerboardPage {
set_layout_comparator(new CompareName());
// adjustment which is shared by all sliders in the application
if (slider_adjustment == null)
slider_adjustment = new Gtk.Adjustment(scale_to_slider(scale), 0,
scale_to_slider(Thumbnail.MAX_SCALE), 1, 10, 0);
// set up page's toolbar (used by AppWindow for layout)
//
// rotate tool
......@@ -136,8 +143,7 @@ public class CollectionPage : CheckerboardPage {
toolbar.insert(separator, -1);
// thumbnail size slider
slider = new Gtk.HScale.with_range(0, scale_to_slider(Thumbnail.MAX_SCALE), 1);
slider.set_value(scale_to_slider(scale));
slider = new Gtk.HScale(slider_adjustment);
slider.value_changed += on_slider_changed;
slider.set_draw_value(false);
......
......@@ -382,6 +382,7 @@ public abstract class CheckerboardPage : Page {
set_event_source(layout);
layout.expose_after += on_layout_exposed;
layout.map += on_layout_mapped;
add(layout);
}
......@@ -614,6 +615,8 @@ public abstract class CheckerboardPage : Page {
drag_select = true;
drag_start.x = (int) event.x;
drag_start.y = (int) event.y;
selection_band.width = 0;
selection_band.height = 0;
return true;
}
......@@ -625,6 +628,8 @@ public abstract class CheckerboardPage : Page {
// if drag-selecting, stop here and do nothing else
if (drag_select) {
drag_select = false;
selection_band.width = 0;
selection_band.height = 0;
// force a repaint to remove the selection band
layout.bin_window.invalidate_rect(null, false);
......@@ -751,24 +756,6 @@ public abstract class CheckerboardPage : Page {
foreach (LayoutItem item in intersection)
select(item);
// generate the GC on demand rather than when window is mapped
if (selection_gc == null) {
// set up GC's for painting selection
Gdk.GCValues gc_values = Gdk.GCValues();
gc_values.foreground = fetch_color(LayoutItem.SELECTED_COLOR, layout.bin_window);
gc_values.function = Gdk.Function.COPY;
gc_values.fill = Gdk.Fill.SOLID;
gc_values.line_width = 0;
Gdk.GCValuesMask mask =
Gdk.GCValuesMask.FOREGROUND
| Gdk.GCValuesMask.FUNCTION
| Gdk.GCValuesMask.FILL
| Gdk.GCValuesMask.LINE_WIDTH;
selection_gc = new Gdk.GC.with_values(layout.bin_window, gc_values, mask);
}
// for a refresh to paint the selection band
layout.bin_window.invalidate_rect(null, false);
}
......@@ -820,9 +807,26 @@ public abstract class CheckerboardPage : Page {
return true;
}
private void on_layout_mapped() {
// set up GC's for painting selection
Gdk.GCValues gc_values = Gdk.GCValues();
gc_values.foreground = fetch_color(LayoutItem.SELECTED_COLOR, layout.bin_window);
gc_values.function = Gdk.Function.COPY;
gc_values.fill = Gdk.Fill.SOLID;
gc_values.line_width = 0;
Gdk.GCValuesMask mask =
Gdk.GCValuesMask.FOREGROUND
| Gdk.GCValuesMask.FUNCTION
| Gdk.GCValuesMask.FILL
| Gdk.GCValuesMask.LINE_WIDTH;
selection_gc = new Gdk.GC.with_values(layout.bin_window, gc_values, mask);
}
private void on_layout_exposed() {
// this method only used to draw selection rectangle
if (!drag_select)
if (selection_band.width == 0 || selection_band.height == 0)
return;
assert(selection_gc != null);
......
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