Audacity  2.2.2
Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | Friends | List of all members
ExpandingToolBar Class Referencefinal

A smart ToolBar class that has a "MainPanel" which is always displayed, and an "ExtraPanel" that can be hidden to save space. More...

#include <ExpandingToolBar.h>

Inheritance diagram for ExpandingToolBar:
wxPanelWrapper wxTabTraversalWrapper< wxPanel >

Public Member Functions

 ExpandingToolBar (wxWindow *parent, wxWindowID id, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize)
 
virtual ~ExpandingToolBar ()
 
wxPanel * GetMainPanel ()
 
wxPanel * GetExtraPanel ()
 
void SetAutoExpand (bool enabled)
 
bool GetAutoExpand ()
 
void Expand ()
 
void Collapse (bool now=false)
 
bool IsExpanded ()
 
void OnSize (wxSizeEvent &evt)
 
void OnToggle (wxCommandEvent &evt)
 
void OnTimer (wxTimerEvent &evt)
 
void StartMoving ()
 
void UpdateMoving ()
 
void FinishMoving ()
 
bool Layout () override
 
void Fit () override
 
- Public Member Functions inherited from wxPanelWrapper
 wxPanelWrapper ()
 
 wxPanelWrapper (wxWindow *parent, wxWindowID winid=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL|wxNO_BORDER, const wxString &name=_("Panel"))
 
bool Create (wxWindow *parent, wxWindowID winid=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL|wxNO_BORDER, const wxString &name=_("Panel"))
 
- Public Member Functions inherited from wxTabTraversalWrapper< wxPanel >
 wxTabTraversalWrapper (Args &&...args)
 

Protected Member Functions

void RecursivelyPushEventHandlers (wxWindow *win)
 
bool IsCursorInWindow ()
 
void ReparentExtraPanel ()
 
void MoveDrawer (wxSize prevSize)
 
wxBitmap GetToolbarBitmap ()
 
void TryAutoExpand ()
 
void TryAutoCollapse ()
 

Protected Attributes

wxPanel * mMainPanel
 
wxPanel * mExtraPanel
 
ToolBarGrabbermGrabber
 
AButtonmToggleButton
 
bool mIsAutoExpanded
 
bool mIsManualExpanded
 
bool mIsExpanded
 
bool mAutoExpand
 
bool mFirstTime
 
wxSize mMainSize
 
wxSize mExtraSize
 
wxSize mButtonSize
 
wxSize mGrabberSize
 
wxSize mCurrentDrawerSize
 
wxSize mTargetDrawerSize
 
wxSize mCurrentTotalSize
 
WindowHash mWindowHash
 
wxTimer mTimer
 
ToolBarFramemFrameParent
 
ToolBarDialogmDialogParent
 
ToolBarAreamAreaParent
 
std::unique_ptr
< ToolBarArrangement
mSavedArrangement
 
ImageRollPanelmTargetPanel
 
std::unique_ptr< wxDragImage > mDragImage
 
wxWindow * mTopLevelParent
 
std::vector< wxRect > mDropTargets
 
wxRect mDropTarget
 
std::vector< std::unique_ptr
< ExpandingToolBarEvtHandler > > 
mHandlers
 

Static Protected Attributes

static int msNoAutoExpandStack = 0
 

Friends

class ExpandingToolBarEvtHandler
 

Detailed Description

A smart ToolBar class that has a "MainPanel" which is always displayed, and an "ExtraPanel" that can be hidden to save space.

Can be docked into a ToolBarArea or floated in an ToolBarFrame;

If auto-expanding is off, behavior is very simple: clicking the toggle button expands, clicking it again collapses.

If auto-expanding is on, behavior is a little more complicated. When the mouse movers over a toolbar and it is collapsed, it gets auto-expanded, and it gets auto-collapsed as soon as the mouse leaves. However, if they manually toggle it collapsed while it was auto-expanded, it will stay collapsed until you move the mouse completely away and then back again later. If you manually expand it, it will stay manually expanded until you manually collapse it.

Definition at line 50 of file ExpandingToolBar.h.

Constructor & Destructor Documentation

ExpandingToolBar::ExpandingToolBar ( wxWindow *  parent,
wxWindowID  id,
const wxPoint &  pos = wxDefaultPosition,
const wxSize &  size = wxDefaultSize 
)
Todo:
check whether this is a memory leak (and check similar code)

Definition at line 118 of file ExpandingToolBar.cpp.

121  :
122  wxPanelWrapper(parent, id, pos, size),
123  mIsAutoExpanded(false),
124  mIsManualExpanded(false),
125  mIsExpanded(false),
126  mAutoExpand(true),
127  mFirstTime(true),
128  mFrameParent(NULL),
129  mDialogParent(NULL),
130  mAreaParent(NULL),
132  mTopLevelParent(NULL)
133 {
134  mMainPanel = safenew wxPanelWrapper(this, -1,
135  wxDefaultPosition, wxSize(1, 1));
137  wxDefaultPosition, wxSize(1, 1));
138 
139  mGrabber = NULL;
140 
141  ToolBarArea *toolBarParent =
142  dynamic_cast<ToolBarArea *>(GetParent());
143  if (toolBarParent)
144  mGrabber = safenew ToolBarGrabber(this, -1, this);
145 
147  //wxImage hbar = theTheme.Image(bmpToolBarToggle);
148  //wxColour magicColor = wxColour(0, 255, 255);
149  //ImageArray fourStates = ImageRoll::SplitV(hbar, magicColor);
150 /*
151  mToggleButton = safenew AButton(this, kToggleButtonID,
152  wxDefaultPosition, wxDefaultSize,
153  ImageRoll(ImageRoll::HorizontalRoll,
154  fourStates[0], magicColor),
155  ImageRoll(ImageRoll::HorizontalRoll,
156  fourStates[1], magicColor),
157  ImageRoll(ImageRoll::HorizontalRoll,
158  fourStates[2], magicColor),
159  ImageRoll(ImageRoll::HorizontalRoll,
160  fourStates[3], magicColor),
161  true);
162  mToggleButton->UseDisabledAsDownHiliteImage(true);
163 */
164  SetAutoLayout(true);
165  mTimer.SetOwner(this, kTimerID);
166 }
wxWindow * mTopLevelParent
std::unique_ptr< ToolBarArrangement > mSavedArrangement
ToolBarArea * mAreaParent
ToolBarDialog * mDialogParent
Draws the grabber for an ExpandingToolBar.
#define safenew
Definition: Audacity.h:230
An alterantive to ToolBarFrame which can contain an ExpandingToolBar. ToolBarArea is used for a 'dock...
ToolBarFrame * mFrameParent
ToolBarGrabber * mGrabber
ExpandingToolBar::~ExpandingToolBar ( )
virtual

Definition at line 168 of file ExpandingToolBar.cpp.

169 {
170 }

Member Function Documentation

void ExpandingToolBar::Collapse ( bool  now = false)

Definition at line 234 of file ExpandingToolBar.cpp.

References Fit(), mCurrentDrawerSize, mIsAutoExpanded, mIsManualExpanded, MoveDrawer(), mTargetDrawerSize, mToggleButton, and AButton::PopUp().

Referenced by OnToggle().

235 {
236  // After being manually collapsed, we set mIsAutoExpanded back to
237  // true, which prevents it from being immediately auto-expanded
238  // again until after the mouse actually moves away and then
239  // back again later.
240 
241  mToggleButton->PopUp();
242  mIsManualExpanded = false;
243  mIsAutoExpanded = false;
244  Fit();
245  mIsAutoExpanded = true;
246 
247  if (now) {
249 
250  MoveDrawer(wxSize(0, 0));
251  }
252 }
void Fit() override
void PopUp()
Definition: AButton.cpp:525
AButton * mToggleButton
void MoveDrawer(wxSize prevSize)
void ExpandingToolBar::Expand ( )

Definition at line 220 of file ExpandingToolBar.cpp.

References Fit(), mIsAutoExpanded, mIsManualExpanded, mToggleButton, and AButton::PushDown().

Referenced by OnToggle().

221 {
222  // We set both mIsManualExpanded and mIsAutoExpanded to true;
223  // that way if the user manually collapses the toolbar we set
224  // mIsManualExpanded to false but keep mIsAutoExpanded to true
225  // to prevent it from being auto-expanded again until the user
226  // actually moves the mouse completely away and back again later.
227 
229  mIsManualExpanded = true;
230  mIsAutoExpanded = true;
231  Fit();
232 }
void Fit() override
AButton * mToggleButton
void PushDown()
Definition: AButton.cpp:517
void ExpandingToolBar::FinishMoving ( )

Definition at line 621 of file ExpandingToolBar.cpp.

References ToolBarArea::CollapseAll(), kDummyRect, kTimerInterval, mAreaParent, mDragImage, mDropTarget, ToolBarArea::MoveChild(), mSavedArrangement, msNoAutoExpandStack, mTimer, mTopLevelParent, ToolBarArea::RestoreArrangement(), and ToolBarArea::SetCapturedChild().

Referenced by ToolBarArea::OnMouse().

622 {
624  return;
625 
626  // DELETE mTargetPanel; // I think this is not needed, but unreachable anyway -- PRL
627 
629 
630  mDragImage->Hide();
631  mDragImage->EndDrag();
632 
634 
635  if (mDropTarget == kDummyRect) {
637  }
638  else {
639  mSavedArrangement.reset();
641  }
642 
643  // Keep all drawers closed until the user moves specifically to a
644  // different window
646 
647  mTopLevelParent->Refresh(true);
648 
649  mTimer.Start(kTimerInterval);
650 }
wxWindow * mTopLevelParent
std::unique_ptr< ToolBarArrangement > mSavedArrangement
static int msNoAutoExpandStack
const wxRect kDummyRect
void SetCapturedChild(ExpandingToolBar *child)
ToolBarArea * mAreaParent
void CollapseAll(bool now=false)
void RestoreArrangement(std::unique_ptr< ToolBarArrangement > &&arrangement)
const int kTimerInterval
std::unique_ptr< wxDragImage > mDragImage
void MoveChild(ExpandingToolBar *child, wxRect dropTarget)
void ExpandingToolBar::Fit ( )
override

Definition at line 355 of file ExpandingToolBar.cpp.

References kTimerInterval, mButtonSize, mCurrentDrawerSize, mCurrentTotalSize, mExtraSize, mFirstTime, mGrabberSize, mIsAutoExpanded, mIsExpanded, mIsManualExpanded, mMainSize, mTargetDrawerSize, and mTimer.

Referenced by Collapse(), Expand(), TryAutoCollapse(), and TryAutoExpand().

356 {
357 #ifdef EXPERIMENTAL_ROLL_UP_DIALOG
359 #else
360  mIsExpanded = true;// JKC - Wedge it open at all times.
361 #endif
362 
363  int width = mButtonSize.x + mGrabberSize.x;
364 
365  wxSize baseWindowSize = wxSize(width,
366  mMainSize.y + mButtonSize.y);
367 
368  mTargetDrawerSize = wxSize(mButtonSize.x, 0);
369 
370  if (mIsExpanded)
372 
374 
375  // The first time, we always update the size. Otherwise, we set
376  // a target size, and the actual size changes during a timer
377  // event.
378 
379  if (mFirstTime) {
380  mFirstTime = false;
381  mCurrentDrawerSize = wxSize(mExtraSize.x, 0);
382  mCurrentTotalSize = baseWindowSize;
383 
384  SetSizeHints(mCurrentTotalSize, mCurrentTotalSize);
385  SetSize(mCurrentTotalSize);
386  }
387 
388  // wxTimers seem to be a little unreliable - sometimes they stop for
389  // no good reason, so this "primes" it every now and then...
390  mTimer.Stop();
391  mTimer.Start(kTimerInterval);
392 }
const int kTimerInterval
bool ExpandingToolBar::GetAutoExpand ( )
inline

Definition at line 65 of file ExpandingToolBar.h.

References mAutoExpand.

65 { return mAutoExpand; }
wxPanel* ExpandingToolBar::GetExtraPanel ( )
inline

Definition at line 62 of file ExpandingToolBar.h.

References mExtraPanel.

62 { return mExtraPanel; }
wxPanel* ExpandingToolBar::GetMainPanel ( )
inline

Definition at line 61 of file ExpandingToolBar.h.

References mMainPanel.

61 { return mMainPanel; }
wxBitmap ExpandingToolBar::GetToolbarBitmap ( )
protected

Definition at line 493 of file ExpandingToolBar.cpp.

Referenced by StartMoving().

494 {
495  wxSize size = GetClientSize();
496  wxBitmap bitmap(size.x, size.y);
497  wxClientDC winDC(this);
498  wxMemoryDC memDC;
499  memDC.SelectObject(bitmap);
500  memDC.Blit(0, 0, size.x, size.y,
501  &winDC, 0, 0);
502  return bitmap;
503 }
bool ExpandingToolBar::IsCursorInWindow ( )
protected

Definition at line 394 of file ExpandingToolBar.cpp.

References mCurrentTotalSize, and mGrabber.

Referenced by OnTimer().

395 {
396  wxPoint globalMouse = ::wxGetMousePosition();
397  wxPoint localMouse = ScreenToClient(globalMouse);
398 
399  bool result = (localMouse.x >= 0 && localMouse.y >= 0 &&
400  localMouse.x < mCurrentTotalSize.x &&
401  localMouse.y < mCurrentTotalSize.y);
402 
403  // The grabber doesn't count!
404  if (mGrabber && mGrabber->GetRect().Contains(localMouse))
405  result = false;
406 
407  return result;
408 }
ToolBarGrabber * mGrabber
bool ExpandingToolBar::IsExpanded ( )
inline

Definition at line 70 of file ExpandingToolBar.h.

References mIsExpanded.

70 { return mIsExpanded; }
bool ExpandingToolBar::Layout ( )
override

Definition at line 325 of file ExpandingToolBar.cpp.

References kToggleButtonHeight, mButtonSize, mExtraPanel, mExtraSize, mGrabber, mGrabberSize, mMainPanel, mMainSize, and mToggleButton.

326 {
327  mMainSize = mMainPanel->GetBestSize();
328  mExtraSize = mExtraPanel->GetBestSize();
329  mButtonSize = wxSize(wxMax(mMainSize.x, mExtraSize.x),
331 
332  int left = 0;
333 
334  if (mGrabber) {
335  mGrabberSize = mGrabber->GetMinSize();
336  left += mGrabberSize.x;
337  }
338  else
339  mGrabberSize = wxSize(0, 0);
340 
341  mMainPanel->SetSize(left, 0, mMainSize.x, mMainSize.y);
342  mToggleButton->SetSize(left, mMainSize.y, mButtonSize.x, mButtonSize.y);
343  mExtraPanel->SetSize(left, mMainSize.y + mButtonSize.y,
344  mExtraSize.x, mExtraSize.y);
345 
346  if (mGrabber)
347  mGrabber->SetSize(0, 0, left, mMainSize.y + mButtonSize.y);
348 
349  // Add event handlers to all children
350  //RecursivelyPushEventHandlers(this);
351 
352  return true;
353 }
const int kToggleButtonHeight
AButton * mToggleButton
ToolBarGrabber * mGrabber
void ExpandingToolBar::MoveDrawer ( wxSize  prevSize)
protected

Definition at line 428 of file ExpandingToolBar.cpp.

References mAreaParent, mButtonSize, mCurrentDrawerSize, mCurrentTotalSize, mDialogParent, mExtraPanel, mFrameParent, mMainSize, and ReparentExtraPanel().

Referenced by Collapse(), and OnTimer().

429 {
430  mCurrentTotalSize = wxSize(mButtonSize.x,
431  mMainSize.y +
432  mButtonSize.y +
434 
435  if (mFrameParent) {
436  // If we're in a tool window
437 
438  SetSizeHints(mCurrentTotalSize, mCurrentTotalSize);
439  SetSize(mCurrentTotalSize);
440 
441  GetParent()->Fit();
442  }
443 
444  if (mDialogParent) {
445  // If we're in a dialog
446 
447  SetSizeHints(mCurrentTotalSize, mCurrentTotalSize);
448  SetSize(mCurrentTotalSize);
449 
450  GetParent()->Fit();
451  }
452 
453  if (mAreaParent) {
454  // If we're in a tool area
455 
456  if (mCurrentDrawerSize.y > 0 && prevSize.y == 0) {
458  mExtraPanel->Show();
459  }
460 
463 
464  if (mCurrentDrawerSize.y == 0)
465  mExtraPanel->Hide();
466  }
467 }
ToolBarArea * mAreaParent
ToolBarDialog * mDialogParent
ToolBarFrame * mFrameParent
void ExpandingToolBar::OnSize ( wxSizeEvent &  evt)

Definition at line 172 of file ExpandingToolBar.cpp.

References ToolBarArea::AddChild(), mAreaParent, mDialogParent, mFrameParent, ToolBarDialog::SetChild(), and ToolBarFrame::SetChild().

173 {
175  return;
176 
177  // At the time of construction, it wasn't "safe" to tell
178  // our parent that we've just joined the window, so we check
179  // for it during our first OnSize event.
180 
181  if (!mFrameParent) {
182  ToolBarFrame *toolBarParent =
183  dynamic_cast<ToolBarFrame *>(GetParent());
184  if (toolBarParent) {
185  // We were placed into a floating window
186  mFrameParent = toolBarParent;
187  toolBarParent->SetChild(this);
188  }
189  }
190 
191  if (!mDialogParent) {
192  ToolBarDialog *toolBarParent =
193  dynamic_cast<ToolBarDialog *>(GetParent());
194  if (toolBarParent) {
195  // We were placed into a dialog
196  mDialogParent = toolBarParent;
197  toolBarParent->SetChild(this);
198  }
199  }
200 
201  if (!mAreaParent) {
202  ToolBarArea *toolBarParent =
203  dynamic_cast<ToolBarArea *>(GetParent());
204  if (toolBarParent) {
205  // We were placed into an area full of other toolbars
206  mAreaParent = toolBarParent;
207  toolBarParent->AddChild(this);
208  }
209  }
210 }
void SetChild(ExpandingToolBar *child)
ToolBarArea * mAreaParent
ToolBarDialog * mDialogParent
A miniframe based container for ExpandingToolBars providing modeless presentation.
void AddChild(ExpandingToolBar *child)
A dialog based container for ExpandingToolBars providing modal based operations.
void SetChild(ExpandingToolBar *child)
An alterantive to ToolBarFrame which can contain an ExpandingToolBar. ToolBarArea is used for a 'dock...
ToolBarFrame * mFrameParent
void ExpandingToolBar::OnTimer ( wxTimerEvent &  evt)

Definition at line 469 of file ExpandingToolBar.cpp.

References IsCursorInWindow(), mAutoExpand, mCurrentDrawerSize, MoveDrawer(), msNoAutoExpandStack, mTargetDrawerSize, TryAutoCollapse(), and TryAutoExpand().

470 {
471  if (mAutoExpand && msNoAutoExpandStack==0 &&
473  TryAutoExpand();
474  else if (!IsCursorInWindow())
475  TryAutoCollapse();
476 
478  return;
479 
480  // This accelerates the current size towards the target size;
481  // it's a neat way for the window to roll open, but in such a
482  // way that it
483 
484  wxSize prevSize = mCurrentDrawerSize;
486  if (abs((mCurrentDrawerSize-mTargetDrawerSize).x)<2 &&
489 
490  MoveDrawer(prevSize);
491 }
static int msNoAutoExpandStack
void MoveDrawer(wxSize prevSize)
void ExpandingToolBar::OnToggle ( wxCommandEvent &  evt)

Definition at line 212 of file ExpandingToolBar.cpp.

References Collapse(), Expand(), and mIsExpanded.

213 {
214  if (mIsExpanded)
215  Collapse();
216  else
217  Expand();
218 }
void Collapse(bool now=false)
void ExpandingToolBar::RecursivelyPushEventHandlers ( wxWindow *  win)
protected

Definition at line 312 of file ExpandingToolBar.cpp.

References mHandlers, and mWindowHash.

313 {
314  if (!mWindowHash[win]) {
315  mHandlers.push_back(std::make_unique<ExpandingToolBarEvtHandler>
316  (this, win, win->GetEventHandler()));
317  mWindowHash[win] = 1;
318  }
319 
320  wxWindowList children = win->GetChildren();
321  for(auto child : children)
323 }
void RecursivelyPushEventHandlers(wxWindow *win)
WindowHash mWindowHash
std::vector< std::unique_ptr< ExpandingToolBarEvtHandler > > mHandlers
void ExpandingToolBar::ReparentExtraPanel ( )
protected

Definition at line 410 of file ExpandingToolBar.cpp.

References mButtonSize, mExtraPanel, mGrabberSize, and mMainSize.

Referenced by MoveDrawer().

411 {
412  // This is how we make sure the extra panel, which slides out
413  // like a drawer, appears on top of everything else in the window...
414 
415  wxPoint pos;
416  pos.x = mGrabberSize.x;
417  pos.y = mMainSize.y + mButtonSize.y;
418  wxWindow *frame = this;
419  while(!frame->IsTopLevel()) {
420  pos += frame->GetPosition();
421  frame = frame->GetParent();
422  }
423 
424  mExtraPanel->Reparent(frame);
425  mExtraPanel->SetPosition(pos);
426 }
void ExpandingToolBar::SetAutoExpand ( bool  enabled)
inline

Definition at line 64 of file ExpandingToolBar.h.

References mAutoExpand.

64 { mAutoExpand = enabled; }
void ExpandingToolBar::StartMoving ( )

Definition at line 505 of file ExpandingToolBar.cpp.

References ToolBarArea::CollapseAll(), ToolBarArea::GetDropTargets(), GetToolbarBitmap(), kDummyRect, mAreaParent, mDragImage, mDropTarget, mDropTargets, mSavedArrangement, msNoAutoExpandStack, mTargetPanel, mTimer, mTopLevelParent, ToolBarArea::RemoveChild(), safenew, ToolBarArea::SaveArrangement(), ToolBarArea::SetCapturedChild(), and ImageRollPanel::SetLogicalFunction().

Referenced by ToolBarGrabber::OnMouse().

506 {
507  if (!mAreaParent)
508  return;
509 
510  int j;
511 
512  mAreaParent->CollapseAll(true);
513 
514  mTimer.Stop();
515 
516  // This gives time for wx to finish redrawing the window that way.
517  // HACK: why do we need to do it so many times???
518  for(j=0; j<500; j++)
519  ::wxSafeYield();
520 
521  wxBitmap toolbarBitmap = GetToolbarBitmap();
522 
525  mAreaParent->RemoveChild(this);
526 
527  mAreaParent->Refresh(true);
528 
529  mTopLevelParent = this;
530  while(!mTopLevelParent->IsTopLevel())
531  mTopLevelParent = mTopLevelParent->GetParent();
532 
533  wxPoint hotSpot = ScreenToClient(wxGetMousePosition());
534 
535  hotSpot -= (ClientToScreen(wxPoint(0, 0)) -
536  mAreaParent->ClientToScreen(wxPoint(0, 0)));
537 
540 
541  wxColour magicColor = wxColour(0, 255, 255);
542 // wxImage tgtImage = theTheme.Image(bmpToolBarTarget);
543 // ImageRoll tgtImageRoll = ImageRoll(ImageRoll::VerticalRoll,
544 // tgtImage,
545 // magicColor);
546  mTargetPanel = safenew ImageRollPanel(mAreaParent, -1, //tgtImageRoll,
547  wxDefaultPosition,
548  wxDefaultSize,
549  wxTRANSPARENT_WINDOW);
551  mTargetPanel->SetSize(mDropTarget);
552 
553  // This gives time for wx to finish redrawing the window that way.
554  // HACK: why do we need to do it several times???
555  for(j=0; j<500; j++)
556  ::wxSafeYield();
557 
559 
560  mDragImage = std::make_unique<wxDragImage>(toolbarBitmap);
561  mDragImage->BeginDrag(hotSpot, mAreaParent, mTopLevelParent);
562  mDragImage->Show();
563  mDragImage->Move(ScreenToClient(wxGetMousePosition()));
564 }
wxWindow * mTopLevelParent
std::unique_ptr< ToolBarArrangement > mSavedArrangement
void SetLogicalFunction(wxRasterOperationMode func)
Definition: ImageRoll.cpp:435
std::unique_ptr< ToolBarArrangement > SaveArrangement()
static int msNoAutoExpandStack
const wxRect kDummyRect
void SetCapturedChild(ExpandingToolBar *child)
void RemoveChild(ExpandingToolBar *child)
ToolBarArea * mAreaParent
#define safenew
Definition: Audacity.h:230
ImageRollPanel * mTargetPanel
std::vector< wxRect > GetDropTargets()
std::vector< wxRect > mDropTargets
void CollapseAll(bool now=false)
A wxPanel which displays an ImageRoll.
Definition: ImageRoll.h:71
wxBitmap GetToolbarBitmap()
std::unique_ptr< wxDragImage > mDragImage
void ExpandingToolBar::TryAutoCollapse ( )
protected

Definition at line 264 of file ExpandingToolBar.cpp.

References Fit(), mIsAutoExpanded, mIsManualExpanded, mToggleButton, and AButton::PopUp().

Referenced by OnTimer().

265 {
266 #ifdef EXPERIMENTAL_ROLL_UP_DIALOG
267  if (mIsAutoExpanded == true && mIsManualExpanded == false) {
268  mToggleButton->PopUp();
269  mIsAutoExpanded = false;
270  Fit();
271  }
272 #endif
273 }
void Fit() override
void PopUp()
Definition: AButton.cpp:525
AButton * mToggleButton
void ExpandingToolBar::TryAutoExpand ( )
protected

Definition at line 254 of file ExpandingToolBar.cpp.

References Fit(), mAutoExpand, mIsAutoExpanded, mIsManualExpanded, msNoAutoExpandStack, mToggleButton, and AButton::PushDown().

Referenced by OnTimer(), and ExpandingToolBarEvtHandler::ProcessEvent().

255 {
256  if (mAutoExpand && msNoAutoExpandStack==0 &&
257  mIsManualExpanded == false && mIsAutoExpanded == false) {
259  mIsAutoExpanded = true;
260  Fit();
261  }
262 }
void Fit() override
static int msNoAutoExpandStack
AButton * mToggleButton
void PushDown()
Definition: AButton.cpp:517
void ExpandingToolBar::UpdateMoving ( )

Definition at line 566 of file ExpandingToolBar.cpp.

References kDummyRect, mAreaParent, mDragImage, mDropTarget, mDropTargets, mSavedArrangement, and mTargetPanel.

Referenced by ToolBarArea::OnMouse().

567 {
569  return;
570 
571  wxPoint cursorPos = mAreaParent->ScreenToClient(wxGetMousePosition());
572  wxRect prevTarget = mDropTarget;
573  int best_dist_sq = 99999;
574  int i;
575 
576  for(i = 0; i < (int)mDropTargets.size(); i++) {
577  int x = (mDropTargets[i].x + (mDropTargets[i].width/2))-cursorPos.x;
578  int y = (mDropTargets[i].y + (mDropTargets[i].height/2))-cursorPos.y;
579  int dist_sq = (x*x) + (y*y);
580 
581  if (dist_sq < best_dist_sq) {
582  best_dist_sq = dist_sq;
584  }
585  }
586 
587  if (!mAreaParent->GetRect().Contains(cursorPos))
589 
590  if (mDropTarget != prevTarget) {
591  mDragImage->Hide();
592 
593  wxRect r = mDropTarget;
594  r.Inflate(4, 4);
595  mTargetPanel->SetSize(r);
596 
597  #if 0
598  wxClientDC dc(mAreaParent);
599  dc.DestroyClippingRegion();
600  dc.SetLogicalFunction(wxINVERT);
601  wxRect r = prevTarget;
602  r.Inflate(4, 4);
603  dc.DrawRectangle(r);
604  r = mDropTarget;
605  r.Inflate(4, 4);
606  dc.DrawRectangle(r);
607  #endif
608 
609  // This gives time for wx to finish redrawing the window that way.
610  // HACK: why do we need to do it so many times???
611  for(i=0; i<500; i++)
612  ::wxSafeYield();
613 
614  mDragImage->Show();
615  mDragImage->Move(ScreenToClient(wxGetMousePosition()));
616  }
617  else
618  mDragImage->Move(ScreenToClient(wxGetMousePosition()));
619 }
std::unique_ptr< ToolBarArrangement > mSavedArrangement
const wxRect kDummyRect
ToolBarArea * mAreaParent
ImageRollPanel * mTargetPanel
std::vector< wxRect > mDropTargets
std::unique_ptr< wxDragImage > mDragImage

Friends And Related Function Documentation

friend class ExpandingToolBarEvtHandler
friend

Definition at line 125 of file ExpandingToolBar.h.

Member Data Documentation

ToolBarArea* ExpandingToolBar::mAreaParent
protected

Definition at line 113 of file ExpandingToolBar.h.

Referenced by FinishMoving(), MoveDrawer(), OnSize(), StartMoving(), and UpdateMoving().

bool ExpandingToolBar::mAutoExpand
protected

Definition at line 100 of file ExpandingToolBar.h.

Referenced by GetAutoExpand(), OnTimer(), SetAutoExpand(), and TryAutoExpand().

wxSize ExpandingToolBar::mButtonSize
protected

Definition at line 104 of file ExpandingToolBar.h.

Referenced by Fit(), Layout(), MoveDrawer(), and ReparentExtraPanel().

wxSize ExpandingToolBar::mCurrentDrawerSize
protected

Definition at line 106 of file ExpandingToolBar.h.

Referenced by Collapse(), Fit(), MoveDrawer(), and OnTimer().

wxSize ExpandingToolBar::mCurrentTotalSize
protected

Definition at line 108 of file ExpandingToolBar.h.

Referenced by Fit(), IsCursorInWindow(), and MoveDrawer().

ToolBarDialog* ExpandingToolBar::mDialogParent
protected

Definition at line 112 of file ExpandingToolBar.h.

Referenced by MoveDrawer(), and OnSize().

std::unique_ptr<wxDragImage> ExpandingToolBar::mDragImage
protected

Definition at line 116 of file ExpandingToolBar.h.

Referenced by FinishMoving(), StartMoving(), and UpdateMoving().

wxRect ExpandingToolBar::mDropTarget
protected

Definition at line 119 of file ExpandingToolBar.h.

Referenced by FinishMoving(), StartMoving(), and UpdateMoving().

std::vector<wxRect> ExpandingToolBar::mDropTargets
protected

Definition at line 118 of file ExpandingToolBar.h.

Referenced by StartMoving(), and UpdateMoving().

wxPanel* ExpandingToolBar::mExtraPanel
protected

Definition at line 94 of file ExpandingToolBar.h.

Referenced by GetExtraPanel(), Layout(), MoveDrawer(), and ReparentExtraPanel().

wxSize ExpandingToolBar::mExtraSize
protected

Definition at line 103 of file ExpandingToolBar.h.

Referenced by Fit(), and Layout().

bool ExpandingToolBar::mFirstTime
protected

Definition at line 101 of file ExpandingToolBar.h.

Referenced by Fit().

ToolBarFrame* ExpandingToolBar::mFrameParent
protected

Definition at line 111 of file ExpandingToolBar.h.

Referenced by MoveDrawer(), and OnSize().

ToolBarGrabber* ExpandingToolBar::mGrabber
protected

Definition at line 95 of file ExpandingToolBar.h.

Referenced by IsCursorInWindow(), and Layout().

wxSize ExpandingToolBar::mGrabberSize
protected

Definition at line 105 of file ExpandingToolBar.h.

Referenced by Fit(), Layout(), and ReparentExtraPanel().

std::vector< std::unique_ptr< ExpandingToolBarEvtHandler > > ExpandingToolBar::mHandlers
protected

Definition at line 126 of file ExpandingToolBar.h.

Referenced by RecursivelyPushEventHandlers().

bool ExpandingToolBar::mIsAutoExpanded
protected

Definition at line 97 of file ExpandingToolBar.h.

Referenced by Collapse(), Expand(), Fit(), TryAutoCollapse(), and TryAutoExpand().

bool ExpandingToolBar::mIsExpanded
protected

Definition at line 99 of file ExpandingToolBar.h.

Referenced by Fit(), IsExpanded(), and OnToggle().

bool ExpandingToolBar::mIsManualExpanded
protected

Definition at line 98 of file ExpandingToolBar.h.

Referenced by Collapse(), Expand(), Fit(), TryAutoCollapse(), and TryAutoExpand().

wxPanel* ExpandingToolBar::mMainPanel
protected

Definition at line 93 of file ExpandingToolBar.h.

Referenced by GetMainPanel(), and Layout().

wxSize ExpandingToolBar::mMainSize
protected

Definition at line 102 of file ExpandingToolBar.h.

Referenced by Fit(), Layout(), MoveDrawer(), and ReparentExtraPanel().

std::unique_ptr<ToolBarArrangement> ExpandingToolBar::mSavedArrangement
protected

Definition at line 114 of file ExpandingToolBar.h.

Referenced by FinishMoving(), StartMoving(), and UpdateMoving().

int ExpandingToolBar::msNoAutoExpandStack = 0
staticprotected

Definition at line 121 of file ExpandingToolBar.h.

Referenced by FinishMoving(), OnTimer(), StartMoving(), and TryAutoExpand().

wxSize ExpandingToolBar::mTargetDrawerSize
protected

Definition at line 107 of file ExpandingToolBar.h.

Referenced by Collapse(), Fit(), and OnTimer().

ImageRollPanel* ExpandingToolBar::mTargetPanel
protected

Definition at line 115 of file ExpandingToolBar.h.

Referenced by StartMoving(), and UpdateMoving().

wxTimer ExpandingToolBar::mTimer
protected

Definition at line 110 of file ExpandingToolBar.h.

Referenced by FinishMoving(), Fit(), and StartMoving().

AButton* ExpandingToolBar::mToggleButton
protected

Definition at line 96 of file ExpandingToolBar.h.

Referenced by Collapse(), Expand(), Layout(), TryAutoCollapse(), and TryAutoExpand().

wxWindow* ExpandingToolBar::mTopLevelParent
protected

Definition at line 117 of file ExpandingToolBar.h.

Referenced by FinishMoving(), and StartMoving().

WindowHash ExpandingToolBar::mWindowHash
protected

Definition at line 109 of file ExpandingToolBar.h.

Referenced by RecursivelyPushEventHandlers().


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