diff options
author | Graeme Geldenhuys <graeme@mastermaths.co.za> | 2009-09-28 13:23:05 +0200 |
---|---|---|
committer | Graeme Geldenhuys <graeme@mastermaths.co.za> | 2009-09-28 13:23:05 +0200 |
commit | eae602aefa0e2e79cfe1a5153d6d078c07d0a693 (patch) | |
tree | 5dc106db888e89073fb989f50016f27f080cce58 /src | |
parent | 6cf34388760e1cfb1886d78ac2a294c57d28564f (diff) | |
download | fpGUI-eae602aefa0e2e79cfe1a5153d6d078c07d0a693.tar.xz |
Bugfix: If BackgroundColor and cached colorwheel image.
If the background color was changed at runtime, the cached colorwheel
image never knew about it. So the margin color was changed, but the
color around the colorwheel was not.
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/fpg_colorwheel.pas | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/gui/fpg_colorwheel.pas b/src/gui/fpg_colorwheel.pas index ad14d6a6..ed90dc79 100644 --- a/src/gui/fpg_colorwheel.pas +++ b/src/gui/fpg_colorwheel.pas @@ -39,12 +39,14 @@ type FWhiteAreaPercent: longint; // 0 to 50 percent of circle radius that is pure white FOnChange: TNotifyEvent; FImage: TfpgImage; // cached colorwheel image + FRecalcWheel: Boolean; // should chached FImage be recalculated procedure HSFromPoint(X, Y: longint; out H: longint; out S: double); procedure DrawCursor; procedure SetMarginWidth(NewWidth: longint); procedure SetCursorSize(NewSize: longint); procedure SetValueBar(AValueBar: TfpgValueBar); procedure SetWhiteAreaPercent(WhiteAreaPercent: longint); + procedure SetBackgroundColor(const AValue: TfpgColor); override; procedure Notification(AComponent: TComponent; Operation: TOperation); override; function DrawWidth: longint; function DrawHeight: longint; @@ -204,9 +206,11 @@ begin Exit; //==> end; - if FImage = nil then + if (FImage = nil) or FRecalcWheel then begin - // we must only do this once, because it's very slow + // we must only do this when needed, because it's very slow + if FImage <> nil then + FImage.Free; FImage := TfpgImage.Create; FImage.AllocateImage(32, DrawWidth, DrawHeight); FImage.UpdateImage; @@ -229,6 +233,7 @@ begin FImage.Colors[x, y] := fpgColorToRGB(BackgroundColor); end; end; + FRecalcWheel := False; end else begin @@ -281,6 +286,7 @@ begin Height := 100; Name := 'ColorWheel'; FWhiteAreaPercent := 10; + FRecalcWheel := True; end; destructor TfpgColorWheel.Destroy; @@ -379,6 +385,12 @@ begin Invalidate; end; +procedure TfpgColorWheel.SetBackgroundColor(const AValue: TfpgColor); +begin + FRecalcWheel := True; + inherited SetBackgroundColor(AValue); +end; + procedure TfpgColorWheel.Notification(AComponent: TComponent; Operation: TOperation); begin inherited Notification(AComponent, Operation); |