MCPcopy Create free account
hub / github.com/audacity/audacity / ReCreateButtons

Method ReCreateButtons

src/toolbars/ToolBar.cpp:533–618  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

531
532
533void ToolBar::ReCreateButtons()
534{
535 wxSize sz3 = GetSize();
536 //wxLogDebug( "x:%i y:%i",sz3.x, sz3.y);
537
538 // SetSizer(NULL) detaches mHSizer and deletes it.
539 // Do not use Detach() here, as that attempts to detach mHSizer from itself!
540 SetSizer( NULL );
541
542 // Get rid of any children we may have
543 DestroyChildren();
544 mGrabber = NULL;
545 mResizer = NULL;
546 SetLayoutDirection(wxLayout_LeftToRight);
547
548 // Refresh the background before populating
549 if (!IsDocked())
550 {
551 GetParent()->Refresh();
552 }
553
554 {
555 // Create the main sizer
556 auto ms = std::make_unique<wxBoxSizer>(wxHORIZONTAL);
557
558 // Create the grabber and add it to the main sizer
559 mGrabber = safenew Grabber(this, GetSection());
560 ms->Add(mGrabber, 0, wxEXPAND | wxALIGN_LEFT | wxALIGN_TOP | wxRIGHT, 1);
561
562 // Use a box sizer for laying out controls
563 ms->Add((mHSizer = safenew wxBoxSizer(wxHORIZONTAL)), 1, wxEXPAND);
564
565 // Go add all the rest of the gadgets
566 Populate();
567
568 // Add some space for the resize border
569 if (IsResizable())
570 {
571 // Create the resizer and add it to the main sizer
572 mResizer = safenew ToolBarResizer(this);
573 ms->Add(mResizer, 0, wxEXPAND | wxALIGN_TOP | wxLEFT, 1);
574 mResizer->SetToolTip(_("Click and drag to resize toolbar"));
575 }
576
577 // Set dock after possibly creating resizer.
578 // (Re)Establish dock state
579 SetDocked(GetDock(), false);
580
581 // Set the sizer
582 SetSizerAndFit(ms.release());
583 }
584
585 // Recalculate the height to be a multiple of toolbarSingle
586 const int tbs = toolbarSingle + toolbarGap;
587 wxSize sz = GetSize();
588 sz.y = ( ( ( sz.y + tbs -1) / tbs ) * tbs ) - 1;
589
590 // Set the true AND minimum sizes and do final layout

Callers 2

OnThemeChangeMethod · 0.45
ResetMethod · 0.45

Calls 9

GetParentFunction · 0.85
GrabberClass · 0.85
GetMinToolbarWidthFunction · 0.85
wxBoxSizerClass · 0.70
ToolBarResizerClass · 0.70
RefreshMethod · 0.45
AddMethod · 0.45
SetToolTipMethod · 0.45
releaseMethod · 0.45

Tested by

no test coverage detected