mbColorLib: All HSV/HSL controls have a property for MaxHue/MaxSaturation/MaxValue (MaxLuminance). Some refactoring avoiding duplicate storage of H, S, L (V) in the complex pickers.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5540 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2016-12-19 16:38:29 +00:00
parent d42ba252f3
commit c75b85e42a
30 changed files with 1399 additions and 803 deletions

View File

@@ -9,7 +9,9 @@
<Title Value="Demo"/>
<ResourceType Value="res"/>
<UseXPManifest Value="True"/>
<Icon Value="0"/>
<XPManifest>
<DpiAware Value="True"/>
</XPManifest>
</General>
<BuildModes Count="1">
<Item1 Name="Default" Default="True"/>
@@ -56,8 +58,14 @@
</SearchPaths>
<Linking>
<Debugging>
<UseHeaptrc Value="True"/>
<UseExternalDbgSyms Value="True"/>
</Debugging>
<Options>
<Win32>
<GraphicApplication Value="True"/>
</Win32>
</Options>
</Linking>
</CompilerOptions>
<Debugging>

View File

@@ -10,6 +10,7 @@ object Form1: TForm1
OnCreate = FormCreate
ShowHint = True
LCLVersion = '1.7'
Scaled = True
object Label1: TLabel
Left = 416
Height = 15
@@ -42,9 +43,9 @@ object Form1: TForm1
Height = 384
Top = 6
Width = 403
ActivePage = TabSheet3
ActivePage = TabSheet1
Anchors = [akTop, akLeft, akRight, akBottom]
TabIndex = 2
TabIndex = 0
TabOrder = 0
OnChange = PageControl1Change
OnMouseMove = PageControl1MouseMove
@@ -57,7 +58,7 @@ object Form1: TForm1
Height = 340
Top = 8
Width = 381
SelectedColor = 1024
SelectedColor = 3289805
HSPickerHintFormat = 'H: %h S: %s'#13'Hex: #%hex'
LPickerHintFormat = 'Luminance: %l'
Anchors = [akTop, akLeft, akRight, akBottom]
@@ -600,6 +601,9 @@ object Form1: TForm1
Anchors = [akTop, akLeft, akRight, akBottom]
TabOrder = 0
OnMouseMove = HSVColorPicker1MouseMove
Hue = 0
Saturation = 0
Value = 255
OnChange = HSVColorPicker1Change
end
object VColorPicker2: TVColorPicker
@@ -613,6 +617,9 @@ object Form1: TForm1
Anchors = [akTop, akRight, akBottom]
TabOrder = 1
OnChange = VColorPicker2Change
Hue = 0
Saturation = 0
Value = 255
SelectedColor = clWhite
end
end
@@ -712,9 +719,10 @@ object Form1: TForm1
SelectionIndicator = siRect
Anchors = [akLeft, akRight, akBottom]
TabOrder = 2
Saturation = 238
Luminance = 60
SelectedColor = 263284
Hue = 0
Saturation = 51
Luminance = 240
SelectedColor = clWhite
end
object VColorPicker1: TVColorPicker
Left = 34
@@ -727,7 +735,7 @@ object Form1: TForm1
SelectionIndicator = siRect
Anchors = [akLeft, akRight, akBottom]
TabOrder = 3
Hue = 240
Hue = 239
Saturation = 255
Value = 40
SelectedColor = 2621440
@@ -744,7 +752,9 @@ object Form1: TForm1
Anchors = [akLeft, akRight, akBottom]
TabOrder = 4
OnGetHintStr = HColorPicker1GetHintStr
Hue = 0
Saturation = 120
Value = 255
SelectedColor = 8882175
end
object SColorPicker1: TSColorPicker
@@ -761,6 +771,7 @@ object Form1: TForm1
TabOrder = 5
Hue = 60
Saturation = 80
Value = 255
SelectedColor = 11534335
end
object Memo1: TMemo
@@ -820,11 +831,11 @@ object Form1: TForm1
Height = 155
Top = 6
Width = 211
SelectedColor = 518633
SelectedColor = 15797774
HintFormat = 'H: %h S: %s'#13'Hex: %hex'
TabOrder = 0
OnMouseMove = HSColorPicker1MouseMove
HueValue = 60
Luminance = 120
MarkerStyle = msSquare
OnChange = HSColorPicker1Change
end
@@ -833,9 +844,13 @@ object Form1: TForm1
Height = 147
Top = 144
Width = 161
SelectedColor = 2763306
HintFormat = 'H: %h S: %s L: %l'#13'Hex: %hex'
TabOrder = 1
OnMouseMove = SLColorPicker1MouseMove
Hue = 0
Saturation = 0
Luminance = 100
MarkerStyle = msCross
OnChange = SLColorPicker1Change
end
@@ -847,6 +862,9 @@ object Form1: TForm1
HintFormat = 'Hue: %h (selected)'
TabOrder = 2
OnMouseMove = HRingPicker1MouseMove
Hue = 0
Saturation = 255
Value = 255
OnChange = HRingPicker1Change
end
end

View File

@@ -9,10 +9,6 @@
<Title Value="Demo"/>
<ResourceType Value="res"/>
<UseXPManifest Value="True"/>
<XPManifest>
<TextName Value="CompanyName.ProductName.AppName"/>
<TextDesc Value="Your application description."/>
</XPManifest>
<Icon Value="0"/>
</General>
<BuildModes Count="1">

View File

@@ -184,6 +184,9 @@ object Form1: TForm1
Visible = False
TabOrder = 5
OnChange = SLVPickerV_Change
Hue = 0
Saturation = 0
Value = 255
SelectedColor = clWhite
end
object LColorPickerV: TLColorPicker
@@ -196,9 +199,10 @@ object Form1: TForm1
Anchors = [akTop, akLeft, akBottom]
TabOrder = 6
OnChange = SLVPickerV_Change
Saturation = 255
Luminance = 127
SelectedColor = 254
Hue = 0
Saturation = 240
Luminance = 239
SelectedColor = 16645631
end
object HColorPickerV: THColorPicker
Left = 288
@@ -210,6 +214,9 @@ object Form1: TForm1
Anchors = [akTop, akLeft, akBottom]
TabOrder = 7
OnChange = HPickerV_Change
Hue = 0
Saturation = 255
Value = 255
end
object KColorPickerV: TKColorPicker
Left = 232
@@ -305,6 +312,9 @@ object Form1: TForm1
Anchors = [akTop, akLeft, akBottom]
TabOrder = 15
OnChange = SLVPickerV_Change
Hue = 0
Saturation = 255
Value = 255
end
end
end
@@ -471,6 +481,9 @@ object Form1: TForm1
Visible = False
TabOrder = 5
OnChange = SLVPickerH_Change
Hue = 0
Saturation = 0
Value = 255
SelectedColor = clWhite
end
object LColorPickerH: TLColorPicker
@@ -483,9 +496,10 @@ object Form1: TForm1
Anchors = [akTop, akLeft, akRight]
TabOrder = 6
OnChange = SLVPickerH_Change
Saturation = 255
Luminance = 127
SelectedColor = 254
Hue = 0
Saturation = 240
Luminance = 239
SelectedColor = 16645631
end
object SColorPickerH: TSColorPicker
Left = 24
@@ -497,6 +511,9 @@ object Form1: TForm1
Anchors = [akTop, akLeft, akRight]
TabOrder = 7
OnChange = SLVPickerH_Change
Hue = 0
Saturation = 255
Value = 255
end
object HColorPickerH: THColorPicker
Left = 24
@@ -508,6 +525,9 @@ object Form1: TForm1
Anchors = [akTop, akLeft, akRight]
TabOrder = 8
OnChange = HPickerH_Change
Hue = 0
Saturation = 255
Value = 255
end
object KColorPickerH: TKColorPicker
Left = 24

View File

@@ -112,7 +112,7 @@ begin
if (CColorPickerH = nil) or (YColorPickerH = nil) or (MColorPickerH = nil) or
(KColorPickerH = nil) or (CMYKh = nil) then
exit;
CMYKh.Color := CMYKToTColor(
CMYKh.Color := CMYKToColor(
CColorPickerH.Cyan,
MColorPickerH.Magenta,
YColorPickerH.Yellow,
@@ -136,7 +136,7 @@ begin
if (CColorPickerV = nil) or (YColorPickerV = nil) or (MColorPickerV = nil) or
(KColorPickerV = nil) or (CMYKv = nil) then
exit;
CMYKv.Color := CMYKToTColor(
CMYKv.Color := CMYKToColor(
CColorPickerV.Cyan,
MColorPickerV.Magenta,
YColorPickerV.Yellow,
@@ -156,6 +156,10 @@ end;
procedure TForm1.FormCreate(Sender: TObject);
begin
MaxHue := 359;
MaxSat := 240;
MaxLum := 240;
VColorPickerH.Left := LColorPickerH.Left;
VColorPickerH.Top := LColorPickerH.Top;
VColorPickerH.Width := LColorPickerH.Width;
@@ -279,14 +283,12 @@ begin
if rbHSLh.Checked then begin
if (LColorPickerH = nil) then
exit;
triple := HSLToRGBTriple(HColorPickerH.Hue, SColorPickerH.Saturation, LColorPickerH.Luminance);
HSLVh.Color := RGBTripleToTColor(triple);
// HSLVh.Color := HSLRangetoRGB(HColorPickerH.Hue, SColorPickerH.Saturation, LColorPickerH.Luminance);
HSLVh.Color := HSLRangeToRGB(HColorPickerH.Hue, SColorPickerH.Saturation, LColorPickerH.Luminance);
end;
if rbHSVh.Checked then begin
if (VColorPickerH = nil) then
exit;
HSLVh.Color := HSVtoColor(HColorPickerH.Hue, SColorPickerH.Saturation, VColorPickerH.Value);
HSLVh.Color := HSVRangetoColor(HColorPickerH.Hue, SColorPickerH.Saturation, VColorPickerH.Value);
end;
c := HSLVh.Color;
@@ -310,7 +312,7 @@ begin
if (LColorPickerV = nil) then
exit;
triple := HSLToRGBTriple(HColorPickerV.Hue, SColorPickerV.Saturation, LColorPickerV.Luminance);
HSLVv.Color := RGBTripleToTColor(triple);
HSLVv.Color := RGBTripleToColor(triple);
end;
if rbHSVv.Checked then begin
if (VColorPickerV = nil) then