You've already forked lazarus-ccr
mbColorLib: Refactor OnChange events. (NOTE: OfficeColorDialog may hang when switching pickers).
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5578 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@@ -9,7 +9,6 @@
|
||||
<Title Value="axispickers"/>
|
||||
<ResourceType Value="res"/>
|
||||
<UseXPManifest Value="True"/>
|
||||
<Icon Value="0"/>
|
||||
</General>
|
||||
<BuildModes Count="1">
|
||||
<Item1 Name="Default" Default="True"/>
|
||||
|
@@ -10,35 +10,39 @@ object Form1: TForm1
|
||||
LCLVersion = '1.7'
|
||||
object PageControl1: TPageControl
|
||||
Left = 4
|
||||
Height = 442
|
||||
Height = 420
|
||||
Top = 4
|
||||
Width = 508
|
||||
ActivePage = PgRED
|
||||
Align = alClient
|
||||
BorderSpacing.Around = 4
|
||||
BorderSpacing.Left = 4
|
||||
BorderSpacing.Top = 4
|
||||
BorderSpacing.Right = 4
|
||||
TabIndex = 0
|
||||
TabOrder = 0
|
||||
OnChange = PageControl1Change
|
||||
object PgRED: TTabSheet
|
||||
Caption = 'Picker based on RED'
|
||||
ClientHeight = 414
|
||||
ClientHeight = 392
|
||||
ClientWidth = 500
|
||||
object PanelRED: TPanel
|
||||
Left = 0
|
||||
Height = 414
|
||||
Height = 392
|
||||
Top = 0
|
||||
Width = 500
|
||||
Align = alClient
|
||||
BevelOuter = bvNone
|
||||
ClientHeight = 414
|
||||
ClientHeight = 392
|
||||
ClientWidth = 500
|
||||
TabOrder = 0
|
||||
OnPaint = PanelREDPaint
|
||||
object RColorPicker1: TRColorPicker
|
||||
Left = 24
|
||||
Height = 390
|
||||
Height = 368
|
||||
Top = 0
|
||||
Width = 22
|
||||
HintFormat = 'Red: %value (selected)'
|
||||
SelectionIndicator = siRect
|
||||
Align = alLeft
|
||||
BorderSpacing.Left = 24
|
||||
BorderSpacing.Bottom = 24
|
||||
@@ -48,7 +52,7 @@ object Form1: TForm1
|
||||
end
|
||||
object RAxisColorPicker1: TRAxisColorPicker
|
||||
Left = 76
|
||||
Height = 378
|
||||
Height = 356
|
||||
Top = 6
|
||||
Width = 418
|
||||
HintFormat = 'G: %g B: %b'#13'Hex: %hex'
|
||||
@@ -64,22 +68,22 @@ object Form1: TForm1
|
||||
end
|
||||
object PgGREEN: TTabSheet
|
||||
Caption = 'Picker based on GREEN'
|
||||
ClientHeight = 414
|
||||
ClientHeight = 392
|
||||
ClientWidth = 500
|
||||
object PanelGREEN: TPanel
|
||||
Left = 0
|
||||
Height = 414
|
||||
Height = 392
|
||||
Top = 0
|
||||
Width = 500
|
||||
Align = alClient
|
||||
BevelOuter = bvNone
|
||||
ClientHeight = 414
|
||||
ClientHeight = 392
|
||||
ClientWidth = 500
|
||||
TabOrder = 0
|
||||
OnPaint = PanelGREENPaint
|
||||
object GColorPicker1: TGColorPicker
|
||||
Left = 24
|
||||
Height = 390
|
||||
Height = 368
|
||||
Top = 0
|
||||
Width = 22
|
||||
HintFormat = 'Green: %value (selected)'
|
||||
@@ -92,7 +96,7 @@ object Form1: TForm1
|
||||
end
|
||||
object GAxisColorPicker1: TGAxisColorPicker
|
||||
Left = 76
|
||||
Height = 378
|
||||
Height = 356
|
||||
Top = 6
|
||||
Width = 418
|
||||
HintFormat = 'R: %r B: %b'#13'Hex: %hex'
|
||||
@@ -149,4 +153,42 @@ object Form1: TForm1
|
||||
end
|
||||
end
|
||||
end
|
||||
object Panel1: TPanel
|
||||
Left = 0
|
||||
Height = 26
|
||||
Top = 424
|
||||
Width = 516
|
||||
Align = alBottom
|
||||
BevelOuter = bvNone
|
||||
ClientHeight = 26
|
||||
ClientWidth = 516
|
||||
TabOrder = 1
|
||||
object Label1: TLabel
|
||||
AnchorSideLeft.Control = mbColorPreview1
|
||||
AnchorSideLeft.Side = asrBottom
|
||||
AnchorSideTop.Control = mbColorPreview1
|
||||
AnchorSideTop.Side = asrCenter
|
||||
Left = 76
|
||||
Height = 15
|
||||
Top = 5
|
||||
Width = 34
|
||||
BorderSpacing.Left = 8
|
||||
Caption = 'Label1'
|
||||
ParentColor = False
|
||||
end
|
||||
object mbColorPreview1: TmbColorPreview
|
||||
AnchorSideLeft.Control = Panel1
|
||||
AnchorSideTop.Control = Panel1
|
||||
AnchorSideBottom.Control = Panel1
|
||||
AnchorSideBottom.Side = asrBottom
|
||||
Left = 8
|
||||
Height = 20
|
||||
Top = 2
|
||||
Width = 60
|
||||
Anchors = [akTop, akLeft, akBottom]
|
||||
BorderSpacing.Left = 8
|
||||
BorderSpacing.Top = 2
|
||||
BorderSpacing.Bottom = 4
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@@ -7,14 +7,17 @@ interface
|
||||
uses
|
||||
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
|
||||
ExtCtrls, ComCtrls, RAxisColorPicker, RColorPicker, GColorPicker,
|
||||
GAxisColorPicker, BColorPicker, BAxisColorPicker;
|
||||
GAxisColorPicker, BColorPicker, BAxisColorPicker, mbColorPreview;
|
||||
|
||||
type
|
||||
|
||||
{ TForm1 }
|
||||
|
||||
TForm1 = class(TForm)
|
||||
Label1: TLabel;
|
||||
mbColorPreview1: TmbColorPreview;
|
||||
PageControl1: TPageControl;
|
||||
Panel1: TPanel;
|
||||
RAxisColorPicker1: TRAxisColorPicker;
|
||||
BAxisColorPicker1: TBAxisColorPicker;
|
||||
GAxisColorPicker1: TGAxisColorPicker;
|
||||
@@ -32,11 +35,14 @@ type
|
||||
procedure FormCreate(Sender: TObject);
|
||||
procedure GAxisColorPicker1Change(Sender: TObject);
|
||||
procedure GColorPicker1Change(Sender: TObject);
|
||||
procedure PageControl1Change(Sender: TObject);
|
||||
procedure PanelBLUEPaint(Sender: TObject);
|
||||
procedure PanelGREENPaint(Sender: TObject);
|
||||
procedure PanelREDPaint(Sender: TObject);
|
||||
procedure RAxisColorPicker1Change(Sender: TObject);
|
||||
procedure RColorPicker1Change(Sender: TObject);
|
||||
private
|
||||
procedure UpdatePreview;
|
||||
public
|
||||
|
||||
end;
|
||||
@@ -49,18 +55,20 @@ implementation
|
||||
{$R *.lfm}
|
||||
|
||||
uses
|
||||
Types, GraphUtil;
|
||||
LclIntf, Types, GraphUtil, HTMLColors;
|
||||
|
||||
{ TForm1 }
|
||||
|
||||
procedure TForm1.BAxisColorPicker1Change(Sender: TObject);
|
||||
begin
|
||||
BColorPicker1.SelectedColor := BAxisColorPicker1.SelectedColor;
|
||||
UpdatePreview;
|
||||
end;
|
||||
|
||||
procedure TForm1.BColorPicker1Change(Sender: TObject);
|
||||
begin
|
||||
BAxisColorPicker1.SelectedColor := BColorPicker1.SelectedColor;
|
||||
UpdatePreview;
|
||||
end;
|
||||
|
||||
procedure TForm1.FormCreate(Sender: TObject);
|
||||
@@ -68,16 +76,24 @@ begin
|
||||
RAxisColorPicker1.SelectedColor := clRed;
|
||||
GAxisColorPicker1.SelectedColor := clGreen;
|
||||
BAxisColorPicker1.SelectedColor := clBlue;
|
||||
UpdatePreview;
|
||||
end;
|
||||
|
||||
procedure TForm1.GAxisColorPicker1Change(Sender: TObject);
|
||||
begin
|
||||
GColorPicker1.SelectedColor := GAxisColorPicker1.SelectedColor;
|
||||
UpdatePreview;
|
||||
end;
|
||||
|
||||
procedure TForm1.GColorPicker1Change(Sender: TObject);
|
||||
begin
|
||||
GAxisColorPicker1.SelectedColor := GColorPicker1.SelectedColor;
|
||||
UpdatePreview;
|
||||
end;
|
||||
|
||||
procedure TForm1.PageControl1Change(Sender: TObject);
|
||||
begin
|
||||
UpdatePreview;
|
||||
end;
|
||||
|
||||
// On BlueAxisPicker, x is RED, y is GREEN
|
||||
@@ -190,12 +206,28 @@ end;
|
||||
procedure TForm1.RAxisColorPicker1Change(Sender: TObject);
|
||||
begin
|
||||
RColorPicker1.SelectedColor := RAxisColorPicker1.SelectedColor;
|
||||
UpdatePreview;
|
||||
end;
|
||||
|
||||
procedure TForm1.RColorPicker1Change(Sender: TObject);
|
||||
begin
|
||||
RAXisColorPicker1.SelectedColor := RColorPicker1.SelectedColor;
|
||||
UpdatePreview;
|
||||
end;
|
||||
|
||||
procedure TForm1.UpdatePreview;
|
||||
begin
|
||||
case PageControl1.ActivePageindex of
|
||||
0: mbColorPreview1.Color := RColorPicker1.SelectedColor;
|
||||
1: mbColorPreview1.Color := GColorPicker1.SelectedColor;
|
||||
2: mbColorPreview1.Color := BColorPicker1.SelectedColor;
|
||||
end;
|
||||
Label1.Caption := Format('R=%d G=%d B=%d HTML=#%s', [
|
||||
GetRValue(mbColorPreview1.Color),
|
||||
GetGValue(mbColorPreview1.Color),
|
||||
GetBValue(mbColorPreview1.Color),
|
||||
ColorToHex(mbColorPreview1.Color)
|
||||
]);
|
||||
end;
|
||||
end.
|
||||
|
||||
|
@@ -15,10 +15,10 @@ object Form1: TForm1
|
||||
Height = 404
|
||||
Top = 6
|
||||
Width = 476
|
||||
ActivePage = TabSheet1
|
||||
ActivePage = TabSheet7
|
||||
Align = alClient
|
||||
BorderSpacing.Around = 6
|
||||
TabIndex = 0
|
||||
TabIndex = 7
|
||||
TabOrder = 0
|
||||
OnChange = PageControl1Change
|
||||
OnMouseMove = PageControl1MouseMove
|
||||
@@ -31,6 +31,7 @@ object Form1: TForm1
|
||||
Height = 360
|
||||
Top = 8
|
||||
Width = 454
|
||||
Saturation = 146
|
||||
SelectedColor = 3289805
|
||||
HSPickerHintFormat = 'H: %h S: %s'#13'Hex: #%hex'
|
||||
LPickerHintFormat = 'Luminance: %l'
|
||||
@@ -608,6 +609,7 @@ object Form1: TForm1
|
||||
Height = 351
|
||||
Top = 6
|
||||
Width = 322
|
||||
Luminance = 240
|
||||
RingPickerHintFormat = 'Hue: %h'
|
||||
SLPickerHintFormat = 'S: %s L: %l'#13'Hex: %hex'
|
||||
Anchors = [akTop, akLeft, akRight, akBottom]
|
||||
@@ -626,13 +628,12 @@ object Form1: TForm1
|
||||
Height = 362
|
||||
Top = 6
|
||||
Width = 405
|
||||
SelectedColor = clWhite
|
||||
HintFormat = 'H: %h S: %s V: %v'#13'Hex: %hex'
|
||||
Anchors = [akTop, akLeft, akRight, akBottom]
|
||||
TabOrder = 0
|
||||
OnMouseMove = HSVColorPicker1MouseMove
|
||||
Hue = 0
|
||||
Saturation = 0
|
||||
Value = 255
|
||||
OnChange = HSVColorPicker1Change
|
||||
end
|
||||
object VColorPicker2: TVColorPicker
|
||||
@@ -662,6 +663,7 @@ object Form1: TForm1
|
||||
Height = 364
|
||||
Top = 6
|
||||
Width = 458
|
||||
Luminance = 100
|
||||
HPickerHintFormat = 'Hue: %h (selected)'
|
||||
SLPickerHintFormat = 'S: %s L: %l'#13'Hex: %hex'
|
||||
Anchors = [akTop, akLeft, akRight, akBottom]
|
||||
@@ -785,9 +787,8 @@ object Form1: TForm1
|
||||
Anchors = [akLeft, akRight, akBottom]
|
||||
TabOrder = 2
|
||||
Hue = 0
|
||||
Saturation = 0
|
||||
Luminance = 48
|
||||
SelectedColor = 3158064
|
||||
Saturation = 240
|
||||
Luminance = 120
|
||||
end
|
||||
object VColorPicker1: TVColorPicker
|
||||
Left = 34
|
||||
@@ -800,10 +801,9 @@ object Form1: TForm1
|
||||
SelectionIndicator = siRect
|
||||
Anchors = [akLeft, akRight, akBottom]
|
||||
TabOrder = 3
|
||||
Hue = 239
|
||||
Hue = 0
|
||||
Saturation = 255
|
||||
Value = 40
|
||||
SelectedColor = 2621440
|
||||
Value = 255
|
||||
end
|
||||
object HColorPicker1: THColorPicker
|
||||
Left = 34
|
||||
@@ -907,6 +907,8 @@ object Form1: TForm1
|
||||
HintFormat = 'H: %h S: %s'#13'Hex: %hex'
|
||||
TabOrder = 0
|
||||
OnMouseMove = HSColorPicker1MouseMove
|
||||
Hue = 240
|
||||
Saturation = 214
|
||||
MarkerStyle = msSquare
|
||||
OnChange = HSColorPicker1Change
|
||||
end
|
||||
@@ -915,12 +917,10 @@ object Form1: TForm1
|
||||
Height = 130
|
||||
Top = 168
|
||||
Width = 161
|
||||
SelectedColor = 6579300
|
||||
SelectedColor = 6974058
|
||||
HintFormat = 'H: %h S: %s L: %l'#13'Hex: %hex'
|
||||
TabOrder = 1
|
||||
OnMouseMove = SLColorPicker1MouseMove
|
||||
Hue = 0
|
||||
Saturation = 0
|
||||
Luminance = 100
|
||||
MarkerStyle = msCross
|
||||
OnChange = SLColorPicker1Change
|
||||
@@ -930,6 +930,7 @@ object Form1: TForm1
|
||||
Height = 130
|
||||
Top = 168
|
||||
Width = 133
|
||||
SelectedColor = clRed
|
||||
HintFormat = 'Hue: %h (selected)'
|
||||
TabOrder = 2
|
||||
OnMouseMove = HRingPicker1MouseMove
|
||||
@@ -1220,9 +1221,9 @@ object Form1: TForm1
|
||||
BorderSpacing.Top = 4
|
||||
BorderSpacing.Right = 10
|
||||
TabOrder = 5
|
||||
LValue = 88
|
||||
AValue = -88
|
||||
BValue = 74
|
||||
LValue = 88
|
||||
end
|
||||
object LblGAxisPicker: TLabel
|
||||
AnchorSideLeft.Control = GAxisColorPicker1
|
||||
|
@@ -4,7 +4,7 @@ interface
|
||||
|
||||
|
||||
uses
|
||||
LCLIntf, LCLType, LMessages, SysUtils, Variants,Classes, Graphics, Controls,
|
||||
LCLIntf, LCLType, SysUtils, Variants,Classes, Graphics, Controls,
|
||||
Forms, Dialogs, HSLColorPicker, ComCtrls, StdCtrls, ExtCtrls, mbColorPreview,
|
||||
HexaColorPicker, mbColorPalette, HSLRingPicker, HSVColorPicker, PalUtils,
|
||||
SLHColorPicker, mbDeskPickerButton, mbOfficeColorDialog, SColorPicker,
|
||||
|
@@ -206,8 +206,8 @@ object Form1: TForm1
|
||||
OnChange = SLVPickerV_Change
|
||||
Hue = 0
|
||||
Saturation = 0
|
||||
Luminance = 240
|
||||
SelectedColor = 15790320
|
||||
Luminance = 226
|
||||
SelectedColor = 14869218
|
||||
end
|
||||
object HColorPickerV: THColorPicker
|
||||
AnchorSideTop.Control = LblH
|
||||
@@ -518,8 +518,8 @@ object Form1: TForm1
|
||||
OnChange = SLVPickerH_Change
|
||||
Hue = 0
|
||||
Saturation = 0
|
||||
Luminance = 240
|
||||
SelectedColor = 15790320
|
||||
Luminance = 226
|
||||
SelectedColor = 14869218
|
||||
end
|
||||
object SColorPickerH: TSColorPicker
|
||||
Left = 24
|
||||
|
@@ -153,7 +153,6 @@ begin
|
||||
]);
|
||||
end;
|
||||
|
||||
|
||||
procedure TForm1.FormCreate(Sender: TObject);
|
||||
begin
|
||||
MaxHue := 359;
|
||||
@@ -181,6 +180,8 @@ end;
|
||||
|
||||
procedure TForm1.HPickerH_Change(Sender: TObject);
|
||||
begin
|
||||
exit;
|
||||
|
||||
SLVPickerH_Change(nil);
|
||||
SColorPickerH.Hue := HColorPickerH.Hue;
|
||||
LColorPickerH.Hue := HColorPickerH.Hue;
|
||||
|
Reference in New Issue
Block a user