[ease/iconview] showing things
- From: Nate Stedman <natesm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ease/iconview] showing things
- Date: Tue, 12 Oct 2010 00:50:28 +0000 (UTC)
commit 8ee3f19714c30eaa426ed0bd189d345263dbd98b
Author: Nate Stedman <natesm gmail com>
Date: Mon Aug 30 11:21:50 2010 -0400
showing things
ease-core/ease-icon-view.vala | 61 +++++++++++++++++++++++++++++++++++-----
1 files changed, 53 insertions(+), 8 deletions(-)
---
diff --git a/ease-core/ease-icon-view.vala b/ease-core/ease-icon-view.vala
index e869bd6..59e99f2 100644
--- a/ease-core/ease-icon-view.vala
+++ b/ease-core/ease-icon-view.vala
@@ -30,6 +30,13 @@ public class Ease.IconView : ScrollableEmbed
public int item_padding { get; set; default = 6; }
/**
+ * The item-height property specifies the height to use for each item. If it
+ * is set to -1, the icon view will automatically determine a suitable item
+ * size.
+ */
+ public int item_height { get; set; default = 64; }
+
+ /**
* The item-width property specifies the width to use for each item. If it
* is set to -1, the icon view will automatically determine a suitable item
* size.
@@ -257,11 +264,51 @@ public class Ease.IconView : ScrollableEmbed
*/
private Gee.LinkedList<IconActor> actors = new Gee.LinkedList<IconActor>();
+ /**
+ * The number of { link IconActor}s displayed per line.
+ */
+ private int actors_per_line;
+
public IconView()
{
// initialize the ScrollableEmbed
base(false, false);
get_stage().color = {150, 150, 150, 255};
+
+ // lay out the iconview when the stage's allocation changes
+ size_allocate.connect((self, rect) => {
+ // determine the number of actors per line
+ actors_per_line = 0;
+ for (int x = margin + item_padding; x < rect.width - margin;
+ x += item_padding + item_width)
+ {
+ actors_per_line++;
+ x += column_spacing;
+ }
+
+ // at least one actor needs to be displayed
+ if (actors_per_line == 0) actors_per_line = 1;
+
+ // lay out all actors
+ float x = margin + item_padding, y = margin + item_padding;
+ int i = 0;
+ foreach (var actor in actors)
+ {
+ actor.set_position(x, y);
+ i++;
+
+ if (i < actors_per_line)
+ {
+ x += item_padding + item_width + column_spacing;
+ }
+ else
+ {
+ i = 0;
+ x = margin + item_padding;
+ y += column_spacing + item_padding;
+ }
+ }
+ });
}
public IconView.with_model(Gtk.TreeModel model)
@@ -285,7 +332,7 @@ public class Ease.IconView : ScrollableEmbed
{
foreach (var actor in actors)
{
- if (actor.tree_path == path)
+ if (actor.tree_path.to_string() == path.to_string())
{
set_actor(actor, iter, path);
break;
@@ -312,10 +359,9 @@ public class Ease.IconView : ScrollableEmbed
var actor = new IconActor();
set_actor(actor, iter, path);
actors.offer_tail(actor);
- get_stage().add_actor(actor);
+ contents.add_actor(actor);
actor.show();
get_stage().show_all();
- debug("Added Actor");
}
private void on_model_rows_reordered(Gtk.TreeModel model, Gtk.TreePath path,
@@ -343,6 +389,7 @@ public class Ease.IconView : ScrollableEmbed
model.get(iter, markup_column, out text);
if (text != null)
{
+ debug(text);
actor.set_markup(text);
text_set = true;
}
@@ -352,12 +399,12 @@ public class Ease.IconView : ScrollableEmbed
if (!text_set && text_column != -1)
{
model.get(iter, text_column, out text);
+ debug(text);
if (text != null) actor.set_text(text);
}
// set the actor's tree path
actor.tree_path = tree_path;
- debug("Actor set");
}
/**
@@ -405,8 +452,6 @@ public class Ease.IconView : ScrollableEmbed
texture = new Clutter.Texture();
background = new Clutter.Rectangle.with_color({255, 0, 0, 255});
- background.set_size(200, 200);
- background.show();
}
/**
@@ -424,10 +469,10 @@ public class Ease.IconView : ScrollableEmbed
2 * TEXT_PADDING + TEXT_HEIGHT;
// show the texture and background
- texture.show();
- if (texture.get_parent() != this) add_actor(texture);
background.show();
if (background.get_parent() != this) add_actor(background);
+ texture.show();
+ if (texture.get_parent() != this) add_actor(texture);
}
catch (Error e)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]