MenuEditor: Better visibility of AddButtons, especially on GTK2.

git-svn-id: trunk@55390 -
This commit is contained in:
michl 2017-06-23 22:01:41 +00:00
parent 9b325e675c
commit a408181660
2 changed files with 32 additions and 14 deletions

View File

@ -10,7 +10,8 @@ uses
ActnList, Controls, Dialogs, StdCtrls, ExtCtrls, Menus, ActnList, Controls, Dialogs, StdCtrls, ExtCtrls, Menus,
Forms, Graphics, ImgList, Themes, LCLType, LCLIntf, LCLProc, Forms, Graphics, ImgList, Themes, LCLType, LCLIntf, LCLProc,
// IdeIntf // IdeIntf
FormEditingIntf, IDEWindowIntf, ComponentEditors, IDEDialogs, PropEdits, FormEditingIntf, IDEWindowIntf, IDEImagesIntf, ComponentEditors, IDEDialogs,
PropEdits,
// IDE // IDE
LazarusIDEStrConsts, LazIDEIntf, MenuDesignerBase, MenuEditorForm, MenuShortcutDisplay, LazarusIDEStrConsts, LazIDEIntf, MenuDesignerBase, MenuEditorForm, MenuShortcutDisplay,
MenuTemplates, MenuResolveConflicts; MenuTemplates, MenuResolveConflicts;
@ -545,7 +546,7 @@ begin
selShadow.ShowingBottomFake:=False; selShadow.ShowingBottomFake:=False;
end end
else begin else begin
w:=selShadow.ParentBox.Width - Gutter_X; w:=selShadow.ParentBox.Width - Gutter_X - 1;
if (FMinWidth > w) then if (FMinWidth > w) then
w:=FMinWidth; w:=FMinWidth;
SetBounds(selShadow.ParentBox.Left + selShadow.Left + Gutter_X, SetBounds(selShadow.ParentBox.Left + selShadow.Left + Gutter_X,
@ -569,9 +570,9 @@ begin
SetInitialBounds(0, 0, cx, cy); SetInitialBounds(0, 0, cx, cy);
BorderStyle:=bsNone; BorderStyle:=bsNone;
Visible:=False; Visible:=False;
Canvas.Pen.Color:=clBtnShadow; Canvas.Pen.Color:=clBtnText;
Canvas.Pen.Style:=psDot; Canvas.Pen.Style:=psDot;
Canvas.Font.Color:=clBtnShadow; Canvas.Font.Color:=clBtnText;
Canvas.Brush.Color:=clBtnFace; Canvas.Brush.Color:=clBtnFace;
Parent:=anOwner; Parent:=anOwner;
end; end;
@ -584,18 +585,31 @@ end;
procedure TFake.Paint; procedure TFake.Paint;
var var
r: TRect; r, TextRect: TRect;
sz: TSize; TextSize: TSize;
y: integer; TextPoint, AddBmpPoint: TPoint;
AddBmp: TCustomBitmap;
begin begin
r:=ClientRect; r:=ClientRect;
Canvas.FillRect(r); Canvas.FillRect(r);
Canvas.RoundRect(r, 3, 3); Canvas.RoundRect(r, 3, 3);
sz:=Canvas.TextExtent(Caption); try
y:=(r.Bottom - r.Top - sz.cy) div 2; AddBmp:=TIDEImages.CreateImage('laz_add');
if (y < 2) then TextSize:=Canvas.TextExtent(Caption);
y:=2; TextPoint.y:=(r.Bottom - r.Top - TextSize.cy) div 2;
Canvas.TextOut((r.Right - r.Left - sz.cx) div 2, y, Caption); if (TextPoint.y < 1) then
TextPoint.y:=1;
TextPoint.x:=(r.Right - r.Left - TextSize.cx + AddBmp.Width) div 2;
TextRect := ClientRect;
InflateRect(TextRect, 1, 1);
Canvas.TextRect(TextRect, TextPoint.x, TextPoint.y, Caption);
AddBmpPoint.x:=(TextPoint.x - AddBmp.Width) div 2;
AddBmpPoint.y:=(r.Bottom - r.Top - AddBmp.Height) div 2;
Canvas.Draw(AddBmpPoint.x, AddBmpPoint.y, AddBmp);
finally
AddBmp.Free;
end;
end; end;
procedure TFake.Refresh; procedure TFake.Refresh;
@ -606,7 +620,9 @@ end;
procedure TFake.TextChanged; procedure TFake.TextChanged;
begin begin
inherited TextChanged; inherited TextChanged;
FMinWidth:=FShadowMenu.GetStringWidth(Caption, False) + Double_MenuBar_Text_Offset; FMinWidth:=FShadowMenu.GetStringWidth(Caption, False) +
Double_MenuBar_Text_Offset +
Add_Icon_Width;
end; end;
{ TShadowMenu } { TShadowMenu }
@ -2088,7 +2104,7 @@ begin
if FRealItem.IsInMenuBar then if FRealItem.IsInMenuBar then
Result:=w + Double_MenuBar_Text_Offset + FShadowMenu.GetMenuBarIconWidth(FRealItem) Result:=w + Double_MenuBar_Text_Offset + FShadowMenu.GetMenuBarIconWidth(FRealItem)
else else
Result:=w + Double_DropDown_Text_Offset + GetShortcutWidth; Result:=w + Double_DropDown_Text_Offset + GetShortcutWidth + Add_Icon_Width;
end; end;
function TShadowItem.HasChildBox(out aChildBox: TShadowBoxBase): boolean; function TShadowItem.HasChildBox(out aChildBox: TShadowBoxBase): boolean;

View File

@ -161,6 +161,7 @@ var
Double_DropDown_Text_Offset: Integer = 70; Double_DropDown_Text_Offset: Integer = 70;
Gutter_Offset: Integer = 6; Gutter_Offset: Integer = 6;
Gutter_X: Integer = 29; Gutter_X: Integer = 29;
Add_Icon_Width: Integer = 16;
implementation implementation
@ -284,6 +285,7 @@ begin
Double_DropDown_Text_Offset := DropDown_Text_Offset shl 1; Double_DropDown_Text_Offset := DropDown_Text_Offset shl 1;
Gutter_Offset := ScaleX(6, 96); Gutter_Offset := ScaleX(6, 96);
Gutter_X := DropDown_Text_Offset - Gutter_Offset; Gutter_X := DropDown_Text_Offset - Gutter_Offset;
Add_Icon_Width := ScaleX(16, 96);
end; end;
{ TMenuTemplate } { TMenuTemplate }