[ease] Scrolling works in new slide sorter.
- From: Nate Stedman <natesm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ease] Scrolling works in new slide sorter.
- Date: Sat, 27 Nov 2010 10:59:08 +0000 (UTC)
commit 54891caffd8b1df1873b5a1e029f67f8f41891a4
Author: Nate Stedman <natesm gmail com>
Date: Sat Nov 27 05:58:45 2010 -0500
Scrolling works in new slide sorter.
* Added ScrolledEmbed and ScrolledEmbedWindow
ease-core/Makefile.am | 2 +
ease-core/ease-icon-view.vala | 11 +++++-
ease-core/ease-scrolled-embed-window.vala | 30 ++++++++++++++++++
ease-core/ease-scrolled-embed.vala | 48 +++++++++++++++++++++++++++++
ease/ease-slide-sorter.vala | 21 ++++++------
5 files changed, 100 insertions(+), 12 deletions(-)
---
diff --git a/ease-core/Makefile.am b/ease-core/Makefile.am
index 69a6ffa..648cea2 100644
--- a/ease-core/Makefile.am
+++ b/ease-core/Makefile.am
@@ -27,6 +27,8 @@ libease_core_ EASE_CORE_VERSION@_la_SOURCES = \
ease-plugin-import-service.vala \
ease-pdf-actor.vala \
ease-pdf-element.vala \
+ ease-scrolled-embed.vala \
+ ease-scrolled-embed-window.vala \
ease-shape-element.vala \
ease-slide.vala \
ease-temp.vala \
diff --git a/ease-core/ease-icon-view.vala b/ease-core/ease-icon-view.vala
index 3d2515a..d494279 100644
--- a/ease-core/ease-icon-view.vala
+++ b/ease-core/ease-icon-view.vala
@@ -203,6 +203,10 @@ public class Ease.IconView : Clutter.Box
(actor as Icon).update_pixbuf(pixbuf_column);
});
});
+
+ notify["text-color"].connect(() => {
+ @foreach((actor) => (actor as Icon).text.color = text_color);
+ });
}
public void selected_foreach(ForeachFunc callback)
@@ -428,7 +432,8 @@ public class Ease.IconView : Clutter.Box
var p = new Gtk.TreePath.from_string(model.get_string_from_iter(iter));
var icon = new Icon(new Gtk.TreeRowReference(model, p),
markup_column != -1 ? markup_column : text_column,
- markup_column == -1, pixbuf_column);
+ markup_column == -1, pixbuf_column,
+ text_color);
// connect signals
icon.select.connect(on_icon_select);
@@ -470,7 +475,8 @@ public class Ease.IconView : Clutter.Box
public signal void select(Icon icon, Clutter.ModifierType modifiers);
public Icon(Gtk.TreeRowReference reference, int text_col,
- bool use_markup, int pixbuf_col)
+ bool use_markup, int pixbuf_col,
+ Clutter.Color text_color)
{
this.reference = reference;
@@ -478,6 +484,7 @@ public class Ease.IconView : Clutter.Box
text = new Clutter.Text.with_text("Sans 8", " ");
text.line_alignment = Pango.Alignment.CENTER;
text.single_line_mode = false;
+ text.color = text_color;
add_actor(text);
// initial "update" of text and pixbuf
diff --git a/ease-core/ease-scrolled-embed-window.vala b/ease-core/ease-scrolled-embed-window.vala
new file mode 100644
index 0000000..11814e3
--- /dev/null
+++ b/ease-core/ease-scrolled-embed-window.vala
@@ -0,0 +1,30 @@
+/* Ease, a GTK presentation application
+ Copyright (C) 2010 Nate Stedman
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+/**
+ * A GtkScrolledWindow that contains a { link ScrolledEmbed}.
+ */
+public class Ease.ScrolledEmbedWindow : Gtk.ScrolledWindow
+{
+ public ScrolledEmbed embed { get; private set; }
+
+ public ScrolledEmbedWindow(Gtk.Adjustment? zadjustment)
+ {
+ embed = new ScrolledEmbed(hadjustment, vadjustment, zadjustment);
+ add(embed);
+ }
+}
diff --git a/ease-core/ease-scrolled-embed.vala b/ease-core/ease-scrolled-embed.vala
new file mode 100644
index 0000000..e607445
--- /dev/null
+++ b/ease-core/ease-scrolled-embed.vala
@@ -0,0 +1,48 @@
+/* Ease, a GTK presentation application
+ Copyright (C) 2010 Nate Stedman
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+/**
+ * A GtkClutterEmbed with scrolling capabilities.
+ */
+public class Ease.ScrolledEmbed : GtkClutter.Embed
+{
+ /**
+ * The viewport. Actors should be placed on this, not on the stage.
+ * It is automatically resized as the stage resizes.
+ */
+ public GtkClutter.Viewport viewport { get; private set; }
+
+ public ScrolledEmbed(Gtk.Adjustment hadjustment,
+ Gtk.Adjustment vadjustment,
+ Gtk.Adjustment? zadjustment)
+ {
+ // create the viewport
+ viewport = new GtkClutter.Viewport(hadjustment,
+ vadjustment,
+ zadjustment);
+
+ // add the viewport to the stage
+ (get_stage() as Clutter.Stage).add_actor(viewport);
+ viewport.show();
+
+ // resize the viewport with the stage
+ get_stage().allocation_changed.connect(() => {
+ viewport.width = get_stage().width;
+ viewport.height = get_stage().height;
+ });
+ }
+}
diff --git a/ease/ease-slide-sorter.vala b/ease/ease-slide-sorter.vala
index 3d3f407..848d9b0 100644
--- a/ease/ease-slide-sorter.vala
+++ b/ease/ease-slide-sorter.vala
@@ -18,25 +18,30 @@
/**
* A widget displaying an icon view the user can use to sort and delete slides.
*/
-internal class Ease.SlideSorter : Gtk.ScrolledWindow
+internal class Ease.SlideSorter : ScrolledEmbedWindow
{
private Ease.IconView view;
- private GtkClutter.Embed embed;
private Document document;
private const int WIDTH = 100;
private const int WIDTH_ADDITIONAL = 300;
private const int LARGE_WIDTH = WIDTH + WIDTH_ADDITIONAL;
- private const int PADDING = 10;
+ private const int PADDING = 100;
private int width;
internal signal void display_slide(Slide s);
internal SlideSorter(Document doc, double zoom)
{
+ base(null);
+
+ // document
document = doc;
document.slide_added.connect(on_slide_added);
+ // no hscrollbars
+ hscrollbar_policy = Gtk.PolicyType.NEVER;
+
// render dynamic-sized pixbufs
Slide slide;
foreach (var itr in document.slides)
@@ -61,15 +66,11 @@ internal class Ease.SlideSorter : Gtk.ScrolledWindow
view.item_width = WIDTH;
// add and show the iconview
- embed = new GtkClutter.Embed();
- (embed.get_stage() as Clutter.Stage).add_actor(view);
- embed.show();
- add(embed);
+ embed.viewport.add_actor(view);
// maintain the icon view's size when the stage is resized
- embed.get_stage().allocation_changed.connect(() => {
- view.width = embed.get_stage().width - 2 * PADDING;
- view.height = embed.get_stage().height - 2 * PADDING;
+ embed.viewport.allocation_changed.connect(() => {
+ view.width = embed.viewport.width - 2 * PADDING;
});
// when a slide is clicked, show it in the editor
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]