mbColorLib: Introduce MaxHue, MaxSaturation and MaxLuminance as new properties of OfficeColorDialog.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5585 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2017-01-02 11:15:19 +00:00
parent c40b7b608c
commit 47c45023ca
3 changed files with 43 additions and 28 deletions

View File

@ -79,6 +79,9 @@ type
ERed, EGreen, EBlue: TSpinEdit; ERed, EGreen, EBlue: TSpinEdit;
EHue, ESat, ELum: TSpinEdit; EHue, ESat, ELum: TSpinEdit;
{$ENDIF} {$ENDIF}
FMaxHue: Integer;
FMaxSat: Integer;
FMaxLum: Integer;
FLockChange: Integer; FLockChange: Integer;
function GetShowHint: Boolean; function GetShowHint: Boolean;
procedure SetAllCustom(c: TColor); procedure SetAllCustom(c: TColor);
@ -87,6 +90,10 @@ type
protected protected
procedure CreateParams(var Params: TCreateParams); override; procedure CreateParams(var Params: TCreateParams); override;
// procedure CreateWnd; override; // procedure CreateWnd; override;
public
property MaxHue: Integer read FMaxHue write FMaxHue;
property MaxSaturation: Integer read FMaxSat write FMaxSat;
property MaxLuminance: Integer read FMaxLum write FMaxLum;
published published
property ShowHint: Boolean read GetShowHint write SetShowHint; property ShowHint: Boolean read GetShowHint write SetShowHint;
end; end;
@ -176,7 +183,7 @@ begin
try try
HSL.Hue := EHue.Value; HSL.Hue := EHue.Value;
SLH.Hue := EHue.Value; SLH.Hue := EHue.Value;
NewSwatch.Color := HSLRangeToRGB(EHue.Value, ESat.Value, ELum.Value); NewSwatch.Color := HSLToRGB(EHue.Value/FMaxHue, ESat.Value/FMaxSat, ELum.Value/FMaxLum);
finally finally
dec(FLockChange); dec(FLockChange);
end; end;
@ -190,7 +197,7 @@ begin
inc(FLockChange); inc(FLockChange);
try try
HSL.Luminance := ELum.Value; HSL.Luminance := ELum.Value;
NewSwatch.Color := HSLRangeToRGB(EHue.Value, ESat.Value, ELum.Value); NewSwatch.Color := HSLToRGB(EHue.Value/FMaxHue, ESat.Value/FMaxSat, ELum.Value/FMaxLum);
finally finally
dec(FLockChange); dec(FLockChange);
end; end;
@ -220,7 +227,7 @@ begin
try try
HSL.Saturation := ESat.Value; HSL.Saturation := ESat.Value;
SLH.Saturation := ESat.Value; SLH.Saturation := ESat.Value;
NewSwatch.Color := HSLRangeToRGB(EHue.Value, ESat.Value, ELum.Value); NewSwatch.Color := HSLToRGB(EHue.Value/FMaxHue, ESat.Value/FMaxSat, ELum.Value/FMaxLum);
finally finally
dec(FLockChange); dec(FLockChange);
end; end;
@ -229,6 +236,22 @@ end;
procedure TOfficeMoreColorsWin.FormCreate(Sender: TObject); procedure TOfficeMoreColorsWin.FormCreate(Sender: TObject);
begin begin
FMaxHue := 359;
FMaxSat := 240;
FMaxLum := 240;
HSL.MaxHue := FMaxHue;
HSL.MaxSaturation := FMaxSat;
HSL.MaxLuminance := FMaxLum;
HSLRing.MaxHue := FMaxHue;
HSLRing.MaxSaturation := FMaxSat;
HSLRing.MaxLuminance := FMaxLum;
SLH.MaxHue := FMaxHue;
SLH.MaxSaturation := FMaxSat;
SLH.MaxLuminance := FMaxLum;
{$IFDEF mbXP_Lib} {$IFDEF mbXP_Lib}
ERed := TmbXPSpinEdit.CreateParented(Custom.Handle); ERed := TmbXPSpinEdit.CreateParented(Custom.Handle);
EGreen := TmbXPSpinEdit.CreateParented(Custom.Handle); EGreen := TmbXPSpinEdit.CreateParented(Custom.Handle);
@ -296,7 +319,7 @@ begin
Top := ERed.Top; Top := ERed.Top;
Alignment := taRightJustify; Alignment := taRightJustify;
Anchors := [akLeft, akBottom]; Anchors := [akLeft, akBottom];
MaxValue := MaxHue; MaxValue := FMaxHue;
MinValue := 0; MinValue := 0;
Value := 0; Value := 0;
OnChange := @EHueChange; OnChange := @EHueChange;
@ -311,7 +334,7 @@ begin
Top := EGreen.Top; Top := EGreen.Top;
Alignment := taRightJustify; Alignment := taRightJustify;
Anchors := [akLeft, akBottom]; Anchors := [akLeft, akBottom];
MaxValue := MaxSat; MaxValue := FMaxSat;
MinValue := 0; MinValue := 0;
Value := 0; Value := 0;
OnChange := @ESatChange; OnChange := @ESatChange;
@ -326,7 +349,7 @@ begin
Top := EBlue.Top; Top := EBlue.Top;
Alignment := taRightJustify; Alignment := taRightJustify;
Anchors := [akLeft, akBottom]; Anchors := [akLeft, akBottom];
MaxValue := MaxLum; MaxValue := FMaxLum;
MinValue := 0; MinValue := 0;
Value := 0; Value := 0;
OnChange := @ELumChange; OnChange := @ELumChange;
@ -445,14 +468,12 @@ var
begin begin
if (ERed = nil) or (EGreen = nil) or (EBlue = nil) or if (ERed = nil) or (EGreen = nil) or (EBlue = nil) or
(EHue = nil) or (ESat = nil) or (ELum = nil) or (EHue = nil) or (ESat = nil) or (ELum = nil) or
(PickerNotebook = nil) or (HSL = nil) or (HSLRing = nil) or (SLH = nil) or (PickerNotebook = nil) or (HSL = nil) or (HSLRing = nil) or (SLH = nil)
(FLockChange > 0)
then then
exit; exit;
NewSwatch.Color := c; NewSwatch.Color := c;
// inc(FLockChange);
r := GetRValue(c); r := GetRValue(c);
g := GetGValue(c); g := GetGValue(c);
b := GetBValue(c); b := GetBValue(c);
@ -483,8 +504,6 @@ begin
EHue.Value := H * HSL.MaxHue; EHue.Value := H * HSL.MaxHue;
ESat.Value := S * HSL.MaxSaturation; ESat.Value := S * HSL.MaxSaturation;
ELum.Value := L * HSL.MaxLuminance; ELum.Value := L * HSL.MaxLuminance;
// dec(FLockChange);
end; end;
procedure TOfficeMoreColorsWin.SetAllToSel(c: TColor); procedure TOfficeMoreColorsWin.SetAllToSel(c: TColor);

View File

@ -330,9 +330,9 @@ end;
// only for internet shortcuts // only for internet shortcuts
procedure TForm1.FormCreate(Sender: TObject); procedure TForm1.FormCreate(Sender: TObject);
begin begin
MaxHue := 360; // MaxHue := 360;
MaxSat := 240; // MaxSat := 240;
MaxLum := 240; // MaxLum := 240;
with TIniFile.Create(ExtractFilePath(Application.ExeName) + '\MXS Website.url') do with TIniFile.Create(ExtractFilePath(Application.ExeName) + '\MXS Website.url') do
try try
WriteString('InternetShortcut','URL', 'http://mxs.bergsoft.net'); WriteString('InternetShortcut','URL', 'http://mxs.bergsoft.net');

View File

@ -14,12 +14,16 @@ type
FWin: TOfficeMoreColorsWin; FWin: TOfficeMoreColorsWin;
FSelColor: TColor; FSelColor: TColor;
FUseHint: boolean; FUseHint: boolean;
FMaxHue, FMaxSat, FMaxLum: Integer;
public public
constructor Create(AOwner: TComponent); override; constructor Create(AOwner: TComponent); override;
function Execute: boolean; overload; function Execute: boolean; overload;
function Execute(AColor: TColor): boolean; overload; function Execute(AColor: TColor): boolean; overload;
published published
property SelectedColor: TColor read FSelColor write FSelColor default clWhite; property SelectedColor: TColor read FSelColor write FSelColor default clWhite;
property MaxHue: Integer read FMaxHue write FMaxHue default 359;
property MaxSaturation: Integer read FMaxSat write FMaxSat default 240;
property MaxLuminance: Integer read FMaxLum write FMaxLum default 240;
property UseHints: boolean read FUseHint write FUseHint default false; property UseHints: boolean read FUseHint write FUseHint default false;
end; end;
@ -32,25 +36,14 @@ begin
inherited; inherited;
FSelColor := clWhite; FSelColor := clWhite;
FUseHint := false; FUseHint := false;
FMaxHue := 359;
FMaxSat := 240;
FMaxLum := 240;
end; end;
function TmbOfficeColorDialog.Execute: boolean; function TmbOfficeColorDialog.Execute: boolean;
begin begin
Result := Execute(FSelColor); Result := Execute(FSelColor);
{
FWin := TOfficeMoreColorsWin.Create(Application);
try
FWin.OldSwatch.Color := FSelColor;
FWin.ShowHint := FUseHint;
Result := (FWin.ShowModal = IdOK);
if Result then
FSelColor := FWin.NewSwatch.Color
else
FSelColor := clNone;
finally
FWin.Free;
end;
}
end; end;
function TmbOfficeColorDialog.Execute(AColor: TColor): boolean; function TmbOfficeColorDialog.Execute(AColor: TColor): boolean;
@ -59,6 +52,9 @@ begin
try try
FWin.OldSwatch.Color := AColor; FWin.OldSwatch.Color := AColor;
FWin.ShowHint := FUseHint; FWin.ShowHint := FUseHint;
FWin.MaxHue := FMaxHue;
FWin.MaxSaturation := FMaxSat;
FWin.MaxLuminance := FMaxLum;
Result := (FWin.ShowModal = IdOK); Result := (FWin.ShowModal = IdOK);
if Result then if Result then
FSelColor := FWin.NewSwatch.Color FSelColor := FWin.NewSwatch.Color