Skip to content

Commit

Permalink
Common positioning code for Routing Info Icon
Browse files Browse the repository at this point in the history
  • Loading branch information
firthm01 committed Nov 3, 2023
1 parent 0a282ca commit e14ba77
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,7 @@ class ValueBoxMain : public Component {
auto routingLabelArea = routingArea.withWidth(labelWidth_);
routingLabel_->setBounds(routingLabelArea);
if (routingInfoIcon_->isVisible()) {
auto routingInfoArea = routingArea.removeFromRight(13).withTrimmedTop(
1); // Trimming 1 to get an odd height. Icon is odd height too, so
// ensures an integer number of pixels padding top and bottom to
// avoid blurring through anti-aliasing.
routingInfoIcon_->setBounds(routingInfoArea);
placeRoutingInfoIconRight(routingArea, routingInfoIcon_.get());
routingArea.removeFromRight(marginSmall_);
}
auto routingComboBoxArea =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,7 @@ class ValueBoxMain : public Component {
auto routingLabelArea = routingArea.withWidth(labelWidth_);
routingLabel_->setBounds(routingLabelArea);
if (routingInfoIcon_->isVisible()) {
auto routingInfoArea = routingArea.removeFromRight(13).withTrimmedTop(1); // Trimming 1 to get an odd height. Icon is odd height too, so ensures an integer number of pixels padding top and bottom to avoid blurring through anti-aliasing.
routingInfoIcon_->setBounds(routingInfoArea);
placeRoutingInfoIconRight(routingArea, routingInfoIcon_.get());
routingArea.removeFromRight(marginSmall_);
}
auto routingComboBoxArea =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,7 @@ class ValueBoxMain : public Component {
auto routingLabelArea = routingArea.withWidth(labelWidth_);
routingLabel_->setBounds(routingLabelArea);
if (routingInfoIcon_->isVisible()) {
auto routingInfoArea = routingArea.removeFromRight(13).withTrimmedTop(1); // Trimming 1 to get an odd height. Icon is odd height too, so ensures an integer number of pixels padding top and bottom to avoid blurring through anti-aliasing.
routingInfoIcon_->setBounds(routingInfoArea);
placeRoutingInfoIconRight(routingArea, routingInfoIcon_.get());
routingArea.removeFromRight(marginSmall_);
}
auto routingComboBoxArea =
Expand Down
10 changes: 10 additions & 0 deletions shared/components/routing_info_icon.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,16 @@ namespace ui {
return std::move(routingIcon);
}

inline void placeRoutingInfoIconRight(juce::Rectangle<int>& area, ImageComponent* routingInfoIcon) {
auto routingInfoArea = area.removeFromRight(13);
// Need an odd height to avoid blurring through anti-aliasing
// (since icon is odd height too, so ensures integer padding when centring vertically)
if (routingInfoArea.getHeight() % 2 == 0) {
routingInfoArea.removeFromTop(1);
}
routingInfoIcon->setBounds(routingInfoArea);
}

} // namespace ui
} // namespace plugin
} // namespace ear

0 comments on commit e14ba77

Please sign in to comment.