spktoolbar: Replace themed painting of dropdown arrows by self-painted triangles (better control of color of the dropdown button).

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@6163 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz 2018-02-01 08:44:57 +00:00
parent dcc90b77e4
commit c5b3e83d2a
2 changed files with 12 additions and 32 deletions

View File

@ -203,7 +203,7 @@ type
implementation implementation
uses uses
LCLType, LCLIntf, LCLProc, SysUtils, Themes, LCLType, LCLIntf, LCLProc, SysUtils,
spkt_Pane, spkt_Appearance; spkt_Pane, spkt_Appearance;
@ -384,30 +384,19 @@ const
w = 8; w = 8;
h = 8; h = 8;
var var
details: TThemedElementDetails;
arrowState: TThemedToolBar;
P: array[0..3] of TPoint; P: array[0..3] of TPoint;
wsc, hsc: Integer; wsc, hsc: Integer;
begin begin
if ThemeServices.ThemesEnabled then begin wsc := ScaleX(w, DesignDPI); // 0 1
if Enabled then hsc := ScaleY(h, DesignDPI); // 2
arrowState := ttbSplitButtonDropdownNormal P[2].x := ARect.Left + (ARect.Right - ARect.Left) div 2;
else P[2].y := ARect.Top + (ARect.Bottom - ARect.Top + hsc) div 2 - 1;
arrowState := ttbSplitButtonDropDownDisabled; P[0] := Point(P[2].x - wsc div 2, P[2].y - hsc div 2);
details := ThemeServices.GetElementDetails(arrowState); P[1] := Point(P[2].x + wsc div 2, P[0].y);
ThemeServices.DrawElement(ABuffer.Canvas.Handle, details, ARect); P[3] := P[0];
end else begin ABuffer.Canvas.Brush.Color := AColor;
wsc := ScaleX(w, DesignDPI); // 0 1 ABuffer.Canvas.Pen.Style := psClear;
hsc := ScaleY(h, DesignDPI); // 2 ABuffer.Canvas.Polygon(P);
P[2].x := ARect.Left + (ARect.Right - ARect.Left) div 2;
P[2].y := ARect.Top + (ARect.Bottom - ARect.Top + hsc) div 2 - 1;
P[0] := Point(P[2].x - wsc div 2, P[2].y - hsc div 2);
P[1] := Point(P[2].x + wsc div 2, P[0].y);
P[3] := P[0];
ABuffer.Canvas.Brush.Color := AColor;
ABuffer.Canvas.Pen.Style := psClear;
ABuffer.Canvas.Polygon(P);
end;
end; end;
function TSpkBaseButton.GetAction: TBasicAction; function TSpkBaseButton.GetAction: TBasicAction;

View File

@ -271,12 +271,9 @@ var
implementation implementation
uses uses
LCLType, Types, Themes; LCLType, Types;
procedure SpkInitLayoutConsts(FromDPI: Integer; ToDPI: Integer = 0); procedure SpkInitLayoutConsts(FromDPI: Integer; ToDPI: Integer = 0);
var
detail: TThemedElementDetails;
detailSize: TSize;
begin begin
if not DPI_AWARE then if not DPI_AWARE then
ToDPI := FromDPI; ToDPI := FromDPI;
@ -303,12 +300,6 @@ begin
SmallButtonRadius := SMALLBUTTON_RADIUS; SmallButtonRadius := SMALLBUTTON_RADIUS;
SmallButtonMinWidth := 2 * SmallButtonPadding + SmallButtonGlyphWidth; SmallButtonMinWidth := 2 * SmallButtonPadding + SmallButtonGlyphWidth;
// Make sure that dropdown button is not too narrow
detail := ThemeServices.GetElementDetails(ttbSplitButtonDropDownNormal);
detailsize := ThemeServices.GetDetailSize(detail);
if SmallButtonDropdownWidth < detailSize.CX then
SmallButtondropdownWidth := detailSize.CX;
MaxElementHeight := SpkScaleY(MAX_ELEMENT_HEIGHT, FromDPI, ToDPI); MaxElementHeight := SpkScaleY(MAX_ELEMENT_HEIGHT, FromDPI, ToDPI);
PaneRowHeight := SpkScaleY(PANE_ROW_HEIGHT, FromDPI, ToDPI); PaneRowHeight := SpkScaleY(PANE_ROW_HEIGHT, FromDPI, ToDPI);
PaneFullRowHeight := 3 * PaneRowHeight; PaneFullRowHeight := 3 * PaneRowHeight;