Audacity 3.2.0
Public Member Functions | Private Attributes | List of all members
ToolFrame Class Referencefinal

class ToolFrame More...

#include <ToolManager.h>

Inheritance diagram for ToolFrame:
[legend]
Collaboration diagram for ToolFrame:
[legend]

Public Member Functions

 ToolFrame (AudacityProject *parent, ToolManager *manager, ToolBar *bar, wxPoint pos)
 
 ~ToolFrame ()
 
ToolBarGetBar ()
 
void ClearBar ()
 
void LockInMinSize (ToolBar *pBar)
 
void OnGrabber (GrabberEvent &event)
 
void OnToolBarUpdate (wxCommandEvent &event)
 
void OnPaint (wxPaintEvent &WXUNUSED(event))
 
void OnMotion (wxMouseEvent &event)
 
void OnCaptureLost (wxMouseCaptureLostEvent &WXUNUSED(event))
 
void OnClose (wxCloseEvent &event)
 
void OnKeyDown (wxKeyEvent &event)
 
void Resize (const wxSize &size)
 

Private Attributes

AudacityProject *const mParent
 
ToolManagermManager
 
ToolBarmBar
 
wxSize mMinSize
 
wxSize mOrigSize
 

Detailed Description

class ToolFrame

Definition at line 188 of file ToolManager.h.

Constructor & Destructor Documentation

◆ ToolFrame()

ToolFrame::ToolFrame ( AudacityProject parent,
ToolManager manager,
ToolBar bar,
wxPoint  pos 
)

Definition at line 72 of file ToolManager.cpp.

74 : wxFrame( FindProjectFrame( parent ),
75 bar->GetId(),
76 wxEmptyString,
77 pos,
78 wxDefaultSize,
79 wxNO_BORDER |
80 wxFRAME_NO_TASKBAR |
81#if !defined(__WXMAC__) // bug1358
82 wxFRAME_TOOL_WINDOW |
83#endif
84 wxFRAME_FLOAT_ON_PARENT )
85 , mParent{ parent }
86{
87 int width = bar->GetSize().x;
88 int border = 1;
89
90 // Save parameters
92 mBar = bar;
93
94 // Transfer the bar to the ferry
95 bar->Reparent(this);
96
97 // Bug 2120 (comment 6 residual): No need to set a minimum size
98 // if the toolbar is not resizable. On GTK, setting a minimum
99 // size will prevent the frame from shrinking if the toolbar gets
100 // reconfigured and needs to resize smaller.
101 if (bar->IsResizable())
102 {
103 SetMinSize(bar->GetDockedSize());
104 }
105
106 {
107 // We use a sizer to maintain proper spacing
108 auto s = std::make_unique<wxBoxSizer>(wxHORIZONTAL);
109
110 // Add the bar to the sizer
111 s->Add(bar, 1, wxEXPAND | wxALL, border);
112
113 // Add space for the resize grabber
114 if (bar->IsResizable())
115 {
116 s->Add(sizerW, 1);
117 width += sizerW;
118 }
119
120 SetSize(width + 2 * ToolBarFloatMargin,
121 bar->GetDockedSize().y + 2 * ToolBarFloatMargin);
122
123 // Attach the sizer and resize the window to fit
124 SetSizer(s.release());
125 }
126
127 Layout();
128
129 // Inform toolbar of change
130 bar->SetDocked( NULL, true );
131
132 // Make sure resizable floaters don't get any smaller than initial size
133 if( bar->IsResizable() )
134 {
135 // Calc the minimum size of the frame
136 mMinSize = bar->GetMinSize() + ( GetSize() - bar->GetSize() );
137 }
138}
wxFrame * FindProjectFrame(AudacityProject *project)
Get a pointer to the window associated with a project, or null if the given pointer is null,...
static const AttachedProjectObjects::RegisteredFactory manager
@ ToolBarFloatMargin
Definition: ToolBar.h:67
#define sizerW
Methods for ToolFrame.
Definition: ToolManager.cpp:67
virtual void SetDocked(ToolDock *dock, bool pushed)
Definition: ToolBar.cpp:661
bool IsResizable() const
Definition: ToolBar.cpp:425
virtual wxSize GetDockedSize()
Definition: ToolBar.h:146
ToolBar * mBar
Definition: ToolManager.h:233
wxSize mMinSize
Definition: ToolManager.h:234
ToolManager * mManager
Definition: ToolManager.h:232
AudacityProject *const mParent
Definition: ToolManager.h:231

References ToolBar::GetDockedSize(), ToolBar::IsResizable(), manager, mBar, mManager, mMinSize, ToolBar::SetDocked(), sizerW, and ToolBarFloatMargin.

Here is the call graph for this function:

◆ ~ToolFrame()

ToolFrame::~ToolFrame ( )

Definition at line 140 of file ToolManager.cpp.

141{
142 if(HasCapture())
143 ReleaseMouse();
144}

Member Function Documentation

◆ ClearBar()

void ToolFrame::ClearBar ( )
inline

Definition at line 197 of file ToolManager.h.

197{ mBar = nullptr; }

References mBar.

Referenced by ToolManager::HandleEscapeKey(), and ToolManager::OnMouse().

Here is the caller graph for this function:

◆ GetBar()

ToolBar * ToolFrame::GetBar ( )
inline

Definition at line 196 of file ToolManager.h.

196{ return mBar; }

References mBar.

◆ LockInMinSize()

void ToolFrame::LockInMinSize ( ToolBar pBar)

Definition at line 154 of file ToolManager.cpp.

155{
156 mBar = pBar;
157
158 wxSize sz = mBar->GetSize();
159 SetClientSize( sz );
160 int yDesiredMin = 26;
161 int y = sz.GetHeight();
162 if (y > yDesiredMin) {
163 sz.SetWidth((sz.GetWidth() * yDesiredMin) / y);
164 sz.SetHeight( yDesiredMin );
165 }
166 mMinSize = sz -wxSize( 10, 0);
167}

References mBar, and mMinSize.

◆ OnCaptureLost()

void ToolFrame::OnCaptureLost ( wxMouseCaptureLostEvent &  WXUNUSEDevent)

Definition at line 281 of file ToolManager.cpp.

282{
283 if( HasCapture() )
284 {
285 ReleaseMouse();
286 }
287}

◆ OnClose()

void ToolFrame::OnClose ( wxCloseEvent &  event)

Definition at line 289 of file ToolManager.cpp.

290{
291 event.Veto();
292}

◆ OnGrabber()

void ToolFrame::OnGrabber ( GrabberEvent event)

Definition at line 146 of file ToolManager.cpp.

147{
148 // Pass it on to the manager since it isn't in the handling hierarchy
149 mManager->ProcessEvent( event );
150}

References mManager.

◆ OnKeyDown()

void ToolFrame::OnKeyDown ( wxKeyEvent &  event)

Definition at line 294 of file ToolManager.cpp.

295{
296 event.Skip();
297 if( HasCapture() && event.GetKeyCode() == WXK_ESCAPE ) {
298 Resize( mOrigSize );
299 ReleaseMouse();
300 }
301}
wxSize mOrigSize
Definition: ToolManager.h:235
void Resize(const wxSize &size)

References mOrigSize, and Resize().

Here is the call graph for this function:

◆ OnMotion()

void ToolFrame::OnMotion ( wxMouseEvent &  event)

Definition at line 207 of file ToolManager.cpp.

208{
209 // Don't do anything if we're docked or not resizeable
210 if( !mBar || mBar->IsDocked() || !mBar->IsResizable() )
211 {
212 return;
213 }
214
215 // Retrieve the mouse position
216 wxPoint pos = ClientToScreen( event.GetPosition() );
217 if( HasCapture() && event.Dragging() )
218 {
219 wxRect rect = GetRect();
220
221 rect.SetBottomRight( pos );
222
223 // Keep it within max size, if specified
224 wxSize maxsz = mBar->GetMaxSize();
225 if (maxsz != wxDefaultSize)
226 {
227 if (maxsz.x != wxDefaultCoord && rect.width > maxsz.x)
228 {
229 rect.width = maxsz.x;
230 }
231 if (maxsz.y != wxDefaultCoord && rect.height > maxsz.y)
232 {
233 rect.height = maxsz.y;
234 }
235 }
236
237 if( rect.width < mMinSize.x )
238 {
239 rect.width = mMinSize.x;
240 }
241
242 if( rect.height < mMinSize.y )
243 {
244 rect.height = mMinSize.y;
245 }
246
247 Resize( rect.GetSize() );
248 }
249 else if( HasCapture() && event.LeftUp() )
250 {
251 ReleaseMouse();
252 }
253 else if( !HasCapture() )
254 {
255 wxRect rect = GetRect();
256 wxRect r;
257
258 r.x = rect.GetRight() - sizerW - 2,
259 r.y = rect.GetBottom() - sizerW - 2;
260 r.width = sizerW + 2;
261 r.height = sizerW + 2;
262
263 // Is left click within resize grabber?
264 if( r.Contains( pos ) && !event.Leaving() )
265 {
266 mOrigSize = GetSize();
267
268 SetCursor( wxCURSOR_SIZENWSE );
269 if( event.LeftDown() )
270 {
271 CaptureMouse();
272 }
273 }
274 else
275 {
276 SetCursor( wxCURSOR_ARROW );
277 }
278 }
279}
bool IsDocked() const
Definition: ToolBar.cpp:433

References ToolBar::IsDocked(), ToolBar::IsResizable(), mBar, mMinSize, mOrigSize, Resize(), and sizerW.

Here is the call graph for this function:

◆ OnPaint()

void ToolFrame::OnPaint ( wxPaintEvent &  WXUNUSEDevent)

Definition at line 180 of file ToolManager.cpp.

181{
182 wxPaintDC dc( this );
183 wxSize sz = GetSize();
184 wxRect r;
185
186 dc.SetPen( theTheme.Colour( clrTrackPanelText ) );
187 dc.SetBackground( wxBrush( theTheme.Colour( clrMedium ) ) );
188 dc.Clear();
189 dc.SetBrush( *wxTRANSPARENT_BRUSH );
190 dc.DrawRectangle( 0, 0, sz.GetWidth(), sz.GetHeight() );
191
192 if( mBar && mBar->IsResizable() )
193 {
194 r.x = sz.x - sizerW - 2,
195 r.y = sz.y - sizerW - 2;
196 r.width = sizerW + 2;
197 r.height = sizerW + 2;
198
199 AColor::Line(dc, r.GetLeft(), r.GetBottom(), r.GetRight(), r.GetTop() );
200 AColor::Line(dc, r.GetLeft() + 3, r.GetBottom(), r.GetRight(), r.GetTop() + 3 );
201 AColor::Line(dc, r.GetLeft() + 6, r.GetBottom(), r.GetRight(), r.GetTop() + 6 );
202 AColor::Line(dc, r.GetLeft() + 9, r.GetBottom(), r.GetRight(), r.GetTop() + 9 );
203 }
204
205}
THEME_API Theme theTheme
Definition: Theme.cpp:82
static void Line(wxDC &dc, wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)
Definition: AColor.cpp:187
wxColour & Colour(int iIndex)

References ThemeBase::Colour(), ToolBar::IsResizable(), AColor::Line(), mBar, sizerW, and theTheme.

Here is the call graph for this function:

◆ OnToolBarUpdate()

void ToolFrame::OnToolBarUpdate ( wxCommandEvent &  event)

Definition at line 169 of file ToolManager.cpp.

170{
171 // Resize floater window to exactly contain toolbar
172 // use actual size rather than minimum size.
173 if (mBar)
174 mBar->GetParent()->SetClientSize( mBar->GetSize() );// ->GetMinSize() );
175
176 // Allow it to propagate to our parent
177 event.Skip();
178}

References mBar.

◆ Resize()

void ToolFrame::Resize ( const wxSize &  size)

Definition at line 303 of file ToolManager.cpp.

304{
305 SetMinSize( size );
306 SetSize( size );
307 Layout();
308 Refresh( false );
309}

References size.

Referenced by OnKeyDown(), and OnMotion().

Here is the caller graph for this function:

Member Data Documentation

◆ mBar

ToolBar* ToolFrame::mBar
private

◆ mManager

ToolManager* ToolFrame::mManager
private

Definition at line 232 of file ToolManager.h.

Referenced by OnGrabber(), and ToolFrame().

◆ mMinSize

wxSize ToolFrame::mMinSize
private

Definition at line 234 of file ToolManager.h.

Referenced by LockInMinSize(), OnMotion(), and ToolFrame().

◆ mOrigSize

wxSize ToolFrame::mOrigSize
private

Definition at line 235 of file ToolManager.h.

Referenced by OnKeyDown(), and OnMotion().

◆ mParent

AudacityProject* const ToolFrame::mParent
private

Definition at line 231 of file ToolManager.h.


The documentation for this class was generated from the following files: