Files
reasampler/src/overflow_menu.cpp
T
daniel 7cd0771e45 L5: dock-panel button refinements — overflow menu, tooltips, opposite-mode tag buttons
Top-bar rare-capture variants move to a right-anchored More popup; short faces gain
hover-delay full-name tooltips (prefix stripped); bottom bar becomes four opposite-mode
Item/Track tag buttons + Show Both (Toggle/Activates dropped); wider cluster gaps. New
pure overflow_menu/mode_enable/tooltip modules, CTest-covered. Same actions, same contract.
2026-07-26 23:56:49 -04:00

43 lines
1.5 KiB
C++

// overflow_menu — pure implementation. See overflow_menu.h. NO REAPER / SWELL / LICE / vendor.
#include "overflow_menu.h"
namespace reasampler {
int menuButtonReserve(const MenuBarRect& bar, const MenuButtonSpec& spec) {
if (bar.width <= 0 || bar.height <= 0 || spec.buttonWidth <= 0) return 0;
// The reserve is the button width plus a right gap (rightInset) and a matching left gap
// (also rightInset) so the frequent buttons have breathing room before the menu button.
return spec.buttonWidth + 2 * spec.rightInset;
}
MenuButtonRect computeMenuButton(const MenuBarRect& bar, const MenuButtonSpec& spec) {
MenuButtonRect btn;
if (bar.width <= 0 || bar.height <= 0 || spec.buttonWidth <= 0) return btn;
const int right = bar.x + bar.width - spec.rightInset;
const int left = right - spec.buttonWidth;
if (left < bar.x + spec.minLeftInset) return btn; // too narrow — suppress
int top = bar.y + spec.verticalInset;
int height = bar.height - 2 * spec.verticalInset;
if (height <= 0) { // thin band: clamp to the band's own extents rather than go negative
top = bar.y;
height = bar.height;
}
btn.x = left;
btn.y = top;
btn.width = spec.buttonWidth;
btn.height = height;
return btn;
}
bool hitTestMenuButton(int px, int py, const MenuButtonRect& button) {
if (button.empty()) return false;
return px >= button.x && px < button.x + button.width &&
py >= button.y && py < button.y + button.height;
}
} // namespace reasampler