mirror of
https://github.com/cookiengineer/audacity
synced 2025-11-01 14:43:48 +01:00
Patch from Ed Musgrove to allow narrower meter bar, plus also actions from code-review.
This commit is contained in:
@@ -259,13 +259,17 @@ void ToolBar::ReCreateButtons()
|
|||||||
Layout();
|
Layout();
|
||||||
|
|
||||||
// Recalculate the height to be a multiple of toolbarSingle
|
// Recalculate the height to be a multiple of toolbarSingle
|
||||||
#define tbs ( toolbarSingle + toolbarGap )
|
const int tbs = toolbarSingle + toolbarGap;
|
||||||
wxSize sz = GetSize();
|
wxSize sz = GetSize();
|
||||||
sz.y = ( ( ( sz.y + tbs ) / tbs ) * tbs ) - 1;
|
sz.y = ( ( ( sz.y + tbs ) / tbs ) * tbs ) - 1;
|
||||||
#undef tbs
|
|
||||||
|
|
||||||
// Set the true AND minimum sizes and do final layout
|
// Set the true AND minimum sizes and do final layout
|
||||||
SetInitialSize(sz);
|
SetInitialSize(sz);
|
||||||
|
if(IsResizable())
|
||||||
|
{// EM: allows narrow Meter Toolbar
|
||||||
|
sz.SetWidth(160);
|
||||||
|
SetMinSize(sz);
|
||||||
|
}
|
||||||
Layout();
|
Layout();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -585,6 +589,18 @@ void ToolBar::OnPaint( wxPaintEvent & event )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @return true iff pos is in resize grabber.
|
||||||
|
bool ToolBar::IsResizeGrabberHit( wxPoint & pos )
|
||||||
|
{
|
||||||
|
wxRect rect = GetRect();
|
||||||
|
|
||||||
|
// Adjust to size of resize grabber
|
||||||
|
rect.x = rect.width - RWIDTH;
|
||||||
|
rect.y = 0;
|
||||||
|
rect.width = RWIDTH;
|
||||||
|
return rect.Contains( pos );
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Handle toolbar resizing
|
// Handle toolbar resizing
|
||||||
//
|
//
|
||||||
@@ -603,19 +619,11 @@ void ToolBar::OnLeftDown( wxMouseEvent & event )
|
|||||||
if( IsResizable() )
|
if( IsResizable() )
|
||||||
{
|
{
|
||||||
wxPoint pos = event.GetPosition();
|
wxPoint pos = event.GetPosition();
|
||||||
wxRect rect = GetRect();
|
|
||||||
|
|
||||||
// Adjust to size of resize grabber
|
|
||||||
rect.x = rect.width - RWIDTH;
|
|
||||||
rect.y = 0;
|
|
||||||
rect.width = RWIDTH;
|
|
||||||
|
|
||||||
// Is left click within resize grabber?
|
// Is left click within resize grabber?
|
||||||
if( rect.Contains( pos ) )
|
if( IsResizeGrabberHit( pos ) )
|
||||||
{
|
{
|
||||||
// Retrieve the mouse position
|
// Retrieve the mouse position
|
||||||
mResizeStart = ClientToScreen( pos );
|
mResizeStart = ClientToScreen( pos );
|
||||||
|
|
||||||
// We want all of the mouse events
|
// We want all of the mouse events
|
||||||
CaptureMouse();
|
CaptureMouse();
|
||||||
}
|
}
|
||||||
@@ -647,29 +655,17 @@ void ToolBar::OnMotion( wxMouseEvent & event )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Retrieve the mouse position
|
// Retrieve the mouse position
|
||||||
wxPoint pos = ClientToScreen( event.GetPosition() );
|
wxPoint raw_pos = event.GetPosition();
|
||||||
|
wxPoint pos = ClientToScreen( raw_pos );
|
||||||
|
|
||||||
if( !HasCapture() )
|
if( !HasCapture() )
|
||||||
{
|
{
|
||||||
|
// JKC: Wrong place for this? Surely the cursor should change on
|
||||||
|
// mouse-down and capture-lost rather than with mouse movement?
|
||||||
if( IsResizable() )
|
if( IsResizable() )
|
||||||
{
|
{
|
||||||
wxPoint pos = event.GetPosition();
|
|
||||||
wxRect rect = GetRect();
|
|
||||||
|
|
||||||
// Adjust to size of resize grabber
|
|
||||||
rect.x = rect.width - RWIDTH;
|
|
||||||
rect.y = 0;
|
|
||||||
rect.width = RWIDTH;
|
|
||||||
|
|
||||||
// Is left click within resize grabber?
|
// Is left click within resize grabber?
|
||||||
if( rect.Contains( pos ) )
|
SetCursor( IsResizeGrabberHit( raw_pos ) ? wxCURSOR_SIZEWE : wxCURSOR_ARROW);
|
||||||
{
|
|
||||||
SetCursor( wxCURSOR_SIZEWE );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
SetCursor( wxCURSOR_ARROW );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if( event.Dragging() )
|
else if( event.Dragging() )
|
||||||
|
|||||||
@@ -159,7 +159,7 @@ class ToolBar:public wxPanel
|
|||||||
void OnCaptureLost(wxMouseCaptureLostEvent & event);
|
void OnCaptureLost(wxMouseCaptureLostEvent & event);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
bool IsResizeGrabberHit( wxPoint & pos );
|
||||||
void Init(wxWindow *parent, int type, const wxString & title, const wxString & label);
|
void Init(wxWindow *parent, int type, const wxString & title, const wxString & label);
|
||||||
|
|
||||||
wxWindow *mParent;
|
wxWindow *mParent;
|
||||||
|
|||||||
Reference in New Issue
Block a user