[ShellGenericContainer] remove example
There are plenty of examples in js/ui/ now https://bugzilla.gnome.org/show_bug.cgi?id=611647
This commit is contained in:
parent
f6b4fa6e7e
commit
0f0e3d9644
@ -10,90 +10,6 @@
|
||||
* into signals, which gjs can catch.
|
||||
*/
|
||||
|
||||
/* Example implementation of a horzontal box with PACK_EXPAND for all,
|
||||
vertically and horizontally centering.
|
||||
|
||||
function TestFixedBox() {
|
||||
this._init();
|
||||
}
|
||||
|
||||
TestFixedBox.prototype = {
|
||||
_init : function () {
|
||||
this.actor = new Shell.GenericContainer();
|
||||
this.spacing = 4;
|
||||
this.actor.connect('get-preferred-width', Lang.bind(this, function (actor, for_height, alloc) {
|
||||
let children = this.actor.get_children();
|
||||
let max_child_min = 0;
|
||||
let max_child_nat = 0;
|
||||
for (let i = 0; i < children.length; i++) {
|
||||
let spacing = i > 0 && i < children.length-1 ? this.spacing : 0;
|
||||
let [child_min, child_nat] = children[i].get_preferred_width(for_height);
|
||||
if (child_min > max_child_min)
|
||||
max_child_min = child_min;
|
||||
if (child_nat > max_child_nat)
|
||||
max_child_nat = child_nat;
|
||||
}
|
||||
let totalSpacing = this.spacing * Math.abs(children.length - 1);
|
||||
alloc.min_size = children.length * max_child_min + totalSpacing;
|
||||
alloc.nat_size = children.length * max_child_nat + totalSpacing;
|
||||
}));
|
||||
this.actor.connect('get-preferred-height', Lang.bind(this, function (actor, for_width, alloc) {
|
||||
let children = this.actor.get_children();
|
||||
let max_child_min = 0;
|
||||
let max_child_nat = 0;
|
||||
for (let i = 0; i < children.length; i++) {
|
||||
let [child_min, child_nat] = children[i].get_preferred_height(for_width);
|
||||
if (child_min > max_child_min)
|
||||
max_child_min = child_min;
|
||||
if (child_nat > max_child_nat)
|
||||
max_child_nat = child_nat;
|
||||
}
|
||||
alloc.min_size = max_child_min;
|
||||
alloc.nat_size = max_child_nat;
|
||||
}));
|
||||
this.actor.connect('allocate', Lang.bind(this, function (actor, box, flags) {
|
||||
let children = this.actor.get_children();
|
||||
let totalSpacing = (this.spacing * Math.abs(children.length - 1));
|
||||
let child_width = (box.x2 - box.x1 - totalSpacing) / (children.length);
|
||||
let child_height = box.y2 - box.y1;
|
||||
|
||||
let x = box.x1;
|
||||
for (let i = 0; i < children.length; i++) {
|
||||
let [child_min, child_nat] = children[i].get_preferred_height(child_width);
|
||||
let vSpacing = Math.abs(child_height - child_nat) / 2;
|
||||
let childBox = new Clutter.ActorBox();
|
||||
childBox.x1 = x;
|
||||
childBox.y1 = vSpacing;
|
||||
childBox.x2 = x+child_width;
|
||||
childBox.y2 = child_height - vSpacing;
|
||||
children[i].allocate(childBox, flags);
|
||||
x += this.spacing + child_width;
|
||||
}
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
function runTestFixedBox() {
|
||||
let testBox = new TestFixedBox();
|
||||
let c = new Clutter.Color();
|
||||
c.from_pixel(0xff0000a0);
|
||||
let r = new Clutter.Rectangle({ width: 50, height: 100, color: c });
|
||||
testBox.actor.add_actor(r);
|
||||
r = new Clutter.Rectangle({ width: 90, height: 70, color: c });
|
||||
testBox.actor.add_actor(r);
|
||||
r = new Clutter.Rectangle({ width: 90, height: 70, color: c });
|
||||
testBox.actor.add_actor(r);
|
||||
r = new Clutter.Rectangle({ width: 30, height: 10, color: c });
|
||||
testBox.actor.add_actor(r);
|
||||
|
||||
c.from_pixel(0x00ff00a0);
|
||||
let borderBox = new Big.Box({ border: 1, border_color: c });
|
||||
borderBox.set_position(100, 100);
|
||||
borderBox.append(testBox.actor, Big.BoxPackFlags.NONE);
|
||||
Shell.Global.get().stage.add_actor(borderBox);
|
||||
}
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "shell-generic-container.h"
|
||||
|
Loading…
x
Reference in New Issue
Block a user