MCPcopy Create free account
hub / github.com/jerryuhoo/Fire / resized

Method resized

Source/Panels/ControlPanel/GlobalPanel.cpp:296–431  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

294}
295
296void GlobalPanel::resized()
297{
298 const float scale = this->scale;
299 const int scaledKnobSize = static_cast<int>(KNOB_SIZE * scale);
300 const int scaledSpacing = static_cast<int>(10 * scale);
301
302 // The main area is reduced only once to create the outer margin.
303 auto mainArea = getLocalBounds().reduced(scaledSpacing);
304
305 // --- Define proportions ---
306 const float switchColumnProportion = 0.15f;
307 const float outputColumnProportion = 0.2f;
308
309 // --- Sequentially lay out the columns ---
310 auto layoutArea = mainArea;
311 auto switchColumnArea = layoutArea.removeFromLeft(mainArea.getWidth() * switchColumnProportion);
312 auto outputColumnArea = layoutArea.removeFromRight(mainArea.getWidth() * outputColumnProportion);
313 auto knobsColumnArea = layoutArea; // Knobs area is what's left.
314
315 tabAreaRect = switchColumnArea.getUnion(knobsColumnArea);
316 outputAreaRect = outputColumnArea;
317
318 // --- Column 1: Layout Switches ---
319 juce::FlexBox switchColumnBox;
320 switchColumnBox.flexDirection = juce::FlexBox::Direction::column;
321 switchColumnBox.justifyContent = juce::FlexBox::JustifyContent::spaceAround;
322 switchColumnBox.alignItems = juce::FlexBox::AlignItems::stretch;
323 switchColumnBox.items.add(juce::FlexItem(filterSwitch).withFlex(1.0f));
324 switchColumnBox.items.add(juce::FlexItem(downsampleSwitch).withFlex(1.0f));
325 switchColumnBox.items.add(juce::FlexItem(graphSwitch).withFlex(1.0f));
326 switchColumnBox.performLayout(switchColumnArea);
327
328 auto layoutBypassButton = [&](juce::ToggleButton& bypass, const juce::TextButton& parentSwitch)
329 {
330 auto parentBounds = parentSwitch.getBounds();
331 const int bypassSize = (int) (KNOB_FONT_SIZE * 2.0f * scale);
332
333 bypass.setBounds(parentBounds.getX(),
334 parentBounds.getCentreY() - (bypassSize / 2),
335 bypassSize,
336 bypassSize);
337 bypass.toFront(false);
338 };
339
340 layoutBypassButton(*filterBypassButton, filterSwitch);
341 layoutBypassButton(*downsampleBypassButton, downsampleSwitch);
342
343 // --- Column 3: Layout for Output Section ---
344 auto knobsArea = outputColumnArea.withSizeKeepingCentre(scaledKnobSize, scaledKnobSize * 2 + scaledSpacing);
345 modulatableSliderComponents.at(GLOBAL_OUTPUT_NAME)->setBounds(knobsArea.removeFromTop(scaledKnobSize));
346 knobsArea.removeFromTop(scaledSpacing); // spacing
347 modulatableSliderComponents.at(GLOBAL_MIX_NAME)->setBounds(knobsArea.removeFromTop(scaledKnobSize));
348
349 // --- Column 2: Layout for Main Knobs/Graphs Area ---
350 if (filterSwitch.getToggleState())
351 {
352 auto controlArea = knobsColumnArea;
353 auto leftHalf = controlArea.removeFromLeft(controlArea.getWidth() / 2);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected