Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#14471 closed enhancement (fixed)

Add a possibility to show/hide tabs to wxRibbonBar

Reported by: wxBen Owned by:
Priority: normal Milestone:
Component: GUI-all Version: stable-latest
Keywords: ribbon bar page show hide tabs Cc:
Blocked By: Blocking:
Patch: yes

Description

Please see the discussion on this page for optional background information:

http://forums.wxwidgets.org/viewtopic.php?f=1&t=27598

The modified files are shown below. Existing applications and functionality is not affected.
Changes have been tested in my own application.

wxWidgets\include\wx\ribbon\bar.h
wxWidgets\src\ribbon\bar.cpp

The following methods were added:

Return the zero based page number for a given wxRibbonPage or wxNOT_FOUND if not found.
The page number return can be used in other ribbon bar calls.
int GetPageNumber(wxRibbonPage* page);

Indicates whether the tab for the given zero based page is show or not.
bool GetShowTab(size_t page);

Show or hide the tab for a given page. After showing or hiding a tab, you need to call wxRibbonBar::Realize().
If you hide the tab for the currently active page (GetActivePage) then you should call SetActivePage to activate a different page.

void SetShowTab(size_t page, bool show_tab);

Attachments (2)

wxBenRBShowTab.patch download (8.4 KB) - added by wxBen 8 years ago.
wxBenRBShowTab.patch
wxBenShowTab2.patch download (10.7 KB) - added by wxBen 8 years ago.
wxBenRBShowTab2.patch - Replaces the first patch. Use only this one.

Download all attachments as: .zip

Change History (10)

Changed 8 years ago by wxBen

wxBenRBShowTab.patch

comment:1 Changed 8 years ago by vadz

  • Milestone future deleted
  • Status changed from new to confirmed
  • Summary changed from Patch for new ribbon bar functionality - Please review and submit to trunk branch to Add a possibility to show/hide tabs to wxRibbonBar

Looks nice, thanks, I just wonder if it's not going to conflict with #14464 once I apply the patch there.

Just a few minor comments:

  1. I'm not sure why were the names Get/SetShowTab() chosen for the new functions, looking at the existing ones -- and wx API in general -- I think it would make more sense to call them ShowTab() and IsTabShown() (and maybe HideTab() as a thin wrapper for ShowTab(false)). Wouldn't it?
  2. Something strange has happened with "@since 2.9.4" (which should be ".5" from today, if you update the patch) as it got removed from one existing function and only added to one of the 3 new ones.
  3. It would be great to have a "demo" of the new feature in the sample as personally I'm not sure what exactly does it do even after reading the docs. Seeing it in the sample would probably explain everything.

Thanks!

comment:2 Changed 8 years ago by wxBen

I just looked at patch #14464 and it lets you add or remove pages or insert them back. That is another way of accomplishing a similar goal. But it is convenient to be able to set everything up and then just hide or show tabs for particular pages.

  1. Renaming the functions to ShowTab, IsTabShown, and adding a HideTab is fine.
  2. I saw that documentaiton diff glitch as well.
  3. Shall I update the ribbon bar sample?

How shall we proceed? I think my proposed functionality is useful and wont hurt or impact any existing applications.

How about you submit the patch $14464 you proposed, and I can then update/rename/add sample and update the patch file attached?

comment:3 Changed 8 years ago by wxBen

Inserting and removing pages means keeping track of them, which is nice, but in some cases it is convenient to just temporarily hide the tab for page.

comment:4 Changed 8 years ago by vadz

I did want to wait for #14464 being resolved first but it looks like it's going to take longer than I thought so I'd indeed like to try you to update the patch renaming the functions and adding an example of using new functionality to the sample and I'll try to apply it when I can.

TIA!

comment:5 Changed 8 years ago by wxBen

I have renamed the methods as suggested, fixed the documentation dif glitch, and added some sample code to the ribbon bar demo. Please accept this patch. The new files are in the second patch, which replaces the first one.

Changed 8 years ago by wxBen

wxBenRBShowTab2.patch - Replaces the first patch. Use only this one.

comment:6 follow-up: Changed 8 years ago by vadz

I'm going to apply this but I've finally decided to rename the methods again as looking at the existing API more carefully, I see that "tabs" and "pages" are actually the same and all the existing functions have "Page" in their name and not "Tab" so IMHO it makes sense to call these ones ShowPage(), HidePage() and IsPageShown(). Sorry for not realizing it sooner resulting in useless work for you. And thanks a lot for the update to the sample, this makes it immediately clear how does this feature work!

comment:7 Changed 8 years ago by VZ

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

(In [72070]) Add possibility to hide and show again wxRibbonBar pages.

Added wxRibbonBar::ShowPage(), HidePage() and IsPageShown() methods and show
them in the sample.

Also add GetPageNumber() helper.

Closes #14471.

comment:8 in reply to: ↑ 6 Changed 8 years ago by wxBen

Replying to vadz:

I'm going to apply this but I've finally decided to rename the methods again as looking at the existing API more carefully, I see that "tabs" and "pages" are actually the same and all the existing functions have "Page" in their name and not "Tab" so IMHO it makes sense to call these ones ShowPage(), HidePage() and IsPageShown(). Sorry for not realizing it sooner resulting in useless work for you. And thanks a lot for the update to the sample, this makes it immediately clear how does this feature work!

That is awesome, thank you Vadz. Renaming the methods is fine.

Note: See TracTickets for help on using tickets.