Added a label to switcher

This commit is contained in:
Tom Beckmann 2012-05-29 16:54:37 +02:00
parent 6f5eebd5fb
commit 9a67563021
3 changed files with 64 additions and 8 deletions

View File

@ -9,15 +9,29 @@ public class WindowSwitcher : Clutter.Group {
Clutter.CairoTexture bg;
Clutter.CairoTexture cur;
Clutter.Text title;
int _windows = 1;
public int windows {
get { return _windows; }
set { _windows = value; this.width = spacing+_windows*(ICON_SIZE+spacing); }
set {
_windows = value;
this.width = spacing+_windows*(ICON_SIZE+spacing);
}
}
GLib.List<weak Meta.Window> window_list;
Meta.Window? current_window;
Meta.Window? _current_window;
Meta.Window? current_window {
get { return _current_window; }
set {
_current_window = value;
this.title.text = this.current_window.title;
this.title.x = this.width/2-this.title.width/2;
}
}
Gala.Plugin plugin;
@ -26,7 +40,6 @@ public class WindowSwitcher : Clutter.Group {
this.height = ICON_SIZE+spacing*2;
this.opacity = 0;
this.scale_x = 0;
this.scale_gravity = Clutter.Gravity.CENTER;
this.bg = new Clutter.CairoTexture (100, 100);
@ -63,8 +76,14 @@ public class WindowSwitcher : Clutter.Group {
});
this.windows = 1;
this.title = new Clutter.Text.with_text ("bold 16px", "");
this.title.y = ICON_SIZE + spacing*2 + 6;
this.title.color = {255, 255, 255, 255};
this.title.add_effect (new TextShadowEffect (1, 1, 220));
this.add_child (bg);
this.add_child (cur);
this.add_child (title);
bg.add_constraint (new Clutter.BindConstraint (this, Clutter.BindCoordinate.WIDTH, 0));
bg.add_constraint (new Clutter.BindConstraint (this, Clutter.BindCoordinate.HEIGHT, 0));
@ -74,8 +93,7 @@ public class WindowSwitcher : Clutter.Group {
plugin.end_modal ();
current_window.activate (e.time);
this.animate (Clutter.AnimationMode.EASE_OUT_QUAD, 200, opacity:0).
completed.connect ( () => { this.scale_x = 0.0f; });
this.animate (Clutter.AnimationMode.EASE_OUT_QUAD, 200, opacity:0);
}
return true;
});
@ -112,7 +130,7 @@ public class WindowSwitcher : Clutter.Group {
public void list_windows (Meta.Display display, Meta.Screen screen,
Meta.KeyBinding binding, bool backward) {
this.get_children ().foreach ( (c) => { //clear
if (c != cur && c != bg)
if (c != cur && c != bg && c != title)
this.remove_child (c);
});
@ -154,6 +172,8 @@ public class WindowSwitcher : Clutter.Group {
});
this.windows = i;
this.title.text = this.current_window.title;
var idx = this.window_list.index (this.current_window);
cur.x = spacing+idx*(spacing+ICON_SIZE);
}

View File

@ -68,8 +68,7 @@ namespace Gala {
this.winswitcher.x = w/2-winswitcher.width/2;
this.winswitcher.y = h/2-winswitcher.height/2;
this.winswitcher.grab_key_focus ();
this.winswitcher.animate (Clutter.AnimationMode.EASE_OUT_QUAD, 250, opacity:255,
scale_x:1.0F);
this.winswitcher.animate (Clutter.AnimationMode.EASE_OUT_QUAD, 250, opacity:255);
}
public void workspace_switcher (Meta.Screen screen, bool up) {

View File

@ -1,3 +1,40 @@
public class TextShadowEffect : Clutter.Effect {
int _offset_y;
public int offset_y {
get { return _offset_y; }
set { _offset_y = value; this.update (); }
}
int _offset_x;
public int offset_x {
get { return _offset_x; }
set { _offset_x = value; this.update (); }
}
uint8 _opacity;
public uint8 opacity {
get { return _opacity; }
set { _opacity = value; this.update (); }
}
public TextShadowEffect (int offset_x, int offset_y, uint8 opacity) {
this._offset_x = offset_x;
this._offset_y = offset_y;
this._opacity = opacity;
}
public override bool pre_paint () {
var layout = ((Clutter.Text)this.get_actor ()).get_layout ();
Cogl.pango_render_layout (layout, this.offset_x, this.offset_y,
Cogl.Color.from_4ub (0, 0, 0, opacity), 0);
return true;
}
public void update () {
if (this.get_actor () != null)
this.get_actor ().queue_redraw ();
}
}
namespace Gala {
const string VERSION = "0.1";