Hi Tom,
your suggestion that qooxdoo's queues interfere with the "center" call
are correct. qooxdoo queues all size changes and computes all size
changes at once. To center a widget you need to know the size of the
parent widget and the size of the widget itself. The "center" methods
uses always the sizes computed in the last layout flush. This is why
your size changes and immediate center calls do not work as expected. I
would suggest you call "center" during the "resize" eventof the window.
This event is fired during the layout flush after the window has been
resized:
win.addListenerOnce("resize", function(e) {
win.center();
}, this);
As an alternative you can manually flush the queues before you center
the widget by calling "qx.ui.core.queue.Manager.flush()" but we don't
suggest doing so because it defeats the purpose of a layout queue and
may impact the performance negatively.
I think the main problem with "center()" is that its API documentation
does not reflect the restrictions I just explained. I'll change the API
doc and close your bug.
Best Fabian
>
> I've got a problem with timing in 0.8.
>
> If I try to set dimensions (height/width) and positions (left/top) of a
> widget and directly calling a built-in qooxdoo method I don't get the result
> I want.
>
> I'll try to explain this by an example. I have a minimal application with
> one window and some buttons. On execute the height and width of the window
> will be set, the window will be centered (using center()-method) and finally
> the window is opened. All three buttons will set different height/width. The
> third button has a timer on the center-call.
>
> Case I:
> Click first button. Window opens centered with correct dimensions. Click
> second button (doesn't matter whether you close window between). The window
> is now opened with correct dimensions but is centered according to the old
> dimensions (set when executing first button).
>
> Case II:
> Case I in reverse. Click second button followed by first button. Result is
> same as case I; dimensions ok, centering is based on the first execution.
>
> Case III (my workaround):
> Click first button. Then click third button. When I added a timer on
> centering in the execute it does as intended. The result is as intended.
>
>
> By this, my questions are: Why is this happening (case I+II)? Is there
> another way to do this? Flushing before calling internal method?
>
>
>
>
> Eksample code:
>
> var win = new qx.ui.window.Window("Test window");
> this.getRoot().add(win);
>
> var testBtn1 = new qx.ui.form.Button("First");
> testBtn1.addListener("execute", function(e) {
> win.set({
> height : 200,
> width : 300
> });
> win.center();
> win.open();
> });
>
> var testBtn2 = new qx.ui.form.Button("Second");
> testBtn2.addListener("execute", function(e) {
> win.set({
> height : 400,
> width : 600
> });
> win.center();
> win.open();
> });
>
> var testBtn3 = new qx.ui.form.Button("Third (w/timer)");
> testBtn3.addListener("execute", function(e) {
> win.set({
> height : 600,
> width : 900
> });
> qx.event.Timer.once(function(e) {
> win.center();
> }, win, 1);
> win.open();
> });
>
> this.getRoot().add(testBtn1, {left: 10, top: 10});
> this.getRoot().add(testBtn2, {left: 80, top: 10});
> this.getRoot().add(testBtn3, {left: 10, top: 50});
>
--
Fabian Jakobs
JavaScript Framework Developer
1&1 Internet AG
Brauerstraße 48
76135 Karlsruhe
Amtsgericht Montabaur HRB 6484
Vorstand: Henning Ahlert, Ralph Dommermuth, Matthias Ehrlich, Thomas
Gottschlich, Matthias Greve, Robert Hoffmann, Markus Huhn, Oliver Mauss, Achim
Weiss
Aufsichtsratsvorsitzender: Michael Scheeren
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel