Add page highlighting to wxRibbonBar.
Allow visually highlighting a page to make it more noticeable to the user. Closes #14527. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72347 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -536,6 +536,7 @@ All (GUI):
|
||||
|
||||
- Respect window max size in wxBoxSizer (Nathan Ridge).
|
||||
- Add possibility to hide and show again wxRibbonBar pages (wxBen).
|
||||
- Add wxRibbonBar pages highlighting (wxBen).
|
||||
- Add expand/collapse button to wxRibbonBar (rakeshthp).
|
||||
- Fix item data access in wxDataViewListCtrl (Kry).
|
||||
- Fix problem with floating maximized AUI panes (Laurent Poujoulat).
|
||||
|
@@ -82,6 +82,7 @@ public:
|
||||
int minimum_width;
|
||||
bool active;
|
||||
bool hovered;
|
||||
bool highlight;
|
||||
bool shown;
|
||||
};
|
||||
|
||||
@@ -127,6 +128,10 @@ public:
|
||||
void ShowPage(size_t page, bool show = true);
|
||||
void HidePage(size_t page) { ShowPage(page, false); }
|
||||
|
||||
bool IsPageHighlighted(size_t page) const;
|
||||
void AddPageHighlight(size_t page, bool highlight = true);
|
||||
void RemovePageHighlight(size_t page) { AddPageHighlight(page, false); }
|
||||
|
||||
void ShowPanels(bool show = true);
|
||||
void HidePanels() { ShowPanels(false); }
|
||||
bool ArePanelsShown() const { return m_arePanelsShown; }
|
||||
|
@@ -284,6 +284,35 @@ public:
|
||||
*/
|
||||
void HidePage(size_t page);
|
||||
|
||||
/**
|
||||
Indicates whether a tab is currently highlighted.
|
||||
|
||||
@see AddPageHighlight()
|
||||
|
||||
@since 2.9.5
|
||||
*/
|
||||
bool IsPageHighlighted(size_t page) const;
|
||||
|
||||
/**
|
||||
Highlight the specified tab.
|
||||
|
||||
Highlighted tabs have a colour between that of the active tab
|
||||
and a tab over which the mouse is hovering. This can be used
|
||||
to make a tab (usually temporarily) more noticeable to the user.
|
||||
|
||||
@since 2.9.5
|
||||
*/
|
||||
void AddPageHighlight(size_t page, bool highlight = true);
|
||||
|
||||
/**
|
||||
Changes a tab to not be highlighted.
|
||||
|
||||
@see AddPageHighlight()
|
||||
|
||||
@since 2.9.5
|
||||
*/
|
||||
void RemovePageHighlight(size_t page);
|
||||
|
||||
/**
|
||||
Shows or hides the panel area of the ribbon bar.
|
||||
|
||||
|
@@ -401,6 +401,8 @@ MyFrame::MyFrame()
|
||||
bar->AddButton(ID_HIDE_PAGES, wxT("Hide Pages"), ribbon_xpm);
|
||||
bar->AddButton(ID_SHOW_PAGES, wxT("Show Pages"), ribbon_xpm);
|
||||
}
|
||||
new wxRibbonPage(m_ribbon, wxID_ANY, wxT("Highlight Page"), empty_xpm);
|
||||
m_ribbon->AddPageHighlight(m_ribbon->GetPageCount()-1);
|
||||
|
||||
m_ribbon->Realize();
|
||||
|
||||
|
@@ -326,7 +326,7 @@ void wxRibbonAUIArtProvider::DrawTab(wxDC& dc,
|
||||
|
||||
dc.SetFont(m_tab_label_font);
|
||||
dc.SetPen(*wxTRANSPARENT_PEN);
|
||||
if(tab.active || tab.hovered)
|
||||
if(tab.active || tab.hovered || tab.highlight)
|
||||
{
|
||||
if(tab.active)
|
||||
{
|
||||
@@ -343,8 +343,24 @@ void wxRibbonAUIArtProvider::DrawTab(wxDC& dc,
|
||||
dc.SetBrush(m_tab_active_top_background_brush);
|
||||
dc.DrawRectangle(tab.rect.x, tab.rect.y + 3, tab.rect.width - 1,
|
||||
grad_rect.y - tab.rect.y - 3);
|
||||
dc.GradientFillLinear(grad_rect, m_tab_active_background_colour,
|
||||
m_tab_active_background_gradient_colour, wxSOUTH);
|
||||
if(tab.highlight)
|
||||
{
|
||||
wxColour top_colour((m_tab_active_background_colour.Red() + m_tab_hover_background_top_colour.Red())/2,
|
||||
(m_tab_active_background_colour.Green() + m_tab_hover_background_top_colour.Green())/2,
|
||||
(m_tab_active_background_colour.Blue() + m_tab_hover_background_top_colour.Blue())/2);
|
||||
|
||||
wxColour bottom_colour((m_tab_active_background_gradient_colour.Red() + m_tab_hover_background_top_gradient_colour.Red())/2,
|
||||
(m_tab_active_background_gradient_colour.Green() + m_tab_hover_background_top_gradient_colour.Green())/2,
|
||||
(m_tab_active_background_gradient_colour.Blue() + m_tab_hover_background_top_gradient_colour.Blue())/2);
|
||||
|
||||
dc.GradientFillLinear(grad_rect, top_colour,
|
||||
bottom_colour, wxSOUTH);
|
||||
}
|
||||
else
|
||||
{
|
||||
dc.GradientFillLinear(grad_rect, m_tab_active_background_colour,
|
||||
m_tab_active_background_gradient_colour, wxSOUTH);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@@ -1063,7 +1063,7 @@ void wxRibbonMSWArtProvider::DrawTab(
|
||||
if(tab.rect.height <= 2)
|
||||
return;
|
||||
|
||||
if(tab.active || tab.hovered)
|
||||
if(tab.active || tab.hovered || tab.highlight)
|
||||
{
|
||||
if(tab.active)
|
||||
{
|
||||
@@ -1098,6 +1098,41 @@ void wxRibbonMSWArtProvider::DrawTab(
|
||||
dc.GradientFillLinear(background, m_tab_hover_background_colour,
|
||||
m_tab_hover_background_gradient_colour, wxSOUTH);
|
||||
}
|
||||
else if(tab.highlight)
|
||||
{
|
||||
wxRect background(tab.rect);
|
||||
|
||||
background.x += 2;
|
||||
background.y += 2;
|
||||
background.width -= 4;
|
||||
background.height -= 3;
|
||||
int h = background.height;
|
||||
background.height /= 2;
|
||||
|
||||
//For highlight pages we show a colour between the active page and for a hovered page:
|
||||
wxColour top_colour1((m_tab_active_background_colour.Red() + m_tab_hover_background_top_colour.Red())/2,
|
||||
(m_tab_active_background_colour.Green() + m_tab_hover_background_top_colour.Green())/2,
|
||||
(m_tab_active_background_colour.Blue() + m_tab_hover_background_top_colour.Blue())/2);
|
||||
|
||||
wxColour bottom_colour1((m_tab_active_background_gradient_colour.Red() + m_tab_hover_background_top_gradient_colour.Red())/2,
|
||||
(m_tab_active_background_gradient_colour.Green() + m_tab_hover_background_top_gradient_colour.Green())/2,
|
||||
(m_tab_active_background_gradient_colour.Blue() + m_tab_hover_background_top_gradient_colour.Blue())/2);
|
||||
|
||||
dc.GradientFillLinear(background, top_colour1, bottom_colour1, wxSOUTH);
|
||||
|
||||
background.y += background.height;
|
||||
background.height = h - background.height;
|
||||
|
||||
wxColour top_colour2((m_tab_active_background_colour.Red() + m_tab_hover_background_colour.Red())/2,
|
||||
(m_tab_active_background_colour.Green() + m_tab_hover_background_colour.Green())/2,
|
||||
(m_tab_active_background_colour.Blue() + m_tab_hover_background_colour.Blue())/2);
|
||||
|
||||
wxColour bottom_colour2((m_tab_active_background_gradient_colour.Red() + m_tab_hover_background_gradient_colour.Red())/2,
|
||||
(m_tab_active_background_gradient_colour.Green() + m_tab_hover_background_gradient_colour.Green())/2,
|
||||
(m_tab_active_background_gradient_colour.Blue() + m_tab_hover_background_gradient_colour.Blue())/2);
|
||||
|
||||
dc.GradientFillLinear(background, top_colour2, bottom_colour2, wxSOUTH);
|
||||
}
|
||||
|
||||
wxPoint border_points[6];
|
||||
border_points[0] = wxPoint(1, tab.rect.height - 2);
|
||||
|
@@ -67,6 +67,7 @@ void wxRibbonBar::AddPage(wxRibbonPage *page)
|
||||
info.page = page;
|
||||
info.active = false;
|
||||
info.hovered = false;
|
||||
info.highlight = false;
|
||||
info.shown = true;
|
||||
// info.rect not set (intentional)
|
||||
|
||||
@@ -306,6 +307,20 @@ void wxRibbonBar::ShowPage(size_t page, bool show)
|
||||
m_pages.Item(page).shown = show;
|
||||
}
|
||||
|
||||
bool wxRibbonBar::IsPageHighlighted(size_t page) const
|
||||
{
|
||||
if (page >= m_pages.GetCount())
|
||||
return false;
|
||||
return m_pages.Item(page).highlight;
|
||||
}
|
||||
|
||||
void wxRibbonBar::AddPageHighlight(size_t page, bool highlight)
|
||||
{
|
||||
if(page >= m_pages.GetCount())
|
||||
return;
|
||||
m_pages.Item(page).highlight = highlight;
|
||||
}
|
||||
|
||||
void wxRibbonBar::DeletePage(size_t n)
|
||||
{
|
||||
if(n < m_pages.GetCount())
|
||||
|
Reference in New Issue
Block a user