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

Method Insert

src/toolbars/ToolDock.cpp:110–186  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

108}
109
110void ToolBarConfiguration::Insert(ToolBar *bar, Position position)
111{
112 if (position == UnspecifiedPosition) {
113 // Add at the "end" of the layout
114 // bottommost and rightmost
115 Forest *pForest = &mForest;
116 while (!pForest->empty())
117 pForest = &pForest->back().children;
118 pForest->push_back( Tree {} );
119 pForest->back().pBar = bar;
120 }
121 else {
122 // Insert at what depth?
123 auto pForest = &mForest;
124 if (position.rightOf) {
125 const auto parent = FindPlace(position.rightOf);
126 if (parent != end())
127 // Insert among children of some node
128 pForest = &parent->pTree->children;
129 }
130 else {
131 // Insert a new root in the top forest
132 }
133
134 // Insert at what breadth?
135 const auto begin = pForest->begin();
136 auto iter = begin;
137 const auto end = pForest->end();
138 bool adopt = false;
139
140 if (position.below) {
141 iter = std::find_if(begin, end,
142 [=](const Tree &tree){ return tree.pBar == position.below; }
143 );
144 if (iter != end) {
145 ++iter;
146 if (iter != end)
147 adopt = true;
148 }
149 else
150 // Not found, default to topmost
151 iter = begin;
152 }
153 else
154 // No previous sibling specified, so insert as first
155 adopt = (iter != end);
156
157 // Insert as a leaf, or as an internal node?
158 if (adopt && position.adopt) {
159 // Existing children of parent become grandchildren
160
161 // Make NEW node
162 Tree tree;
163 tree.pBar = bar;
164
165 // Do adoption
166 const auto barHeight = bar->GetSize().GetY() + toolbarGap;
167 auto totalHeight = 0;

Callers 9

InsertEffectRowMethod · 0.45
EnvLogToLinMethod · 0.45
EnvLinToLogMethod · 0.45
GraphicEQMethod · 0.45
UpdateGraphicMethod · 0.45
OnMergeStereoMethod · 0.45
DockMethod · 0.45
VisitLayoutMethod · 0.45

Calls 8

endFunction · 0.50
emptyMethod · 0.45
push_backMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
GetSizeMethod · 0.45
swapMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected