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.
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
// tooltip — pure implementation. See tooltip.h. NO REAPER / SWELL / LICE / vendor.
|
||||
|
||||
#include "tooltip.h"
|
||||
|
||||
namespace reasampler {
|
||||
|
||||
std::string stripActionPrefix(const std::string& fullName, const std::string& prefix) {
|
||||
if (prefix.empty()) return fullName;
|
||||
if (fullName.size() >= prefix.size() &&
|
||||
fullName.compare(0, prefix.size(), prefix) == 0)
|
||||
return fullName.substr(prefix.size());
|
||||
return fullName;
|
||||
}
|
||||
|
||||
TooltipBox computeTooltip(int anchorX, int anchorY, int anchorW, int anchorH,
|
||||
int textW, int textH, int clientW, int clientH,
|
||||
const TooltipSpec& spec) {
|
||||
TooltipBox box;
|
||||
if (textW <= 0 || textH <= 0 || clientW <= 0 || clientH <= 0) return box;
|
||||
|
||||
const int boxW = textW + 2 * spec.padX;
|
||||
const int boxH = textH + 2 * spec.padY;
|
||||
|
||||
// Horizontal: centre on the anchor, then clamp within [margin, clientW - margin - boxW].
|
||||
int x = anchorX + (anchorW - boxW) / 2;
|
||||
const int maxX = clientW - spec.margin - boxW;
|
||||
if (x > maxX) x = maxX;
|
||||
if (x < spec.margin) x = spec.margin;
|
||||
|
||||
// Vertical: prefer BELOW the anchor; flip ABOVE if it would clip the bottom edge.
|
||||
int y = anchorY + anchorH + spec.gap;
|
||||
if (y + boxH > clientH - spec.margin) {
|
||||
const int above = anchorY - spec.gap - boxH;
|
||||
if (above >= spec.margin) {
|
||||
y = above; // fits above — flip
|
||||
} else {
|
||||
// Fits neither cleanly (tall tooltip / short client): clamp to the bottom margin.
|
||||
const int maxY = clientH - spec.margin - boxH;
|
||||
y = maxY < spec.margin ? spec.margin : maxY;
|
||||
}
|
||||
}
|
||||
|
||||
box.x = x;
|
||||
box.y = y;
|
||||
box.width = boxW;
|
||||
box.height = boxH;
|
||||
return box;
|
||||
}
|
||||
|
||||
} // namespace reasampler
|
||||
Reference in New Issue
Block a user