mirror of
				https://github.com/cookiengineer/audacity
				synced 2025-11-04 16:14:00 +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,10 +523,13 @@ 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(),
 | 
				
			||||||
@@ -519,12 +538,9 @@ void ToolDock::OnPaint( wxPaintEvent & WXUNUSED(event) )
 | 
				
			|||||||
                   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
 | 
					      // ...and for bars that aren't the last in a row, draw an
 | 
				
			||||||
      // horizontal gap line
 | 
					      // horizontal gap line
 | 
				
			||||||
         if( r.y == ( (ToolBar *)mConfiguration[ ndx + 1 ] )->GetRect().y )
 | 
					      if (!mConfiguration.IsRightmost(toolbar)) {
 | 
				
			||||||
         {
 | 
					 | 
				
			||||||
         AColor::Line(dc,
 | 
					         AColor::Line(dc,
 | 
				
			||||||
            r.GetRight() + 1,
 | 
					            r.GetRight() + 1,
 | 
				
			||||||
            r.GetTop(),
 | 
					            r.GetTop(),
 | 
				
			||||||
@@ -532,7 +548,6 @@ void ToolDock::OnPaint( wxPaintEvent & WXUNUSED(event) )
 | 
				
			|||||||
            r.GetBottom() + 1 );
 | 
					            r.GetBottom() + 1 );
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
   }
 | 
					   }
 | 
				
			||||||
   }
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void ToolDock::OnMouseEvents(wxMouseEvent &event)
 | 
					void ToolDock::OnMouseEvents(wxMouseEvent &event)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -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