[sushi/wip/cosimoc/no-clutter: 9/50] mainWindow: remove more dependencies on Clutter



commit b1974f24ded643cfc583518d8a6df9e1fe868d1e
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Sun Jul 19 11:26:31 2015 -0700

    mainWindow: remove more dependencies on Clutter
    
    The various containers have now been removed; we add the texture
    directly to the stage.

 src/js/ui/mainWindow.js | 93 +++++++++++++------------------------------------
 1 file changed, 25 insertions(+), 68 deletions(-)
---
diff --git a/src/js/ui/mainWindow.js b/src/js/ui/mainWindow.js
index 4450840..9f77dbb 100644
--- a/src/js/ui/mainWindow.js
+++ b/src/js/ui/mainWindow.js
@@ -49,7 +49,6 @@ var MainWindow = new Lang.Class({
     _init : function(args) {
         args = args || {};
 
-        this._background = null;
         this._isFullScreen = false;
         this._pendingRenderer = null;
         this._renderer = null;
@@ -84,14 +83,13 @@ var MainWindow = new Lang.Class({
         this._gtkWindow.set_visual(screen.get_rgba_visual());
 
         this._gtkWindow.connect('delete-event',
-                                Lang.bind(this, this._onWindowDeleteEvent));
-        this._gtkWindow.connect('realize', Lang.bind(this,
-            function() {
-                // don't support maximize and minimize
-                this._gtkWindow.get_window().set_functions(Gdk.WMFunction.MOVE |
-                                                           Gdk.WMFunction.RESIZE |
-                                                           Gdk.WMFunction.CLOSE);
-            }));
+                                Lang.bind(this, this._onDeleteEvent));
+        this._gtkWindow.connect('key-press-event',
+                                Lang.bind(this, this._onKeyPressEvent));
+        this._gtkWindow.connect('motion-notify-event',
+                                Lang.bind(this, this._onMotionNotifyEvent));
+        this._gtkWindow.connect('realize',
+                                Lang.bind(this, this._onRealize));
 
         this._embed = new Gtk.Overlay();
         this._gtkWindow.add(this._embed);
@@ -112,60 +110,27 @@ var MainWindow = new Lang.Class({
                                                   blue: 0,
                                                   alpha: 255 }));
 
-        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._gtkWindow.connect('key-press-event',
-                                Lang.bind(this, this._onKeyPressEvent));
-        this._gtkWindow.connect('motion-notify-event',
-                                Lang.bind(this, this._onMotionNotifyEvent));
+        this._stage.set_layout_manager(new Clutter.BinLayout());
 
         this._stage.connect('button-press-event',
                             Lang.bind(this, this._onButtonPressEvent));
     },
 
-    _createSolidBackground: function() {
-        if (this._background)
-            return;
-
-        this._background = new Clutter.Rectangle();
-        this._background.set_opacity(255);
-        this._background.set_color(new Clutter.Color({ red: 0,
-                                                       green: 0,
-                                                       blue: 0,
-                                                       alpha: 255 }));
-
-        this._mainLayout.add(this._background, Clutter.BinAlignment.FILL, Clutter.BinAlignment.FILL);
-        this._background.lower_bottom();
-    },
-
-    _createAlphaBackground: function() {
-        if (this._background)
-            return;
-
-        this._background = new Clutter.Actor();
-        this._background.set_background_color(new Clutter.Color({ red: 0,
-                                                                  green: 0,
-                                                                  blue: 0,
-                                                                  alpha: 255 }));
-        this._background.set_opacity(Constants.VIEW_BACKGROUND_OPACITY);
-        this._mainLayout.add(this._background, Clutter.BinAlignment.FILL, Clutter.BinAlignment.FILL);
-
-        this._background.lower_bottom();
-    },
-
     /**************************************************************************
      ****************** main object event callbacks ***************************
      **************************************************************************/
-    _onWindowDeleteEvent : function() {
+    _onDeleteEvent : function() {
         this._clearAndQuit();
     },
 
-    _onKeyPressEvent : function(actor, event) {
+    _onRealize: function() {
+        // don't support maximize and minimize
+        this._gtkWindow.get_window().set_functions(Gdk.WMFunction.MOVE |
+                                                   Gdk.WMFunction.RESIZE |
+                                                   Gdk.WMFunction.CLOSE);
+    },
+
+    _onKeyPressEvent : function(widget, event) {
         let key = event.get_keyval()[1];
 
         if (key == Gdk.KEY_Escape ||
@@ -328,9 +293,12 @@ var MainWindow = new Lang.Class({
                                           factor: 0.5,
                                           align_axis: Clutter.AlignAxis.Y_AXIS });
         this._texture.add_constraint(this._textureYAlign);
+        this._texture.add_constraint(
+            new Clutter.BindConstraint({ coordinate: Clutter.BindCoordinate.SIZE,
+                                         source: this._stage }));
 
         this.refreshSize();
-        this._mainGroup.add_child(this._texture);
+        this._stage.add_child(this._texture);
     },
 
     /**************************************************************************
@@ -340,18 +308,13 @@ var MainWindow = new Lang.Class({
         this._stage.disconnect(this._unFullScreenId);
         this._unFullScreenId = 0;
 
-        /* We want the alpha background back now */
-        this._background.destroy();
-        this._background = null;
-        this._createAlphaBackground();
-
         this._textureYAlign.factor = this._savedYFactor;
 
         let textureSize = this._getTextureSize();
         this._texture.set_size(textureSize[0],
                                textureSize[1]);
 
-        Tweener.addTween(this._mainGroup,
+        Tweener.addTween(this._texture,
                          { opacity: 255,
                            time: 0.15,
                            transition: 'easeOutQuad'
@@ -372,7 +335,7 @@ var MainWindow = new Lang.Class({
         /* quickly fade out everything,
          * and then unfullscreen the (empty) window.
          */
-        Tweener.addTween(this._mainGroup,
+        Tweener.addTween(this._texture,
                          { opacity: 0,
                            time: 0.10,
                            transition: 'easeOutQuad',
@@ -387,13 +350,8 @@ var MainWindow = new Lang.Class({
         this._stage.disconnect(this._fullScreenId);
         this._fullScreenId = 0;
 
-        /* We want a solid black background */
-        this._background.destroy();
-        this._background = null;
-        this._createSolidBackground();
-
         /* Fade in everything */
-        Tweener.addTween(this._mainGroup,
+        Tweener.addTween(this._texture,
                          { opacity: 255,
                            time: 0.15,
                            transition: 'easeOutQuad'
@@ -438,7 +396,7 @@ var MainWindow = new Lang.Class({
         /* quickly fade out everything,
          * and then fullscreen the (empty) window.
          */
-        Tweener.addTween(this._mainGroup,
+        Tweener.addTween(this._texture,
                          { opacity: 0,
                            time: 0.10,
                            transition: 'easeOutQuad',
@@ -535,7 +493,6 @@ var MainWindow = new Lang.Class({
 
     setFile : function(file) {
         this.file = file;
-        this._createAlphaBackground();
         this._createRenderer(file);
         this._createTexture();
         this._createToolbar();


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