mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-06 00:58:04 +02:00
lcl: themes: add TThemeOption.toUseGlyphEffects. Use it for TToolButton, TSpeedButton, TBitBtn, TButtonGlyph
git-svn-id: trunk@50962 -
This commit is contained in:
parent
f838770236
commit
b769322f40
@ -2059,7 +2059,8 @@ type
|
||||
procedure Click; override;
|
||||
procedure ArrowClick; virtual;
|
||||
procedure GetCurrentIcon(var ImageList: TCustomImageList;
|
||||
var TheIndex: integer); virtual;
|
||||
var TheIndex: integer;
|
||||
var TheEffect: TGraphicsDrawEffect); virtual;
|
||||
procedure GetPreferredSize(var PreferredWidth, PreferredHeight: integer;
|
||||
Raw: boolean = false;
|
||||
WithThemeSpace: boolean = true); override;
|
||||
|
@ -88,9 +88,11 @@ procedure TButtonGlyph.GetImageIndexAndEffect(State: TButtonState;
|
||||
out AIndex: Integer; out AEffect: TGraphicsDrawEffect);
|
||||
var
|
||||
AStoredState: TButtonState;
|
||||
AUseAutoEffects: Integer;
|
||||
begin
|
||||
AStoredState := bsUp;
|
||||
AEffect := gdeNormal;
|
||||
AUseAutoEffects := ThemeServices.GetOption(toUseGlyphEffects);
|
||||
case State of
|
||||
bsDisabled:
|
||||
if NumGlyphs > 1 then
|
||||
@ -99,13 +101,17 @@ begin
|
||||
AEffect := gdeDisabled;
|
||||
bsDown:
|
||||
if NumGlyphs > 2 then
|
||||
AStoredState := State;
|
||||
AStoredState := State
|
||||
else if AUseAutoEffects > 0 then
|
||||
AEffect := gdeShadowed;
|
||||
bsExclusive:
|
||||
if NumGlyphs > 3 then
|
||||
AStoredState := State;
|
||||
bsHot:
|
||||
if NumGlyphs > 4 then
|
||||
AStoredState := State
|
||||
else if AUseAutoEffects > 0 then
|
||||
AEffect := gdeHighlighted;
|
||||
end;
|
||||
AIndex := FImageIndexes[AStoredState];
|
||||
end;
|
||||
|
@ -295,6 +295,7 @@ var
|
||||
ImgList: TCustomImageList;
|
||||
ImgIndex: integer;
|
||||
Details, TempDetails: TThemedElementDetails;
|
||||
ImgEffect: TGraphicsDrawEffect;
|
||||
begin
|
||||
if (FToolBar<>nil) and (ClientWidth>0) and (ClientHeight>0) then
|
||||
begin
|
||||
@ -348,7 +349,7 @@ begin
|
||||
|
||||
// calculate icon size
|
||||
IconSize := Point(0,0);
|
||||
GetCurrentIcon(ImgList, ImgIndex);
|
||||
GetCurrentIcon(ImgList, ImgIndex, ImgEffect);
|
||||
if (ImgList<>nil) then
|
||||
begin
|
||||
IconSize := Point(ImgList.Width, ImgList.Height);
|
||||
@ -433,7 +434,7 @@ begin
|
||||
|
||||
// draw icon
|
||||
if (ImgList<>nil) then
|
||||
ImgList.Draw(Canvas, IconPos.X, IconPos.Y, ImgIndex, Enabled);
|
||||
ImgList.Draw(Canvas, IconPos.X, IconPos.Y, ImgIndex, ImgEffect);
|
||||
|
||||
// draw text
|
||||
if (TextSize.cx > 0) then
|
||||
@ -896,32 +897,43 @@ begin
|
||||
end;
|
||||
|
||||
procedure TToolButton.GetCurrentIcon(var ImageList: TCustomImageList;
|
||||
var TheIndex: integer);
|
||||
var TheIndex: integer; var TheEffect: TGraphicsDrawEffect);
|
||||
var
|
||||
UseAutoEffects: Integer;
|
||||
begin
|
||||
ImageList := nil;
|
||||
TheIndex := -1;
|
||||
TheEffect := gdeNormal;
|
||||
UseAutoEffects := ThemeServices.GetOption(toUseGlyphEffects);
|
||||
if (ImageIndex < 0) or (FToolBar = nil) then Exit;
|
||||
|
||||
if Style in [tbsButton, tbsDropDown, tbsButtonDrop, tbsCheck] then
|
||||
begin
|
||||
TheIndex := ImageIndex;
|
||||
if Enabled and FMouseInControl then
|
||||
// if mouse over button then use HotImages
|
||||
ImageList := FToolBar.HotImages
|
||||
else
|
||||
if not Enabled then
|
||||
// if button disabled then use HotImages
|
||||
ImageList := FToolBar.DisabledImages;
|
||||
if (ImageList = nil) or (ImageList.Count <= ImageIndex) then
|
||||
ImageList := FToolBar.Images;
|
||||
if (FToolButtonFlags*[tbfPressed,tbfArrowPressed] = [tbfPressed]) then
|
||||
begin
|
||||
// if no special icon available, then try the default Images
|
||||
ImageList := FToolBar.Images;
|
||||
if (ImageList = nil) or (ImageList.Count <= ImageIndex) then
|
||||
begin
|
||||
// no icon available
|
||||
ImageList := nil;
|
||||
TheIndex := -1;
|
||||
end;
|
||||
// if button pressed then use PressedImages // Maybe To-Do ?
|
||||
{if (FToolBar.PressedImages <> nil) and (ImageIndex < FToolBar.PressedImages.Count) then
|
||||
ImageList := FToolBar.DisabledImages
|
||||
else} if UseAutoEffects > 0 then
|
||||
TheEffect := gdeShadowed;
|
||||
end else
|
||||
if Enabled and FMouseInControl then
|
||||
begin
|
||||
// if mouse over button then use HotImages
|
||||
if (FToolBar.HotImages <> nil) and (ImageIndex < FToolBar.HotImages.Count) then
|
||||
ImageList := FToolBar.HotImages
|
||||
else if UseAutoEffects > 0 then
|
||||
TheEffect := gdeHighlighted;
|
||||
end else
|
||||
if not Enabled then
|
||||
begin
|
||||
// if button disabled then use DisabledImages
|
||||
if (FToolBar.DisabledImages <> nil) and (ImageIndex < FToolBar.DisabledImages.Count) then
|
||||
ImageList := FToolBar.DisabledImages
|
||||
else
|
||||
TheEffect := gdeDisabled;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
@ -1089,6 +1101,7 @@ var
|
||||
IconPos: TPoint;
|
||||
ImgList: TCustomImageList;
|
||||
ImgIndex: integer;
|
||||
ImgEffect: TGraphicsDrawEffect;
|
||||
begin
|
||||
if Assigned(FToolBar) then
|
||||
begin
|
||||
@ -1116,7 +1129,7 @@ begin
|
||||
IconSize := Point(0, 0);
|
||||
if (Style in [tbsButton, tbsDropDown, tbsButtonDrop, tbsCheck]) then
|
||||
begin
|
||||
GetCurrentIcon(ImgList, ImgIndex);
|
||||
GetCurrentIcon(ImgList, ImgIndex, ImgEffect);
|
||||
if Assigned(ImgList) then
|
||||
begin
|
||||
IconSize := Point(ImgList.Width, ImgList.Height);
|
||||
|
@ -419,8 +419,8 @@ begin
|
||||
ButtonImageList.margin.top := 5;
|
||||
ButtonImageList.margin.bottom := 5;
|
||||
ButtonImageList.uAlign := BUTTON_IMAGELIST_ALIGN_CENTER;
|
||||
// if themes are not enabled then we need to fill only one state bitmap, else
|
||||
// fill all bitmas
|
||||
// if themes are enabled then we need to fill all state bitmaps,
|
||||
// else fill only current state bitmap
|
||||
if ThemeServices.ThemesEnabled then
|
||||
begin
|
||||
for I := 1 to 6 do
|
||||
|
@ -414,7 +414,8 @@ type
|
||||
|
||||
TThemeOption = (
|
||||
toShowButtonImages, // show images on buttons
|
||||
toShowMenuImages // show images on menus
|
||||
toShowMenuImages, // show images on menus
|
||||
toUseGlyphEffects // use hot/down effects on (button) glyphs
|
||||
);
|
||||
|
||||
// TThemeServices is a small foot print class to provide the user with pure
|
||||
@ -1914,6 +1915,17 @@ begin
|
||||
case AOption of
|
||||
toShowButtonImages: Result := 1;
|
||||
toShowMenuImages: Result := 1;
|
||||
toUseGlyphEffects:
|
||||
begin
|
||||
// toUseGlyphEffects seems to be OS-dependent.
|
||||
// Linux: yes
|
||||
// Win, OSX: no
|
||||
{$IFDEF LINUX}
|
||||
Result := 1;
|
||||
{$ELSE}
|
||||
Result := 0;
|
||||
{$ENDIF}
|
||||
end;
|
||||
else
|
||||
Result := 0;
|
||||
end;
|
||||
|
Loading…
Reference in New Issue
Block a user