jhickman / gxt-uibinder

Automatically exported from code.google.com/p/gxt-uibinder
0 stars 0 forks source link

HBoxLayout support #10

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Since I use HBoxLayout (and to some extent, VBoxLayout) combined with RowLayout 
for 90% of the layouts I do, I would love to see HBoxLayout and VBoxLayout 
supported in the near future, if possible.

thanks!

Original issue reported on code.google.com by joel.re...@gmail.com on 10 Mar 2011 at 4:52

GoogleCodeExporter commented 9 years ago
sorry, I meant this as an enhancement request.

Original comment by joel.re...@gmail.com on 10 Mar 2011 at 4:53

GoogleCodeExporter commented 9 years ago
Have you tried setting layout="HBoxLayout" or layout="VBoxLayout"?  I just 
looked at the code, and it looks like I've included this already.

It's been there since at least version 0.6

Original comment by jus...@jhickman.com on 10 Mar 2011 at 4:57

GoogleCodeExporter commented 9 years ago
hmm....ok, I just looked at the code and I'm not seeing it. I'll try it anyway, 
maybe it's covered under GenericLayoutParser.  I'm on 0.7.

Original comment by joel.re...@gmail.com on 11 Mar 2011 at 12:23

GoogleCodeExporter commented 9 years ago
The HBoxLayout is there, but I need to work on supporting the HBoxLayoutData 
for nested elements.

Original comment by jus...@jhickman.com on 14 Mar 2011 at 2:52

GoogleCodeExporter commented 9 years ago
well, yeah...that plus the setHBoxLayoutAlign, setPack, setPadding (possibly 
others) related attributes in the HBoxLayout main element.  I guess i wouldn't 
mind doing this if you are busy.  Might need a little help if I run into 
trouble though.

Original comment by joel.re...@gmail.com on 14 Mar 2011 at 9:17

GoogleCodeExporter commented 9 years ago
This has been a general issue with how the Layouts work.  I'm unsure on a 
decent way to address this via XML.  I've been able to address the 
LayoutData-type objects to be set as the second argument to the "add" method of 
the surrounding container, but not sure how to set values on the Layout object 
itself.

For your example above, how do you suppose the setters could be called?

I've thought about the following.  
<gxt:LayoutContainer>
  <gxt:layout type="HBoxLayout" hBoxLayoutAlign=".." pack=".." padding=".." />

  <gxt:layoutdata type="HBoxLayoutData" margins="0,5,0,0">
    <button:Button text="Button 1" />
  </gxt:layoutdata>
  <gxt:layoutdata type="HBoxLayoutData" margins="0,5,0,0">
    <button:Button text="Button 1" />
  </gxt:layoutdata>
  <gxt:layoutdata type="HBoxLayoutData" margins="0,5,0,0">
    <button:Button text="Button 1" />
  </gxt:layoutdata>
  <gxt:layoutdata type="HBoxLayoutData" margins="0">
    <button:Button text="Button 1" />
  </gxt:layoutdata>
</gxt:LayoutContainer>

This could be an alternative to <gxt:LayoutContainer layout="HBoxLayout"/>  if 
properties on the layout must be set.  It can die if the layout attribute as 
well as child element are both present.  Only a single gxt:layout element can 
exist.

This would essentially produce the following Java:
LayoutContainer foo = new LayoutContainer();
HBoxLayout layout = new HBoxLayout();
layout.setHBoxLayoutAlign(..);
layout.setPack(..);
layout.setPadding(..);

Button button1 = new Button();
button1.setText("Button 1");
HBoxLayoutData layoutData = new HBoxLayoutData();
layoutData.setMargins(new Margins(0,5,0,0));
layout.add(button1, layoutData);

Button button2 = new Button();
button2.setText("Button 2");
layoutData = new HBoxLayoutData();
layoutData.setMargins(new Margins(0,5,0,0));
layout.add(button2, layoutData);

Button button3 = new Button();
button3.setText("Button 3");
layoutData = new HBoxLayoutData();
layoutData.setMargins(new Margins(0,5,0,0));
layout.add(button3, layoutData);

Button button4 = new Button();
button4.setText("Button 4");
layoutData = new HBoxLayoutData();
layoutData.setMargins(new Margins(0));
layout.add(button4, layoutData);

Thoughts?  Other ideas?  This has been something I've been avoiding for awhile. 
 I want to be sure to maintain a backwards compatibility.

Original comment by jus...@jhickman.com on 14 Mar 2011 at 9:54

GoogleCodeExporter commented 9 years ago
That seems like a pretty decent design to me.  

A cool thing (if possible) would be to support multiple children for a 
layoutdata element for those cases where it is redundant.

I guess as you work with it, things like this become more obvious.

Original comment by joel.re...@gmail.com on 14 Mar 2011 at 11:43

GoogleCodeExporter commented 9 years ago
BTW, this project totally rocks. thanks for the good work so far.

Original comment by joel.re...@gmail.com on 14 Mar 2011 at 11:47

GoogleCodeExporter commented 9 years ago
Thanks for the complement.  

As per your comment about supporting multiple children per layoutdata element, 
it is actually possibly with the current release.  I can rewrite the XML 
provided above as this:

<gxt:LayoutContainer layout="HBoxLayout">

  <gxt:layoutdata type="HBoxLayoutData" margins="0,5,0,0">
    <button:Button text="Button 1" />
    <button:Button text="Button 2" />
    <button:Button text="Button 3" />
  </gxt:layoutdata>

  <gxt:layoutdata type="HBoxLayoutData" margins="0">
    <button:Button text="Button 4" />
  </gxt:layoutdata>

</gxt:LayoutContainer>

This would be the equivalent to the following Java. You can see that buttons 1, 
2 and 3 all use a single instance of the HBoxLayoutData where the 4th button 
uses a new instance.

LayoutContainer panel = new LayoutContainer();
HBoxLayout layout = new HBoxLayout();
panel.setLayout(layout);

HBoxLayoutData layoutData = new HBoxLayoutData();
layoutData.setMargins(new Margins(0,5,0,0));

Button button1 = new Button();
button1.setText("Button 1");
layout.add(button1, layoutData);

Button button2 = new Button();
button2.setText("Button 2");
layout.add(button2, layoutData);

Button button3 = new Button();
button3.setText("Button 3");
layout.add(button3, layoutData);

// the 4th button uses a different instance of layoutData
Button button4 = new Button();
button4.setText("Button 4");
layoutData = new HBoxLayoutData();
layoutData.setMargins(new Margins(0));
layout.add(button4, layoutData);

Original comment by jus...@jhickman.com on 15 Mar 2011 at 1:21

GoogleCodeExporter commented 9 years ago
I added Issue 13.  There is a defect in which the layoutdata child elements 
will be consumed first, thus causing containers with a mix to be ordered 
incorrectly.  This won't be a problem if all child elements are surrounded with 
a layoutdata element.

Original comment by jus...@jhickman.com on 15 Mar 2011 at 1:29

GoogleCodeExporter commented 9 years ago
Fixed. Will be available in version 0.8

Original comment by jus...@jhickman.com on 15 Mar 2011 at 5:57

GoogleCodeExporter commented 9 years ago

Original comment by jus...@jhickman.com on 16 Mar 2011 at 3:45