Bug 361731 - Set size constraints on children of PartSashContainer
Summary: Set size constraints on children of PartSashContainer
Status: NEW
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.1   Edit
Hardware: All All
: P3 normal with 4 votes (vote)
Target Milestone: ---   Edit
Assignee: Platform-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: helpwanted
Depends on:
Blocks:
 
Reported: 2011-10-22 11:43 EDT by Karl Weber CLA
Modified: 2019-12-18 01:28 EST (History)
15 users (show)

See Also:


Attachments
screenshot: relative and absolute settings in the model (190.17 KB, image/png)
2014-08-15 15:16 EDT, Steven Spungin CLA
no flags Details
screenshot: before resize (86.49 KB, image/png)
2014-08-15 15:17 EDT, Steven Spungin CLA
no flags Details
screenshot: after resize (135.46 KB, image/png)
2014-08-15 15:17 EDT, Steven Spungin CLA
no flags Details
screenshot: before resize (with toolitem) (147.86 KB, image/png)
2014-09-07 12:05 EDT, Steven Spungin CLA
no flags Details
screenshot: after resize (with toolitem) (177.42 KB, image/png)
2014-09-07 12:05 EDT, Steven Spungin CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Karl Weber CLA 2011-10-22 11:43:08 EDT
Build Identifier: M20110912-1510

As far as I know, one can put integer numbers in the field Container Data of the children of a PartSashContainer. They determine the _relative_ sizes of these children of the parent PartSashContainer.

(1) Now I would like to set an absolute size constraint on one child, minimum or maximum size (in my case maximum size). The other children should take up the remainder of the space. How can one do this?

(2) There seems to be another problem even with relative sizes: One can set the relative size of one child to 5%. If the application is started, the child gets this 5%, even if the window is maximized. However, if one tries to change the size with the sash only a tiny little bit, the size of the child jumps to 10% (estimate). Afterward one cannot set the size of the child below this (estimated) 10%; above that limit, one can change its size at will (well up to 90% at the upper end, in case the parent has two children). In other words, there is a limit on the relative size.

Reproducible: Always
Comment 1 Siva Kovvuri CLA 2012-08-28 14:08:27 EDT
Any solution?
Comment 2 Eric Moffatt CLA 2012-08-29 13:45:34 EDT
The sash container uses integers to maintain the ratios between its elements. The code will attempt to maintain this as well as maintaining the *total* of the weights. I think your issue for the %'age changes is that you are starting with a total that is too small.

For example if you simply use weights of '9' and '1' to be the percentages then the only choice the sash has would be 10% increments. Try using 1000 / 9000 instead and you'll give the sash container code enough 'space' to be able to adjust the sashes down to the pixel level.

As far as setting min or max values goes I think it's a good idea. First cut would be two persistent data 'keys' that can be used to store the *percentage* value for either min or max. I'd prefer to use the percentage since it's independent of the actual integer range being used (see above). There is already code in the SashLayout that restricts the range to a fixed percentage so this should be relatively straightforward to implement (patches welcome! ;-).
Comment 3 Siva Kovvuri CLA 2012-09-01 13:44:26 EDT
Thanks a lot Eric for the detailed explanation. My actual requirement is to show a branding image just below the toolbar, the model i was trying is the below one

PartShashContainer
-->Part (to show branding image)
-->PartStack
---->Part
---->Part

Want to fix the height and show the complete image irrespective of height of the window to the maximum possible.
Comment 4 Eric Moffatt CLA 2012-09-04 14:27:21 EDT
Siva, no promises that this will work in your situation but you might try the following:

Make an MToolControl and add it to the top trim *at the end*.
Have the implementation construct the 'branding image' at whatever height you wish

Now, also have the implementation always set its *width* to match the shell's client area's width (add a resize listener to the Shell).

This will cause that control to 'wrap', putting it below the rest of the top trim's entries (i.e. the main toolbar).
Comment 5 Steven Spungin CLA 2014-08-15 15:15:59 EDT
I implemented a patch for absolute sizes.  Container data can be in one of the following formats.

<empty>
Integer
 relative percentage (legacy)
Integer <optional spaces> '%'
 relative percentage
Integer <optional spaces> 'px'
 absolute size in pixels

Relative sizes take up the remaining space after absolute sizes are allocated.

If a sash is resized, the absolute or relative values are adjusted but still kept as absolute or relative.

It would be nice to specify min/max constraints in the configuration string as well, but I will leave that to a future enhancement.

It is undetermined what the impact will be on other renderers besides SashRenderer/SashLayout; there very well may be a better solution.
Comment 6 Steven Spungin CLA 2014-08-15 15:16:58 EDT
Created attachment 246056 [details]
screenshot: relative and absolute settings in the model
Comment 7 Steven Spungin CLA 2014-08-15 15:17:27 EDT
Created attachment 246057 [details]
screenshot: before resize
Comment 8 Steven Spungin CLA 2014-08-15 15:17:56 EDT
Created attachment 246058 [details]
screenshot: after resize
Comment 9 Steven Spungin CLA 2014-08-15 15:42:23 EDT
Gerrit Review: https://git.eclipse.org/r/#/c/31777/

This patch does not yet contain min/max code but allows absolute sizing by using a 'px' suffix
Comment 10 Steven Spungin CLA 2014-08-15 16:33:06 EDT
For min and max limiting, I am thinking allowing any combination fixed or relative values using a terse CSS-like syntax.

examples:

10%;min:5%;max:50%

min:50px;max:500px

min:20px;50%;max:80%

default:40%;min:5px
Comment 11 Lars Vogel CLA 2014-08-22 07:32:39 EDT
Are you planning to support a fixed size directly? Setting min / max to the same value would work but maybe having explicit support would help.
Comment 12 Steven Spungin CLA 2014-08-22 08:31:44 EDT
(In reply to Lars Vogel from comment #11)
> Are you planning to support a fixed size directly? Setting min / max to the
> same value would work but maybe having explicit support would help.

min:100px (same as 100px;min:100px)
the part will be set to 100px, will only grow if sash is dragged, and cannot get smaller.

min:100px;max:100px (same as 100px;min:100px;max:100px)
this is fixed size

I could certainly add this attribute to the spec:
fixed:100px (can't be resized)
fixed:50%  (only resized when shell is, and always 50 weight)
It would be trivial for us to implement, but more rope for the end user...

I was not too pleased with how the UI responds with max values set.  The current code handles sash dragging by adjusting adjacent parts.  If one side maxes out, the sash appears to be frozen.  There is no visual indicator, and it makes for a seemingly unresponsive UI.  Min constraints are much more intuitive as to why the sash cannot be moved.  Flashing the part border or changing the appearance of the sash or cursor are options.
Comment 13 Steven Spungin CLA 2014-09-06 08:22:56 EDT
I suggest using the terms Fixed and Relative for the 2 sizing modes.  Relative would be a weight and fixed would be pixel setting.

This makes more sense than using absolute and relative.
Comment 14 Steven Spungin CLA 2014-09-07 12:04:26 EDT
After using the current patch in the field, I have changed my approach.

This new approach is based on 3 concepts:

1.  Initial size can be expressed in weights or pixels.

2.  Separate parameter specifies whether or not the part resizes when the parent resizes.

3.  Minimum and maximum constraints are not a good idea and have been removed.

The initial size can be set as an absolute or relative value, independent of the resize mode of the part.  This was the major flaw in my initial approach.

A part can have one of two resizing modes:  Weighted and Fixed.  A fixed resize mode part only changes sizes when its neighbor sash is moved.  A weighted resize mode part changes sizes when its parent is resized, relative to its weighted siblings.  The resizing mode should not change when a part is moved to another stack.

The user should be able to change the resizing mode.  I created an addon that adds a tool item each parts toolbar for this purpose; There are obviously other approaches to this.

Every sash container must have at least 1 weighted resize mode part to consume remaining space in the container.  The system will convert a fixed resize mode to weighted resize mode if needed.

The size specified (either as a relative weight or absolute size) only applies to the initial display of the part.  When a part is resized, the size will be adjusted based on the mode.  When a part is moved to a new sash container, the size will be set based on the system default part distribution settings.

Minimum and maximum settings make the UI seem unrepsonsive.  They also do not apply when the part is moved to a sash with a different orientation (unless their parameter can specify both width and height).  This functionality will be commented out in the patch, to be reintroduced as an experimental feature if requested.
Comment 15 Steven Spungin CLA 2014-09-07 12:05:11 EDT
Created attachment 246798 [details]
screenshot: before resize (with toolitem)
Comment 16 Steven Spungin CLA 2014-09-07 12:05:32 EDT
Created attachment 246799 [details]
screenshot: after resize (with toolitem)
Comment 17 Lars Vogel CLA 2014-09-08 07:46:02 EDT
Is https://git.eclipse.org/r/#/c/32189/ still the correct Gerrit review?
Comment 18 Lars Vogel CLA 2014-10-24 08:59:51 EDT
(In reply to Lars Vogel from comment #17)
> Is https://git.eclipse.org/r/#/c/32189/ still the correct Gerrit review?

Steven AFAIK you have an updated version of this. Could you point me to the latest Gerrit review?
Comment 19 Eric Moffatt CLA 2015-08-17 15:20:17 EDT
Once you have this working you should check to make sure that incompatible situations are handled correctly. For example:

- if both parts have a min size and there's not enough space what happens
- if both parts have a max size and there's too much space

This is a nice feature to have but can cause issues when used in odd combinations. This isn't a problem as long as the various situations are covered in the docs and nothing catches fire...;-).
Comment 20 Stefan Xenos CLA 2015-12-18 13:30:10 EST
What is the use-case for this? Understanding the use-case is necessary to make sure any new API here serves its intended purpose.

The old (pre-E4) PartSashContainer supported minimum sizes, maximum sizes, and fixed height/width children.

At the time, the purpose of fixed height/width children was to prevent views on the edge of the editor are from resizing when the window was resized. In order to handle this use-case well, the behavior of having a fixed or relative size can't be baked into the layout -- it has to be computed based on what sort of other views are present in the layout (ie: is there an editor in one of the other children). That is, the views would prefer fixed sizing but if there was no editor on the other side of a sash, the views would revert to relative sizing.

I agree that min/max constraints aren't a good idea unless we have a strong use-case for them. In Eclipse 3.x, min/max sizes were needed to support a "minimized" mode for view stacks and it needed to support wrapping tabs, which brought along with it a bunch of extra limitations.

Looking at the attached patch, I see it's doing some regex matching inside the layout code. We probably shouldn't do that, since layouts need to be very fast. It may be better to cache the quantities we need as ints/bools (for example, an isFixed boolean and an int size) and only update them when they change.
Comment 21 Elena Laskavaia CLA 2016-02-22 11:28:14 EST
My use case: I have a static control that is just a label (kind of) and I want
it on top of the Part Stack. Depending on initial window if I use weight it will
be either cut off or have lots of extra unneeded space. Setting a static size will fix that. 
I cannot think of a use case where max size is needed though.
Comment 22 Lars Vogel CLA 2016-04-20 12:06:48 EDT
Mass move to 4.7 as M7 is approaching. Please move back in case you are planning to fix it for Neon.
Comment 23 Stefan Xenos CLA 2016-08-16 13:27:31 EDT
Re: comment 21

This is PartSashContainer, though... so your "control" is actually a view or editor, or are you doing a funky RCP thing that is using a PartSashContainer without the rest of the workbench? Can your control appear in a stack with other views or is it a standalone view that can't be stacked with?
Comment 24 Stefan Wild CLA 2017-04-18 08:19:55 EDT
boolean "fixed" and integer size would be a good idea.

Our use-case is what Stefan Xenos wrote in comment:20 - we need fixed height/width children to prevent views on the edge of the Application from resizing when the window is resized. Our users should be able to define the size of the right Part of the Application (which is DetailsPart) and this setting should not change if the window size changes. The left Parts of the Application are designated to use as much space as available.

This is an actual problem for us and our customers and we found no (good) workaround yet.
Comment 25 Christoph Laeubrich CLA 2019-03-23 02:31:46 EDT
Is there any update on this isse?
I also have demands for fixed sized controls inside PartSash.

We use e$ Model editor to define views, and some of the views contains a Toolbar like control that should as  Stefan Wild described, not resize, but the rest of the parts should take the extra space.
Comment 26 Lars Vogel CLA 2019-12-17 14:15:10 EST
(In reply to Christoph Laeubrich from comment #25)
> Is there any update on this isse?
> I also have demands for fixed sized controls inside PartSash.
> 
> We use e$ Model editor to define views, and some of the views contains a
> Toolbar like control that should as  Stefan Wild described, not resize, but
> the rest of the parts should take the extra space.

I think Steven pushed a patch got Gerrit a few years ago. If you have interested in reworking it, I can search for it.
Comment 27 Christoph Laeubrich CLA 2019-12-17 14:27:58 EST
Sure why not :-)
Comment 28 Lars Vogel CLA 2019-12-17 14:37:32 EST
(In reply to Christoph Laeubrich from comment #27)
> Sure why not :-)

https://git.eclipse.org/r/#/c/32189/
Comment 29 Steven Spungin CLA 2019-12-17 15:12:09 EST
Yep, we pushed a fork with a working implementation back in the day...
Comment 30 Lars Vogel CLA 2019-12-17 15:15:40 EST
(In reply to Steven Spungin from comment #29)
> Yep, we pushed a fork with a working implementation back in the day...

You should return at some point, we are now much more agile. You would like it. :-) (yeah, I know, no chance, you are happy with Kotlin and the like...) ;-(
Comment 31 Steven Spungin CLA 2019-12-17 15:56:23 EST
Hey Lars, I miss you guys, but JetBrains has wooed me by sending free stuff. LOL.

It's great to hear you have honed the development process!

I'd offer more help on this issue, but it was so long ago;  IIRC there was a peculiar messaging architecture that was the major hurdle in getting this off the ground.