[ease/animate_zoom: 5/6] Use ZoomSlider in EditorWindow.
- From: Nate Stedman <natesm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ease/animate_zoom: 5/6] Use ZoomSlider in EditorWindow.
- Date: Thu, 20 May 2010 03:37:59 +0000 (UTC)
commit 8f8799d95c64840a75795bf529e71c42328ca492
Author: Nate Stedman <natesm gmail com>
Date: Wed May 19 23:25:41 2010 -0400
Use ZoomSlider in EditorWindow.
src/libease/EditorWindow.vala | 77 +++++------------------------------------
src/libease/ZoomSlider.vala | 16 ++++++++
2 files changed, 25 insertions(+), 68 deletions(-)
---
diff --git a/src/libease/EditorWindow.vala b/src/libease/EditorWindow.vala
index 8ee254b..3f4388c 100644
--- a/src/libease/EditorWindow.vala
+++ b/src/libease/EditorWindow.vala
@@ -32,10 +32,7 @@ public class Ease.EditorWindow : Gtk.Window
public Gtk.HBox slides;
public TransitionPane pane_transition;
public SlidePane pane_slide;
- public Gtk.HScale zoom_slider;
- private Gtk.Button zoom_in;
- private Gtk.Button zoom_out;
- private int zoom_previous = 0;
+ public ZoomSlider zoom_slider;
// the player for this window
private Player player;
@@ -51,8 +48,8 @@ public class Ease.EditorWindow : Gtk.Window
public bool slides_shown { get; set; }
// constants
- private const int[] ZOOM_LEVELS = {10, 25, 33, 50, 66, 75, 100, 125, 150,
- 200, 250, 300, 400};
+ private int[] ZOOM_LEVELS = {10, 25, 33, 50, 66, 75, 100, 125, 150,
+ 200, 250, 300, 400};
private const int ZOOM_COUNT = 13;
/**
@@ -214,40 +211,8 @@ public class Ease.EditorWindow : Gtk.Window
});
// change the embed's zoom when the zoom slider is moved
- zoom_slider.change_value.connect((scroll, zoom, user_data) => {
- if (zoom_previous != (float)zoom_slider.get_value())
- {
- embed.set_zoom((float)zoom_slider.get_value());
- }
- zoom_previous = zoom;
- return false;
- });
-
- // zoom in and out with the buttons
- zoom_in.clicked.connect(() => {
- for (var i = 0; i < ZOOM_COUNT; i++)
- {
- if (zoom_slider.get_value() < ZOOM_LEVELS[i])
- {
- zoom_slider.set_value(ZOOM_LEVELS[i]);
- embed.set_zoom(ZOOM_LEVELS[i]);
- zoom_previous = ZOOM_LEVELS[i];
- break;
- }
- }
- });
-
- zoom_out.clicked.connect(() => {
- for (var i = ZOOM_COUNT - 1; i > -1; i--)
- {
- if (zoom_slider.get_value() > ZOOM_LEVELS[i])
- {
- zoom_slider.set_value(ZOOM_LEVELS[i]);
- embed.set_zoom(ZOOM_LEVELS[i]);
- zoom_previous = ZOOM_LEVELS[i];
- break;
- }
- }
+ zoom_slider.value_changed.connect(() => {
+ embed.set_zoom((float)zoom_slider.get_value());
});
hide.connect(() => Main.remove_window(this));
@@ -354,44 +319,20 @@ public class Ease.EditorWindow : Gtk.Window
var hbox = new Gtk.HBox(false, 5);
// create zoom slider
- zoom_slider = new Gtk.HScale(new Gtk.Adjustment(100, 10, 400, 10, 50, 50));
+ zoom_slider = new ZoomSlider(new Gtk.Adjustment(100, 10, 400, 10,
+ 50, 50), ZOOM_LEVELS);
zoom_slider.width_request = 200;
zoom_slider.value_pos = Gtk.PositionType.RIGHT;
zoom_slider.digits = 0;
- // format the slider text
- zoom_slider.format_value.connect(val => {
- return "%i%%".printf((int)val);
- });
-
- // zoom in button
- zoom_in = new Gtk.Button();
- zoom_in.add(new Gtk.Image.from_stock("gtk-zoom-in", Gtk.IconSize.MENU));
- zoom_in.relief = Gtk.ReliefStyle.NONE;
-
- // zoom out button
- zoom_out = new Gtk.Button();
- zoom_out.add(new Gtk.Image.from_stock("gtk-zoom-out", Gtk.IconSize.MENU));
- zoom_out.relief = Gtk.ReliefStyle.NONE;
-
// put it all together
- var align = new Gtk.Alignment(0, 0.5f, 1, 0);
- align.add(zoom_out);
- hbox.pack_start(align, false, false, 0);
-
- align = new Gtk.Alignment(0, 0.5f, 1, 0);
- align.add(zoom_slider);
- hbox.pack_start(align, false, false, 0);
-
- align = new Gtk.Alignment(0, 0.5f, 1, 0);
- align.add(zoom_in);
- hbox.pack_start(align, false, false, 0);
+ hbox.pack_start(zoom_slider, false, false, 0);
var vbox = new Gtk.VBox(false, 0);
vbox.pack_start(new Gtk.HSeparator(), false, false, 0);
vbox.pack_start(hbox, true, true, 2);
- align = new Gtk.Alignment(1, 1, 1, 1);
+ var align = new Gtk.Alignment(1, 1, 1, 1);
align.add(vbox);
return align;
}
diff --git a/src/libease/ZoomSlider.vala b/src/libease/ZoomSlider.vala
index 02bc483..dc199e9 100644
--- a/src/libease/ZoomSlider.vala
+++ b/src/libease/ZoomSlider.vala
@@ -24,6 +24,18 @@ public class Ease.ZoomSlider : Gtk.Alignment
private Gtk.Button zoom_in;
private Gtk.Button zoom_out;
private int[] values;
+
+ public Gtk.PositionType value_pos
+ {
+ get { return zoom_slider.value_pos; }
+ set { zoom_slider.value_pos = value; }
+ }
+
+ public int digits
+ {
+ get { return zoom_slider.digits; }
+ set { zoom_slider.digits = value; }
+ }
public ZoomSlider(Gtk.Adjustment adjustment, int[] button_values)
{
@@ -86,6 +98,10 @@ public class Ease.ZoomSlider : Gtk.Alignment
}
}
});
+
+ zoom_slider.format_value.connect(val => {
+ return "%i%%".printf((int)val);
+ });
}
public double get_value()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]