View unanswered posts | View active topics It is currently Sun May 26, 2013 11:19 am



Reply to topic  [ 7 posts ] 
 Difference between hidemode 1 and hidemode 2 ?? 
Author Message

Joined: Fri Sep 21, 2007 1:10 am
Posts: 23
Post Difference between hidemode 1 and hidemode 2 ??
I can't figure out what the difference is between hidemode 1 and 2.

The documentation says:
1 - The size of an invisible component will be set to 0, 0.
2 - The size of an invisible component will be set to 0, 0 and the gaps will also be set to 0 around it.

I don't see any difference between these two modes. All gaps seem to be present, regardless of whether it's hidemode 1 or 2.

At first, I just had three components in a row:
Code:
c.setLayout(new MigLayout("debug, hidemode 2"));
c.add(new JLabel("Hello world"));
JLabel hideme = new JLabel("HIDE ME");
hideme.setVisible(false);
c.add(hideme, "gapright 50");
c.add(new JLabel("Hello 2 world"), "wrap");


Then I thought maybe it didn't work because they have to be in a split cell:
Code:
c.setLayout(new MigLayout("debug, hidemode 2"));
c.add(new JLabel("Hello world"), "split 3");
JLabel hideme = new JLabel("HIDE ME");
hideme.setVisible(false);
c.add(hideme, "gapright 50");
c.add(new JLabel("Hello 2 world"), "wrap");


Then I thought perhaps it will remove row gaps if the invisible component is on it's own row. That didn't matter either. Which gaps does hidemode 2 remove?

Thanks!


Wed Nov 11, 2009 11:03 pm
Profile
Site Admin

Joined: Mon Dec 06, 2004 4:24 pm
Posts: 2485
Location: Sweden
Post Re: Difference between hidemode 1 and hidemode 2 ??
Hmm, then it might be a bug.

It is put, in the now rather long, work queue.

Crazy much to do..

Cheers,
Mikael


Wed Nov 11, 2009 11:11 pm
Profile WWW

Joined: Fri Sep 21, 2007 1:10 am
Posts: 23
Post Re: Difference between hidemode 1 and hidemode 2 ??
Thanks, that's what I was thinking. I hear ya about the work queue :)


Wed Nov 11, 2009 11:31 pm
Profile

Joined: Thu Apr 23, 2009 3:33 pm
Posts: 4
Post Re: Difference between hidemode 1 and hidemode 2 ??
Almost exactly two years later, I was about to ask the same question. In my tests there was no difference between hidemode 1 and hidemode 2. In other words: hidemode 2 does not remove any gaps around the invisible controls.

I have created a small standalone example for SWT to illustrate this. Basically, it creates two columns of labels. The labels on the second column have a gapleft 10, gapright 10 and are then made invisible. The red bar you see when running the example as is, are the two gaps that - from how I would hidemode 2 expect to work - should be gone. Is this a bug, or am I doing something wrong?

Code:
import net.miginfocom.swt.MigLayout;

import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;

public class HideModeTest
{
 
  public static void main(String[] args)
  {
    Display display = new Display();
    Shell shell = new Shell(display);

    shell.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_RED));

    shell.setLayout(new MigLayout("wrap, gap 0, hidemode 2, insets 0", " [] [] "));

    int rows = 10;

    for (int i = 0; i < rows * 2; i++)
    {
      Label label = new Label(shell, SWT.BORDER);
      if (i % 2 > 0)
      {
        label.setLayoutData("gapleft 10, gapright 10");
      }
      label.setText("labellabellabellabellabellabellabellabel");
    }

    Control[] children = shell.getChildren();
    for (int i = 0; i < children.length; i++)
    {
      if (i % 2 > 0)
      {
        children[i].setVisible(false);
      }
    }

    shell.pack();
    shell.open();
    while (!shell.isDisposed())
    {
      if (!display.readAndDispatch())
        display.sleep();
    }
    display.dispose();
  }
 
}


Wed Nov 09, 2011 7:27 pm
Profile
Site Admin

Joined: Mon Dec 06, 2004 4:24 pm
Posts: 2485
Location: Sweden
Post Re: Difference between hidemode 1 and hidemode 2 ??
Hello,

It does not remove the gaps between columns, that would be ambiguous between rows.

If you have two or more components in the same cell it removes the gaps between them.

Cheers,
Mikael


Wed Nov 09, 2011 10:12 pm
Profile WWW

Joined: Thu Apr 23, 2009 3:33 pm
Posts: 4
Post Re: Difference between hidemode 1 and hidemode 2 ??
Hmm, alright. I thought it works something like this: Each cell (or rather the component within it) can tell how much space it wants on each side. If that space is between two components the maximum of the left component's right gap and the right component's left gap is taken. And if one component is made invisible and hidemode is 2, then the component incl. its declared gap requirements are counted as 0. For all my use cases this seems like the natural way to do it.

Oh well, maybe it's an idea to think about for future versions ;)
In any case, thank you for your effort.


Thu Nov 10, 2011 1:29 am
Profile

Joined: Mon Aug 23, 2010 6:24 am
Posts: 54
Post Re: Difference between hidemode 1 and hidemode 2 ??
MiG Support wrote:
Hello,

It does not remove the gaps between columns, that would be ambiguous between rows.

If you have two or more components in the same cell it removes the gaps between them.

Cheers,
Mikael


So now the documentation is ambiguous. It reads "The size of an invisible component will be set to 0, 0 and the gaps will also be set to 0 around it." It sounds as if you're talking about *all* gaps.

I am expecting this behavior: If an entire column is invisible, remove the gap between it and surrounding columns. If an entire row is invisible, remove the gap between it and surrounding rows. The same applies for "split" components: if a split component is invisible, remove the gap between it and surrounding components.


Mon Jan 16, 2012 6:29 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 7 posts ] 

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.