Merge pull request #34 from kelunik/master

Fix vertical alignment, fixes #30
This commit is contained in:
oleid 2017-11-03 17:43:21 +01:00 committed by GitHub
commit eccb722095
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 11 deletions

View File

@ -54,7 +54,7 @@ const TeaTimeFullscreenNotification = new Lang.Class({
// a table imitating a vertical box layout to hold the texture and
// a label underneath it
this._layout = new St.BoxLayout({vertical:true, y_align:Clutter.ActorAlign.CENTER});
this._layout = new St.BoxLayout({ vertical: true, y_align: Clutter.ActorAlign.CENTER });
this._bin.set_child(this._layout);
// find all the textures
@ -145,7 +145,7 @@ const TeaTime = new Lang.Class({
Extends : PanelMenu.Button,
_init : function() {
this.parent(0.0, "TeaTime");
this.parent(null, "TeaTime");
this._settings = Utils.getSettings();
@ -158,6 +158,7 @@ const TeaTime = new Lang.Class({
this._graphicalTimer = new Icon.TwoColorIcon(24, Icon.Pie);
this.actor.add_actor(this._logo);
this.actor.add_style_class_name('panel-status-button');
this.actor.connect('style-changed', Lang.bind(this, this._onStyleChanged));
this._idleTimeout = null;

View File

@ -22,7 +22,7 @@ const TwoColorIcon = new Lang.Class({
Extends: St.DrawingArea,
_init : function(size, drawingObject) {
this.parent({ reactive : true });
this.parent({ reactive : true, style: 'padding: 0px 2px' });
this.set_width(size);
this.set_height(size);
this._drawingObject = drawingObject;
@ -53,21 +53,23 @@ const TwoColorIcon = new Lang.Class({
this.queue_repaint();
},
_drawIcon: function() {
let cr = this.get_context();
let cr = this.get_context();
let orWdt = this._drawingObject.width;
let orHgt = this._drawingObject.height;
let[width, height] = this.get_surface_size();
let[width, height] = this.get_surface_size();
cr.save();
// layout object in box
if (orWdt/orHgt > width/height) {
// take full width and center vertically
cr.translate(0, height * 0.5);
cr.scale(width/orWdt, width/orWdt);
cr.translate(0, (orWdt-orHgt)*0.5);
cr.translate(0, (height*width/orWdt - orHgt) * 0.5);
} else {
cr.scale(height/orHgt, height/orHgt)
cr.translate(-(orWdt-orHgt)*0.5, 0);;
cr.translate(width * 0.5, 0);
cr.scale(height/orHgt, height/orHgt);
cr.translate((width*height/orHgt - orWdt) * 0.5, 0);
}
this._drawingObject.draw(cr, this._customStatus, this._primaryColor, this._secundaryColor);