mirror of
https://github.com/cookiengineer/audacity
synced 2025-11-02 23:23:53 +01:00
ToolDock::OnPaint assumes less about configuration details
This commit is contained in:
@@ -82,6 +82,22 @@ void ToolBarConfiguration::Hide(ToolBar *bar)
|
|||||||
Remove(bar);
|
Remove(bar);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ToolBarConfiguration::IsRightmost(const ToolBar *bar) const
|
||||||
|
{
|
||||||
|
auto iter = FindPlace(bar);
|
||||||
|
auto endit = end();
|
||||||
|
if (iter == endit)
|
||||||
|
// not present
|
||||||
|
return true;
|
||||||
|
if (++iter == endit)
|
||||||
|
// Last of all
|
||||||
|
return true;
|
||||||
|
if (bar->GetRect().y != iter->pBar->GetRect().y)
|
||||||
|
// Last in its row
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
IMPLEMENT_CLASS( ToolDock, wxPanel );
|
IMPLEMENT_CLASS( ToolDock, wxPanel );
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
@@ -507,30 +523,29 @@ void ToolDock::OnPaint( wxPaintEvent & WXUNUSED(event) )
|
|||||||
AColor::Line(dc, 0, 0, 0, sz.GetHeight() );
|
AColor::Line(dc, 0, 0, 0, sz.GetHeight() );
|
||||||
|
|
||||||
// Draw the gap between each bar
|
// Draw the gap between each bar
|
||||||
int ndx, cnt = mConfiguration.GetCount();
|
for (const auto &place : GetConfiguration())
|
||||||
for( ndx = 0; ndx < cnt; ndx++ )
|
|
||||||
{
|
{
|
||||||
wxRect r = ( (ToolBar *)mConfiguration[ ndx ] )->GetRect();
|
auto toolbar = place.pBar;
|
||||||
|
if (!toolbar)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
wxRect r = toolbar->GetRect();
|
||||||
|
|
||||||
AColor::Line( dc,
|
AColor::Line( dc,
|
||||||
r.GetLeft(),
|
r.GetLeft(),
|
||||||
r.GetBottom() + 1,
|
r.GetBottom() + 1,
|
||||||
sz.GetWidth(),
|
sz.GetWidth(),
|
||||||
r.GetBottom() + 1 );
|
r.GetBottom() + 1 );
|
||||||
|
|
||||||
// For all bars but the last...
|
// For all bars but the last...
|
||||||
if( ndx < cnt - 1 )
|
// ...and for bars that aren't the last in a row, draw an
|
||||||
{
|
// horizontal gap line
|
||||||
// ...and for bars that aren't the last in a row, draw an
|
if (!mConfiguration.IsRightmost(toolbar)) {
|
||||||
// horizontal gap line
|
AColor::Line(dc,
|
||||||
if( r.y == ( (ToolBar *)mConfiguration[ ndx + 1 ] )->GetRect().y )
|
r.GetRight() + 1,
|
||||||
{
|
r.GetTop(),
|
||||||
AColor::Line(dc,
|
r.GetRight() + 1,
|
||||||
r.GetRight() + 1,
|
r.GetBottom() + 1 );
|
||||||
r.GetTop(),
|
|
||||||
r.GetRight() + 1,
|
|
||||||
r.GetBottom() + 1 );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -129,6 +129,7 @@ public:
|
|||||||
void Show(ToolBar *bar);
|
void Show(ToolBar *bar);
|
||||||
void Hide(ToolBar *bar);
|
void Hide(ToolBar *bar);
|
||||||
|
|
||||||
|
bool IsRightmost(const ToolBar *bar) const;
|
||||||
private:
|
private:
|
||||||
Iterator FindPlace(const ToolBar *bar) const;
|
Iterator FindPlace(const ToolBar *bar) const;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user