App.prototype.getBody = function() { let label; label = new Gtk.Label({ label: "Open the '" + this.title + "' application menu and click on 'Dialog' or 'Modal'" }); label.setLineWrap(true); label.setLines(5); return label; };
App.prototype.getBody = function() { let content, css1, label1, css2, label2; // CSS from source code css1 = new Gtk.CssProvider(); css1.loadFromData(' * { color: #0a0; font-size: 12px; background-color: rgba(0, 0, 0, 0.5); border-radius: 5px; }'); label1 = new Gtk.Label({ halign: Gtk.Align.CENTER, label: 'Source code CSS', valign: Gtk.Align.CENTER }); label1.getStyleContext().addProvider(css1, 0); label1.setSizeRequest(150, 35); // CSS from .css file class css2 = new Gtk.CssProvider(); css2.loadFromPath(__dirname + '/assets/egCss.css'); label2 = new Gtk.Label({ halign: Gtk.Align.CENTER, label: 'CSS from file', valign: Gtk.Align.CENTER }); label2.getStyleContext().addProvider(css2, 0); label2.setSizeRequest(150, 35); content = new Gtk.Grid({ halign: Gtk.Align.CENTER, columnSpacing: 10, margin: 15, rowSpacing: 10 }); content.attach(label1, 0, 0, 1, 1); content.attach(label2, 0, 1, 1, 1); return content; };
App.prototype.getLabel = function(justification) { let text, label; text = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt'; label = new Gtk.Label({ halign: Gtk.Align.CENTER, label: text, valign: Gtk.Align.START }); label.setSizeRequest(100, -1); label.setEllipsize(Pango.EllipsizeMode.END); label.setMaxWidthChars(10); label.setLineWrap(true); label.setJustify(justification); label.setLines(6); return label; };
App.prototype.buildBody = function() { let embed, grid, titleRotate, scale, buttonStart, buttonStop; embed = new GtkClutter.Embed(); embed.setSizeRequest(400, 240); this.position = new Gtk.Label({ label: 'Drag the square' }); this.position.setSizeRequest(300, -1); titleRotate = new Gtk.Label({ label: 'Rotation: ' }); titleRotate.setSizeRequest(150, -1); scale = new Gtk.Scale({ digits: 1, drawValue: true, valuePos: Gtk.PositionType.LEFT }); scale.setRange(-35, 35); scale.setSizeRequest(150, -1); scale.on('change-value', widget => { this.actor.setRotation(Clutter.RotateAxis.Y_AXIS, widget.getValue(), 50, 0, 0); }); buttonStart = new Gtk.Button({ label: 'Play' }); buttonStart.on('clicked', () => { let tg, pt; pt = new Clutter.PropertyTransition({ propertyName: 'rotation-angle-z' }); pt.setFrom(0); pt.setTo(360); pt.setDuration(2000); pt.setProgressMode(Clutter.AnimationMode.LINEAR); tg = new Clutter.TransitionGroup(); tg.setDuration(2000); tg.setRepeatCount(-1); // Infinite tg.addTransition(pt); // Add more property transitions ... this.actor.addTransition('rotateTransition', tg); scale.setSensitive(false); buttonStart.setSensitive(false); buttonStop.setSensitive(true); }); buttonStop = new Gtk.Button({ label: 'Stop', sensitive: false }); buttonStop.on('clicked', () => { this.actor.removeTransition('rotateTransition'); this.actor.setRotationAngle(Clutter.RotateAxis.Z_AXIS, 0); scale.setSensitive(true); buttonStart.setSensitive(true); buttonStop.setSensitive(false); }); grid = new Gtk.Grid({ columnSpacing: 6, margin: 15, rowSpacing: 6 }); grid.attach(embed, 0, 0, 1, 3); grid.attach(this.position, 1, 0, 2, 1); grid.attach(titleRotate, 1, 1, 1, 1); grid.attach(scale, 2, 1, 1, 1); grid.attach(buttonStart, 1, 2, 1, 1); grid.attach(buttonStop, 2, 2, 1, 1); this.stage = embed.getStage(); this.stage.setColor(new Clutter.Color({ red: 255, green: 255, blue: 255, alpha: 255 })); this.stage.addChild(this.getActor()); return grid; };