Hybrid button on ribbon bar always getting cut off Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
wxBen
Experienced Solver
Experienced Solver
Posts: 64
Joined: Wed Jun 06, 2012 4:44 pm
Location: Calgary, Canada

Hybrid button on ribbon bar always getting cut off

Post by wxBen »

Our application uses the wxWidgst ribbon bar, wxWidets 3.0.2.7.
Some clients, and we have never seen this ourselves, experience a problem that button bar buttons of the type wxRIBBON_BUTTON_HYBRID get cut off, as shown by the attached screen. The top button should read "Re-solve" and then have a drop down on the right with some options.
I cannot debug or test this, since it appears fine on all of our machines.

Our code is pretty much just adding buttons to the button bar and not setting any sizes or sizers and relying on the auto layout.

The machines have size monitors, no bars or anything involved. At this point we have limited information as to what machines or setting or OS is involved.

I am hoping someone here might read this and go "Ah yes, we fixed that 3.0.4, or you just have to set this extra option on the button or some such..."
Attachments
Screen shot
Screen shot
Cut.png (126.91 KiB) Viewed 1765 times
User avatar
doublemax
Moderator
Moderator
Posts: 19114
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Hybrid button on ribbon bar always getting cut off

Post by doublemax »

I can't give you a "oh, yeah, that was fixed in...", but based on the screenshot, it could be a High-DPI problem. Is your program marked as "DPI aware"? If yes, try setting the font-scaling on your system to 150 or even 200% and check if you then see the issue.
Use the source, Luke!
wxBen
Experienced Solver
Experienced Solver
Posts: 64
Joined: Wed Jun 06, 2012 4:44 pm
Location: Calgary, Canada

Re: Hybrid button on ribbon bar always getting cut off

Post by wxBen »

We have been able to reproduce it locally, so I can debug it.
Our application is an enormous application, which uses some wxWidget UI components. It is not DPI aware, I am barely DPI aware.
But thanks, doublemax, I shall investigate.
Since I shall have to fix this, I shall debug this and post here when I get to the bottom of it.
May just upgrade to the latest minor release first and see if that fixes it.
wxBen
Experienced Solver
Experienced Solver
Posts: 64
Joined: Wed Jun 06, 2012 4:44 pm
Location: Calgary, Canada

Re: Hybrid button on ribbon bar always getting cut off

Post by wxBen »

I have been debugging it and here is what I found. In src\ribbon\buttonbar.cpp, note that method AddButton calls InsertButton which does this:

Code: Select all

   m_layouts_valid = false;
Good good. But in panel.cpp method wxRibbonPanel::Realize note how m_smallest_unminimised_size gets set via a call to m_art:

Code: Select all

        minimum_children_size = GetPanelSizerMinSize();

but a few lines above that line it calls:

Code: Select all

        GetPanelSizerMinSize

which uses m_smallest_unminimised_size if it is already set... So once the minimum size gets set, you are essentially stuck with it.

This means if you realize your ribbon bar and then insert more buttons, that it will use the old minimum size even if you call Realize.

I guess the documentation says to call Realize "After all pages have been created, and all controls and panels placed on those pages, Realize() must be called." But I assume that means don't call it after every single change, only when you are done making a group of changes. And there are methods to add and remove buttons, so I assume it does support some changes as you go. So based on that, I would say this is a bug.

And in our code we add the second button later one, which works fine, except it is still stuck with the original minimum size, and hence gets cut off.

A possible code fix is this (I tested it and it works), in panel.cpp wxRibbonPanel::Realize() add this:

Code: Select all

    wxSize minimum_children_size(0, 0);

    //--------------
    //ONLY THIS IS NEW
    //Reset this, otherwise GetPanelSizerMinSize will use the old value before it gets set further below.
    m_smallest_unminimised_size = wxDefaultSize;
    //--------------

    // Ask sizer if there is one present
    if(GetSizer())
A work around is to initially add all possible buttons, call Realize, and after that you can go nuts and add or remove buttons, and the panels wont be too small. But then some of the panels are a little too big, but extra space is better than buttons getting cut off...

Thoughts, doublemax? You usually have some good sound advise.
Last edited by wxBen on Fri Sep 21, 2018 8:21 pm, edited 2 times in total.
User avatar
doublemax
Moderator
Moderator
Posts: 19114
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Hybrid button on ribbon bar always getting cut off

Post by doublemax »

I didn't check the whole code myself, but what you're saying sounds plausible.

Please open a ticket at http://trac.wxwidgets.org
Use the source, Luke!
wxBen
Experienced Solver
Experienced Solver
Posts: 64
Joined: Wed Jun 06, 2012 4:44 pm
Location: Calgary, Canada

Re: Hybrid button on ribbon bar always getting cut off

Post by wxBen »

Post Reply