Skip to content

Commit 5816b12

Browse files
HanSur94claude
andcommitted
fix: use pixel-sized info and detach buttons instead of normalized
Info (i) and detach (^) buttons now use fixed 24x24 pixel sizing anchored to the top-right of the widget panel. Previously they used normalized 0.08x0.08 which became unreadably small on short panels like KPI widgets and collapsed groups. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent fe8d1e0 commit 5816b12

1 file changed

Lines changed: 25 additions & 6 deletions

File tree

libs/Dashboard/DashboardLayout.m

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -538,18 +538,19 @@ function addInfoIcon(obj, widget)
538538
end
539539
iconBg = theme.ToolbarBackground;
540540
iconFg = theme.ToolbarFontColor;
541-
uicontrol('Parent', widget.hPanel, ...
541+
btn = uicontrol('Parent', widget.hPanel, ...
542542
'Style', 'pushbutton', ...
543543
'String', 'i', ...
544-
'Units', 'normalized', ...
545-
'Position', [0.90 0.90 0.08 0.08], ...
544+
'Units', 'pixels', ...
545+
'Position', [0 0 24 24], ...
546546
'FontSize', 9, ...
547547
'FontWeight', 'bold', ...
548548
'ForegroundColor', iconFg, ...
549549
'BackgroundColor', iconBg, ...
550550
'Tag', 'InfoIconButton', ...
551551
'TooltipString', 'Widget info', ...
552552
'Callback', @(~,~) obj.openInfoPopup(widget, theme));
553+
DashboardLayout.anchorTopRight(btn, 4);
553554
end
554555

555556
function addDetachButton(obj, widget)
@@ -559,22 +560,40 @@ function addDetachButton(obj, widget)
559560
else
560561
theme = widget.ParentTheme;
561562
end
562-
uicontrol('Parent', widget.hPanel, ...
563+
btn = uicontrol('Parent', widget.hPanel, ...
563564
'Style', 'pushbutton', ...
564565
'String', '^', ...
565-
'Units', 'normalized', ...
566-
'Position', [0.82 0.90 0.08 0.08], ...
566+
'Units', 'pixels', ...
567+
'Position', [0 0 24 24], ...
567568
'FontSize', 9, ...
568569
'ForegroundColor', theme.ToolbarFontColor, ...
569570
'BackgroundColor', theme.ToolbarBackground, ...
570571
'Tag', 'DetachButton', ...
571572
'TooltipString', 'Detach widget', ...
572573
'Callback', @(~,~) obj.DetachCallback(widget));
574+
DashboardLayout.anchorTopRight(btn, 32);
573575
end
574576
end
575577

576578
methods (Static, Access = private)
577579

580+
function anchorTopRight(btn, offsetFromRight)
581+
%ANCHORTOPRIGHT Position a pixel-sized button at the top-right of its parent.
582+
% anchorTopRight(btn, offsetFromRight) places btn at the top-right corner
583+
% of its parent, inset by offsetFromRight pixels from the right edge.
584+
parent = get(btn, 'Parent');
585+
oldUnits = get(parent, 'Units');
586+
set(parent, 'Units', 'pixels');
587+
pp = get(parent, 'Position');
588+
set(parent, 'Units', oldUnits);
589+
btnPos = get(btn, 'Position');
590+
btnW = btnPos(3);
591+
btnH = btnPos(4);
592+
x = pp(3) - offsetFromRight;
593+
y = pp(4) - btnH - 4;
594+
set(btn, 'Position', [x y btnW btnH]);
595+
end
596+
578597
function plain = stripHtmlTags(html)
579598
%STRIPHTMLTAGS Remove HTML tags and decode basic HTML entities.
580599
% plain = DashboardLayout.stripHtmlTags(html) removes all <tag> and </tag>

0 commit comments

Comments
 (0)