[sushi] main-window: cleanup layout code



commit 7a67d979370f0fe40bad6f3135badc97b93a13ac
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Tue Jul 3 13:57:24 2012 -0400

    main-window: cleanup layout code
    
    Reduce the use of constraints and use align/expand flags or margins when
    possible. Requires Clutter 1.11.4 for the x-expand property of
    ClutterActor.

 configure.ac            |    2 +-
 src/js/ui/mainWindow.js |   37 +++++++++++--------------------------
 src/js/viewers/gst.js   |    8 +++-----
 3 files changed, 15 insertions(+), 32 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index f19b379..6f0ade6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -49,7 +49,7 @@ GLIB_GSETTINGS
 GJS_JS_DIR=`$PKG_CONFIG --variable=datadir gjs-1.0`/gjs-1.0
 AC_SUBST(GJS_JS_DIR)
 
-CLUTTER_MIN_VERSION=1.10.0
+CLUTTER_MIN_VERSION=1.11.4
 GLIB_MIN_VERSION=2.29.14
 GTK_MIN_VERSION=3.0.0
 GJS_MIN_VERSION=0.7.7
diff --git a/src/js/ui/mainWindow.js b/src/js/ui/mainWindow.js
index 0bb8db3..a7dcf4b 100644
--- a/src/js/ui/mainWindow.js
+++ b/src/js/ui/mainWindow.js
@@ -118,6 +118,9 @@ MainWindow.prototype = {
 
         this._mainLayout = new Clutter.BinLayout();
         this._mainGroup = new Clutter.Actor({ layout_manager: this._mainLayout });
+        this._mainGroup.add_constraint(
+            new Clutter.BindConstraint({ coordinate: Clutter.BindCoordinate.SIZE,
+                                         source: this._stage }));
         this._stage.add_actor(this._mainGroup);
         this._mainGroup.set_opacity(0);
 
@@ -139,14 +142,8 @@ MainWindow.prototype = {
                                                        green: 0,
                                                        blue: 0,
                                                        alpha: 255 }));
-        this._background.add_constraint(
-            new Clutter.BindConstraint({ source: this._stage,
-                                         coordinate: Clutter.BindCoordinate.POSITION }));
-        this._background.add_constraint(
-            new Clutter.BindConstraint({ source: this._stage,
-                                         coordinate: Clutter.BindCoordinate.SIZE }));
 
-        this._mainGroup.add_child(this._background);
+        this._mainLayout.add(this._background, Clutter.BinAlignment.FILL, Clutter.BinAlignment.FILL);
         this._background.lower_bottom();
     },
 
@@ -165,14 +162,8 @@ MainWindow.prototype = {
         }
 
         this._background.set_opacity(Constants.VIEW_BACKGROUND_OPACITY);
-        this._background.add_constraint(
-            new Clutter.BindConstraint({ source: this._stage,
-                                         coordinate: Clutter.BindCoordinate.POSITION }));
-        this._background.add_constraint(
-            new Clutter.BindConstraint({ source: this._stage,
-                                         coordinate: Clutter.BindCoordinate.SIZE }));
+        this._mainLayout.add(this._background, Clutter.BinAlignment.FILL, Clutter.BinAlignment.FILL);
 
-        this._mainGroup.add_child(this._background);
         this._background.lower_bottom();
     },
 
@@ -347,16 +338,10 @@ MainWindow.prototype = {
         }
 
         this._texture = this._renderer.render();
-
-        this._textureXAlign =
-            new Clutter.AlignConstraint({ source: this._stage,
-                                          factor: 0.5 });
         this._textureYAlign =
             new Clutter.AlignConstraint({ source: this._stage,
                                           factor: 0.5,
                                           align_axis: Clutter.AlignAxis.Y_AXIS });
-
-        this._texture.add_constraint(this._textureXAlign);
         this._texture.add_constraint(this._textureYAlign);
 
         this.refreshSize();
@@ -518,13 +503,13 @@ MainWindow.prototype = {
 
         this._toolbarActor.set_reactive(true);
         this._toolbarActor.set_opacity(0);
-        this._toolbarActor.add_constraint(
-            new Clutter.AlignConstraint({ source: this._stage,
-                                          factor: 0.5 }));
 
         this._toolbarActor.margin_bottom = Constants.TOOLBAR_SPACING;
+        this._toolbarActor.margin_left = Constants.TOOLBAR_SPACING;
+        this._toolbarActor.margin_right = Constants.TOOLBAR_SPACING;
+
         this._mainLayout.add(this._toolbarActor,
-                             Clutter.BinAlignment.FIXED, Clutter.BinAlignment.END);
+                             Clutter.BinAlignment.CENTER, Clutter.BinAlignment.END);
     },
 
     _removeToolbarTimeout: function() {
diff --git a/src/js/viewers/gst.js b/src/js/viewers/gst.js
index 97e8043..6e31665 100644
--- a/src/js/viewers/gst.js
+++ b/src/js/viewers/gst.js
@@ -144,14 +144,12 @@ GstRenderer.prototype = {
     createToolbar : function () {
         this._mainToolbar = new Gtk.Toolbar({ icon_size: Gtk.IconSize.MENU });
         this._mainToolbar.get_style_context().add_class('osd');
+        this._mainToolbar.set_show_arrow(false);
         this._mainToolbar.show();
 
         this._toolbarActor = new GtkClutter.Actor({ contents: this._mainToolbar,
-                                                    opacity: 0 });
-        this._toolbarActor.add_constraint(
-            new Clutter.BindConstraint({ source: this._video,
-                                         coordinate: Clutter.BindCoordinate.WIDTH,
-                                         offset: -50 }));
+                                                    opacity: 0,
+                                                    x_expand: true });
 
         this._toolbarPlay = new Gtk.ToolButton({ icon_name: 'media-playback-pause-symbolic' });
         this._toolbarPlay.show();



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]