Hi guys, I've been making a MigLayout for Fantom and I've ran into some difficulties.
Here is my problem. I'm trying to debug my MigPane and in order to do so I need to have comparable data (I'm comparing existing SWT implementation with my fwt implementation). So I did a little test.
So the discrepancy between these two don't worry me, however what does worry me is the fact that prefSize returns just (0,0). Could you guys look into this issue?
PS. I tried to replace some instances of prefSize with size, but the problem is that when I call my computeSize method from the MigLayout's source file, the size is 0,0 as well.
PSS. Also the behavior between Widget varies (for example TextField has default pref for 230,0) in SWT I think all Widgets have both dimensions pre-assigned.
brianMon 21 Mar 2011
SWT Widget routes prefSize to SWT computeSize (look in WidgetPeer.java). Although keep in mind that a Fantom widgets isn't always bound to its Control (as a work around to SWT requiring the parent during construction).
DanielFathMon 21 Mar 2011
Still, it seems to be Label never gets any prefSize (even after being displayed on a Window), while others get only a dimension. Couldn't Label and other calculate their size based on number of letters or something? I'll have to see with Mikael, if this is the real culprit.
qualidafialThu 24 Mar 2011
What happens to the prefSize when the widget has been added to a visible window? This may be caused by the SWT widget not being created yet.
brianThu 24 Mar 2011
What happens to the prefSize when the widget has been added to a visible window? This may be caused by the SWT widget not being created yet.
If a widget isn't mounted in the SWT then prefSize will be 0,0. So it is really only meaningful during the layout cycle handled by relayout (which Fantom controls separately from SWT). Often things like Labels need to mounted anyhow to figure out their font metrics, etc.
DanielFathThu 24 Mar 2011
Ok, brian got a question. How can I delay layout until my components prefSize is something usable (both h and w are different than 0 )? If I feed the MiGLayout engine something with zeroes in it, it will just display it weirdly.
brianFri 25 Mar 2011
Hi Daniel,
If you want it work inside FWT work, you have to follow FWT layout model which requires you to subclass from fwt::Pane and do your layout inside the onLayout callback. See:
If you want it work inside FWT work, you have to follow FWT layout model which requires you to subclass from fwt::Pane and do your layout inside the onLayout callback.
I did do my layout in onLayout and my MigPane had Widget[] constrainsWidget. I'll try to add few more checks.
BTW is there a way to make a map that has a mutable keys? I need a Widget:Obj? map but there isn't a way to make it.
DanielFathFri 25 Mar 2011
Ok, I managed to make to "fix" it. I have no clue why this works as it does. But I'd like Fantom's community help in testing out and discovering bugs.
When making it serializable do I need to have my own each method if I added some new additions?
Is it possible to compile it into JavaScript using @JS annotations even if it contains code in a /java folder?
andyFri 25 Mar 2011
Is it possible to compile it into JavaScript using @JS annotations even if it contains code in a /java folder
If your code requires peer implementations - then yes you will need to provide appropriate JS versions. If you have pure Fantom code, then those classes will work just fine without them.
Also - looks like your repo might not be public?
DanielFathFri 25 Mar 2011
Ah, ok tnx. Does that still stand in case my code uses Java FFI (I call MiGLayout from my code)?
Also sorry about that. It's open now.
andyFri 25 Mar 2011
Cool - took a quick look at your code - looks like you depend on the Java impl of some of the Mig stuff. If you were interested in getting MigPane to work in JS (which I assume thats what you were asking?) - you would really need to write the complete implementation in Fantom.
DanielFathFri 25 Mar 2011
There is no way to serialize the MigPane send it to MiGLayout for calculations and then deserialize it to JavaScript?
andyFri 25 Mar 2011
You could do that if you wanted - but relayout gets called alot (remember this is all built and run client-side) - so practically speaking you wouldn't want to block on network requests each time you needed to relayout.
DanielFath Sat 19 Mar 2011
Hi guys, I've been making a MigLayout for Fantom and I've ran into some difficulties.
Here is my problem. I'm trying to debug my MigPane and in order to do so I need to have comparable data (I'm comparing existing
SWT
implementation with myfwt
implementation). So I did a little test.This is
size
andcomputeSize
inSWT
:This is
size
andprefSize
infwt
:So the discrepancy between these two don't worry me, however what does worry me is the fact that
prefSize
returns just(0,0)
. Could you guys look into this issue?PS. I tried to replace some instances of
prefSize
withsize
, but the problem is that when I call mycomputeSize
method from the MigLayout's source file, the size is 0,0 as well.PSS. Also the behavior between Widget varies (for example TextField has default pref for 230,0) in SWT I think all Widgets have both dimensions pre-assigned.
brian Mon 21 Mar 2011
SWT Widget routes prefSize to SWT computeSize (look in WidgetPeer.java). Although keep in mind that a Fantom widgets isn't always bound to its Control (as a work around to SWT requiring the parent during construction).
DanielFath Mon 21 Mar 2011
Still, it seems to be Label never gets any
prefSize
(even after being displayed on a Window), while others get only a dimension. Couldn't Label and other calculate their size based on number of letters or something? I'll have to see with Mikael, if this is the real culprit.qualidafial Thu 24 Mar 2011
What happens to the
prefSize
when the widget has been added to a visible window? This may be caused by the SWT widget not being created yet.brian Thu 24 Mar 2011
If a widget isn't mounted in the SWT then prefSize will be 0,0. So it is really only meaningful during the layout cycle handled by relayout (which Fantom controls separately from SWT). Often things like Labels need to mounted anyhow to figure out their font metrics, etc.
DanielFath Thu 24 Mar 2011
Ok, brian got a question. How can I delay layout until my components
prefSize
is something usable (both h and w are different than 0 )? If I feed the MiGLayout engine something with zeroes in it, it will just display it weirdly.brian Fri 25 Mar 2011
Hi Daniel,
If you want it work inside FWT work, you have to follow FWT layout model which requires you to subclass from fwt::Pane and do your layout inside the onLayout callback. See:
DanielFath Fri 25 Mar 2011
This doesn't apply to all widgets. For instance.
I did do my layout in onLayout and my MigPane had
Widget[] constrainsWidget
. I'll try to add few more checks.BTW is there a way to make a map that has a mutable keys? I need a
Widget:Obj?
map but there isn't a way to make it.DanielFath Fri 25 Mar 2011
Ok, I managed to make to "fix" it. I have no clue why this works as it does. But I'd like Fantom's community help in testing out and discovering bugs.
Here is the link https://bitbucket.org/DanielFath/migpane to repository.
Few more questions:
@JS
annotations even if it contains code in a/java
folder?andy Fri 25 Mar 2011
If your code requires peer implementations - then yes you will need to provide appropriate JS versions. If you have pure Fantom code, then those classes will work just fine without them.
Also - looks like your repo might not be public?
DanielFath Fri 25 Mar 2011
Ah, ok tnx. Does that still stand in case my code uses Java FFI (I call MiGLayout from my code)?
Also sorry about that. It's open now.
andy Fri 25 Mar 2011
Cool - took a quick look at your code - looks like you depend on the Java impl of some of the Mig stuff. If you were interested in getting MigPane to work in JS (which I assume thats what you were asking?) - you would really need to write the complete implementation in Fantom.
DanielFath Fri 25 Mar 2011
There is no way to serialize the MigPane send it to MiGLayout for calculations and then deserialize it to JavaScript?
andy Fri 25 Mar 2011
You could do that if you wanted - but relayout gets called alot (remember this is all built and run client-side) - so practically speaking you wouldn't want to block on network requests each time you needed to relayout.