Fwd: [SOLVED] Re: overlapping elements in St.BoxLayout



Solution to my overlapping elements problem; I'm re-sending this to
gnome-shell-list so the (sort-of-)solution will make it to the
archives (I tried last Friday but the list was down).

---------- Forwarded message ----------
From: Amy C <mathematical coffee gmail com>
Date: 10 August 2012 10:14
Subject: [SOLVED] Re: overlapping elements in St.BoxLayout
To: "Jasper St. Pierre" <jstpierre mecheye net>
Cc: gnome-shell-list gnome org


On 9 August 2012 11:58, Jasper St. Pierre <jstpierre mecheye net> wrote:
> You could use anchor_x/anchor_y.

That didn't work - the box & its contents were still underneath the bin:

layout = new St.BoxLayout({vertical: true});
layout.add(box);
layout.add(bin);

Mainloop.idle_add(function() {
    // put into mainloop because box.height is styled in ems and if I
query straight away
    // I get 'attempt to access theme node of widget before it was
added to stage'
    box.anchor_y = -box.height/2;
});

However, what *did* work (similar to and inspired by this) was to add
the box to layout *after* the bin was added, and then setting its y
and anchor y relative to the `bin`:

layout.add(bin);
layout.add(box); // add this after so in an overlap this is on top

// now we have to move box vertically to the top of `layout`:
Mainloop.idle_add(function () {
    box.y = 0;
    box.anchor_y = box.height/2; // cause an overlap. Need the
mainloop for this .height request.
});

(And remove the `height: 1em;` from `box`'s style from my previous attempt).

There is still a slight  visual delay though on initial display of
`layout` where it has the full height allocated at first and then a
little after shrinks (once the Mainloop.idle_add modifications take
effect). It'll do for now.

thanks!


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