Advertisement
nezvers

Jusce Rectangle

Feb 26th, 2020
533
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.88 KB | None | 0 0
  1. //Current
  2. void MainComponent::resized()
  3. {
  4.     Rectangle<int> top = getLocalBounds();
  5.     Rectangle<int> bottom = top.removeFromTop(top.getHeight() * 0.5);
  6.     dial1.setBounds(top.removeFromLeft(top.getWidth() * 0.5));
  7.     dial2.setBounds(top);
  8.     dial3.setBounds(bottom.removeFromLeft(bottom.getWidth() * 0.5));
  9.     dial4.setBounds(bottom);
  10. }
  11.  
  12. //Proposed - that using removeFromSide doesn't change caller object
  13. //Maybe alternative method?
  14. void MainComponent::resized()
  15. {
  16.     Rectangle<int> area = getLocalBounds();
  17.     int h = area.getHeight();
  18.     int w = area.getWidth();
  19.     dial1.setBounds(area.removeFromTop(h * 0.5).removeFromLeft(w * 0.5));
  20.     dial2.setBounds(area.removeFromTop(h * 0.5).removeFromRight(w * 0.5));
  21.     dial3.setBounds(area.removeFromBottom(h * 0.5).removeFromLeft(w * 0.5));
  22.     dial4.setBounds(area.removeFromBottom(h * 0.5).removeFromRight(w * 0.5));
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement