Opened 3 years ago

Closed 7 months ago

#13673 closed defect (fixed)

Stretchable spacer is missing for vertical wxToolBar

Reported by: catalin Owned by:
Priority: low Milestone:
Component: wxMSW Version: dev-latest
Keywords: wxToolBar vertical stretchable spacer Cc:
Blocked By: Blocking:
Patch: yes

Description

To reproduce it, run toolbar sample, move the toolbar to the left or right side, resize top frame vertically.

Attachments (3)

toolbar-vert.png download (30.3 KB) - added by awi 7 months ago.
Screenshot of vertical toolbar with stretchable spacer.
toolbar-vert-spacer.patch download (3.6 KB) - added by awi 7 months ago.
Patch implementing stretchable spacer for vertical toolbar.
toolbar-vert-spacer_v2.patch download (4.4 KB) - added by awi 7 months ago.
Patch implementing stretchable spacer for vertical toolbar (v2).

Download all attachments as: .zip

Change History (12)

comment:1 Changed 3 years ago by vadz

  • Priority changed from normal to low

Probably a native toolbar control limitation as I don't see anything obviously wrong in wxToolBar code. If this is really the case, then the best thing we can do is to document that this doesn't work under MSW.

comment:2 follow-up: Changed 3 years ago by catalin

I think there are other problems as well. Changing the toolbar sample by adding a stretch spacer on the first position of the toolbar, then moving the toolbar to the side (vertical) will make the toolbar invisible.
If there is any limitation then maybe explicitly ignoring stretchable spaces in vertical toolbars is needed?

comment:3 in reply to: ↑ 2 ; follow-up: Changed 3 years ago by catalin

Some observations:

1) A small change would really improve the toolbar sample, especially for trying to use it in discovering other problems: when toolBar->SetRows is called (2 occurrences), the hard coded value 10 should be replaced with toolBar->GetToolsCount() and GetToolBar()->GetToolsCount() respectively.

2) When making the toolbar vertical wxToolBar::HandleSize is called a lot of times (!). Each time the width of the first tool is retrieved and everything else is calculated based on that. But when a stretch-space is on the first position, that width is continuously increasing until it reaches 32767. I recon that everything based on that number becomes a nonsense.

comment:4 Changed 3 years ago by VZ

(In [69855]) Don't hardcode the number of toolbar tools in the toolbar sample.

Use GetToolsCount() instead of the hardcoded 10 (which can be wrong if any
tools were added or removed).

See #13673.

Changed 7 months ago by awi

Screenshot of vertical toolbar with stretchable spacer.

comment:5 Changed 7 months ago by awi

  • Keywords wxToolBar vertical stretchable spacer added
  • Patch set
  • Version changed from stable-latest to dev-latest

Technique used to implement stretchable spacer for horizontal toolbar doesn't work for vertical toolbar because for some reasons there is no way to change the height of existing separator.
One way to implement this feature is to remove the old separator from vertical toolbar and to insert the new one at the same position.
Patch introducing stretchable spacer for vertical toolbar attached.
Results on the screenshot below.
Screenshot of vertical toolbar with stretchable spacer.

Problem #2 ("Each time the width of the first tool is retrieved and everything else is calculated based on that") is already fixed in r76079

comment:6 in reply to: ↑ 3 Changed 7 months ago by awi

Replying to catalin:

2) When making the toolbar vertical wxToolBar::HandleSize is called a lot of times (!). Each time the width of the first tool is retrieved and everything else is calculated based on that. But when a stretch-space is on the first position, that width is continuously increasing until it reaches 32767. I recon that everything based on that number becomes a nonsense.

Problem no2 ("Each time the width of the first tool is retrieved and everything else is calculated based on that") is already fixed in r76079

Changed 7 months ago by awi

Patch implementing stretchable spacer for vertical toolbar.

comment:7 Changed 7 months ago by vadz

@awi: would it make the code simpler to always use this technique, i.e. replace the separator instead of changing its size, even with the horizontal toolbars? I don't like having two ways to do the same thing in the code, it makes it longer and more difficult to maintain. If this approach doesn't have any problems, I'd prefer to just always use it.

TIA!

comment:8 Changed 7 months ago by awi

Patch with simplified version attached.

Changed 7 months ago by awi

Patch implementing stretchable spacer for vertical toolbar (v2).

comment:9 Changed 7 months ago by VZ

  • Resolution set to fixed
  • Status changed from new to closed

(In [76092]) Make stretchable spacers work in vertical toolbars too in wxMSW.

Replace the old implementation of stretchable spacers based on changing the
size of the separators used as spacers as the toolbar size itself changed with
a new one, simply replacing the old separator with the new one of the correct
size, as it also works for the vertical toolbars, unlike the old approach.

Closes #13673.

Note: See TracTickets for help on using tickets.