Open SyntevoAlex opened 1 year ago
I already have tried to reduce the level of nesting a little bit and created nestable layouts. However, recently I've discovered a problem that still is on my todo-list to be fixed: radio buttons that are inside the same composite with other controls, e.g. checkboxes, magically are moved to the end of the tab list. This can be reproduced in SmartGit's preferences dialog, pages "Commands", "User interface" or - even worse - "Standard window" (which contains 2 radio button groups).
Such a feature would be awesome @SyntevoAlex
I have a client who uses tons of Composites just for layouting his widgets and as this client has tons of widgets he runs into no more handlers exceptions. Having a Composite without an underlying widget only for layouting would be great.
If composites are only created for Layout purpose, then this could maybe easier handled by a layout manager, I'm already working on another layout manager at the moment (not finished yet) but found that this is often a better approach as the "classic" SWT LayoutMangers are often hard to use.
If you want to switch visibility for multiple items at once, maybe an ControlGroup
class would be more suitable, where one can not only switch visibility, but maybe even enablement of multiple items at once and can add/remove items, e.g.
ControlGroup group = new ControlGroup(control1, control2, control3, ...);
group.setVisible(false);
But without an example what layout / managing requirements are there is a bit hard to guess, using Composite
for that seem to me very risky as it has many tasks (e.g. what should be happen for listeners? Parent relative computations) and so on...
I already have tried to reduce the level of nesting a little bit and created nestable layouts. However, recently I've discovered a problem that still is on my todo-list to be fixed: radio buttons that are inside the same composite with other controls, e.g. checkboxes, magically are moved to the end of the tab list. This can be reproduced in SmartGit's preferences dialog, pages "Commands", "User interface" or - even worse - "Standard window" (which contains 2 radio button groups).
See https://github.com/eclipse-platform/eclipse.platform.swt/issues/634
I see that both @laeubi and @tmssngr prefer Layout approach instead of virtual Composite
.
I understand and agree that implementing it in Composite
may have some bugs.
Still, I think that it's an approach that allows to adjust old code much more easily.
Where it fails, code could be left as is or switched to Layout approach.
Either way, I was instructed to not spend time developing the Composite approach.
In SWT,
Composite
is very often used as layout container - that is, the user's needs typically are.setVisible()
multiple Controls at onceHowever, the actual OS control is not needed:
SWT.Paint
etc is not handledThere is a number of downsides of actually creating a control:
There are more exotic issues as well:
StackOverflowError
when pressing Alt (which is recursively passed to parents).N0vaDesktop.exe
program goes crazy already with 18 nesting levels and slows down entire system. It does this by repeatedly and recursively inspecting child windows, which causes Windows kernel-side lock to be too busy, which affects all other programs.The suggestion is to implement something like
SWT.VIRTUAL
style forComposite
, whereComposite
parent instead ofComposite
itself).According to my idea, SWT users will use
SWT.VIRTUAL
manually in each place where they're good with "thin layout container" behavior.