summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGraeme Geldenhuys <graemeg@gmail.com>2013-04-02 11:56:03 +0100
committerDavid Laurence Emerson <dle3ab@angelbase.com>2013-05-28 00:42:50 -0700
commit17ac1344ebb5cf742b2c959596d30732a0bd3a85 (patch)
tree34d5239acea76e12f61c577cada88fa641efc91a
parent74975ef32f9f23319c369c5155508efbd641ec81 (diff)
downloadfpGUI-17ac1344ebb5cf742b2c959596d30732a0bd3a85.tar.xz
Buttons & Styles now support hover effect on standard buttons too.
Before we only had the mouse hover effect on Flat buttons. But now the Style can enable hover support for normal buttons too. Important for Win7 and MacOSX like themes.
-rw-r--r--src/corelib/fpg_main.pas6
-rw-r--r--src/gui/fpg_button.pas12
2 files changed, 15 insertions, 3 deletions
diff --git a/src/corelib/fpg_main.pas b/src/corelib/fpg_main.pas
index f90e6b4c..89c5da1d 100644
--- a/src/corelib/fpg_main.pas
+++ b/src/corelib/fpg_main.pas
@@ -214,6 +214,7 @@ type
procedure DrawButtonFace(ACanvas: TfpgCanvas; r: TfpgRect; AFlags: TfpgButtonFlags); overload;
function GetButtonBorders: TRect; virtual;
function GetButtonShift: TPoint; virtual;
+ function HasButtonHoverEffect: boolean; virtual;
{ Menus }
procedure DrawMenuBar(ACanvas: TfpgCanvas; r: TfpgRect; ABackgroundColor: TfpgColor); virtual;
procedure DrawMenuRow(ACanvas: TfpgCanvas; r: TfpgRect; AFlags: TfpgMenuItemFlags); virtual;
@@ -2340,6 +2341,11 @@ begin
Result := Point(1, 1);
end;
+function TfpgStyle.HasButtonHoverEffect: boolean;
+begin
+ Result := False;
+end;
+
function TfpgStyle.GetControlFrameBorders: TRect;
begin
Result := Rect(2, 2, 2, 2);
diff --git a/src/gui/fpg_button.pas b/src/gui/fpg_button.pas
index 28db95d6..3bc026de 100644
--- a/src/gui/fpg_button.pas
+++ b/src/gui/fpg_button.pas
@@ -550,6 +550,12 @@ begin
Include(lBtnFlags, btfHover)
else if FFlat then
Include(lBtnFlags, btfFlat);
+
+ if (not FFlat) and (not FDown) and fpgStyle.HasButtonHoverEffect then
+ begin
+ if FState = 1 then
+ Include(lBtnFlags, btfHover);
+ end;
end
else
begin
@@ -558,7 +564,7 @@ begin
Include(lBtnFlags, btfHover);
end;
- if not FFlat and FDefault then
+ if (not FFlat) and FDefault then
Include(lBtnFlags, btfIsDefault);
if FBackgroundColor <> clButtonFace then
@@ -747,7 +753,7 @@ begin
FDown := False;
Repaint;
end
- else if FFlat then
+ else if FFlat or fpgStyle.HasButtonHoverEffect then
begin
if Enabled then
Repaint;
@@ -766,7 +772,7 @@ begin
FDown := True;
Repaint;
end
- else if FFlat then
+ else if FFlat or fpgStyle.HasButtonHoverEffect then
begin
if Enabled then
Repaint;