You've already forked lazarus-ccr
mColorLib: Refactor mouse coordinates (mx, mxx, mdx etc).
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5579 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -14,7 +14,6 @@ type
|
||||
TBAxisColorPicker = class(TmbColorPickerControl)
|
||||
private
|
||||
FR, FG, FB: integer;
|
||||
dx, dy, mxx, myy: integer;
|
||||
procedure SetRValue(r: integer);
|
||||
procedure SetGValue(g: integer);
|
||||
procedure SetBValue(b: integer);
|
||||
@ -63,11 +62,6 @@ begin
|
||||
FB := 255;
|
||||
FR := 0;
|
||||
FSelected := clBlue;
|
||||
FManual := false;
|
||||
dx := 0;
|
||||
dy := 0;
|
||||
mxx := 0;
|
||||
myy := 0;
|
||||
MarkerStyle := msCircle;
|
||||
end;
|
||||
|
||||
@ -91,8 +85,6 @@ begin
|
||||
FR := GetRValue(FSelected);
|
||||
FG := GetGValue(FSelected);
|
||||
FB := GetBValue(FSelected);
|
||||
dx := x;
|
||||
dy := y;
|
||||
if Focused or (csDesigning in ComponentState) then
|
||||
c := clBlack
|
||||
else
|
||||
@ -124,10 +116,10 @@ begin
|
||||
delta := IfThen(ssCtrl in Shift, 10, 1);
|
||||
|
||||
case Key of
|
||||
VK_LEFT : SelectColor(mxx - delta, myy);
|
||||
VK_RIGHT : SelectColor(mxx + delta, myy);
|
||||
VK_UP : SelectColor(mxx, myy - delta);
|
||||
VK_DOWN : SelectColor(mxx, myy + delta);
|
||||
VK_LEFT : SelectColor(mx - delta, my);
|
||||
VK_RIGHT : SelectColor(mx + delta, my);
|
||||
VK_UP : SelectColor(mx, my - delta);
|
||||
VK_DOWN : SelectColor(mx, my + delta);
|
||||
else eraseKey := false;
|
||||
end;
|
||||
|
||||
@ -163,13 +155,13 @@ end;
|
||||
procedure TBAxisColorPicker.Paint;
|
||||
begin
|
||||
Canvas.StretchDraw(ClientRect, FBufferBmp);
|
||||
DrawMarker(mxx, myy);
|
||||
DrawMarker(mx, my);
|
||||
end;
|
||||
|
||||
procedure TBAxisColorPicker.Resize;
|
||||
begin
|
||||
mxx := round(FR * Width / 255);
|
||||
myy := round((255 - FG) * Height / 255);
|
||||
mx := round(FR * Width / 255);
|
||||
my := round((255 - FG) * Height / 255);
|
||||
inherited;
|
||||
end;
|
||||
|
||||
@ -180,8 +172,8 @@ var
|
||||
needNewGradient: Boolean;
|
||||
begin
|
||||
CorrectCoords(x, y);
|
||||
mxx := x;
|
||||
myy := y;
|
||||
mx := x;
|
||||
my := y;
|
||||
c := GetColorAtPoint(x, y);
|
||||
if c = FSelected then
|
||||
exit;
|
||||
@ -241,8 +233,8 @@ begin
|
||||
FG := g;
|
||||
FB := b;
|
||||
FSelected := c;
|
||||
mxx := Round(FR * Width / 255); // RED is on x
|
||||
myy := Round((255 - FG) * Height / 255); // GREEN is on y
|
||||
mx := Round(FR * Width / 255); // RED is on x
|
||||
my := Round((255 - FG) * Height / 255); // GREEN is on y
|
||||
if needNewGradient then
|
||||
CreateGradient;
|
||||
Invalidate;
|
||||
|
@ -15,7 +15,6 @@ type
|
||||
TCIEAColorPicker = class(TmbColorPickerControl)
|
||||
private
|
||||
FL, FA, FB: integer;
|
||||
dx, dy, mxx, myy: integer;
|
||||
procedure SetLValue(l: integer);
|
||||
procedure SetAValue(a: integer);
|
||||
procedure SetBValue(b: integer);
|
||||
@ -63,10 +62,6 @@ begin
|
||||
FL := 100;
|
||||
FA := 127;
|
||||
FB := -128;
|
||||
dx := 0;
|
||||
dy := 0;
|
||||
mxx := 0;
|
||||
myy := 0;
|
||||
MarkerStyle := msCircle;
|
||||
end;
|
||||
|
||||
@ -90,8 +85,6 @@ begin
|
||||
FL := Round(GetCIELValue(FSelected));
|
||||
FA := Round(GetCIEAValue(FSelected));
|
||||
FB := Round(GetCIEBValue(FSelected));
|
||||
dx := x;
|
||||
dy := y;
|
||||
if Focused or (csDesigning in ComponentState) then
|
||||
c := clBlack
|
||||
else
|
||||
@ -135,10 +128,10 @@ begin
|
||||
delta := IfThen(ssCtrl in Shift, 10, 1);
|
||||
|
||||
case Key of
|
||||
VK_LEFT : SelectColor(mxx - delta, myy);
|
||||
VK_RIGHT : SelectColor(mxx + delta, myy);
|
||||
VK_UP : SelectColor(mxx, myy - delta);
|
||||
VK_DOWN : SelectColor(mxx, myy + delta);
|
||||
VK_LEFT : SelectColor(mx - delta, my);
|
||||
VK_RIGHT : SelectColor(mx + delta, my);
|
||||
VK_UP : SelectColor(mx, my - delta);
|
||||
VK_DOWN : SelectColor(mx, my + delta);
|
||||
else eraseKey := false;
|
||||
end;
|
||||
|
||||
@ -175,21 +168,21 @@ end;
|
||||
procedure TCIEAColorPicker.Paint;
|
||||
begin
|
||||
Canvas.StretchDraw(ClientRect, FBufferBmp);
|
||||
DrawMarker(mxx, myy);
|
||||
DrawMarker(mx, my);
|
||||
end;
|
||||
|
||||
procedure TCIEAColorPicker.Resize;
|
||||
begin
|
||||
mxx := Round((FB + 128) / 255 * Width);
|
||||
mx := Round((FB + 128) / 255 * Width);
|
||||
// myy := Round(((100 - FL) * 255 / 100) * Height / 255);
|
||||
myy := Round((100 - FL) / 100 * Height);
|
||||
my := Round((100 - FL) / 100 * Height);
|
||||
inherited;
|
||||
end;
|
||||
|
||||
procedure TCIEAColorPicker.SelectColor(x, y: Integer);
|
||||
var
|
||||
c: TColor;
|
||||
l, a, b: Integer;
|
||||
L, a, b: Integer;
|
||||
needNewGradient: Boolean;
|
||||
begin
|
||||
CorrectCoords(x, y);
|
||||
@ -199,14 +192,14 @@ begin
|
||||
if c = FSelected then
|
||||
exit;
|
||||
|
||||
mxx := x;
|
||||
myy := y;
|
||||
l := Round(GetCIELValue(c));
|
||||
mx := x;
|
||||
my := y;
|
||||
L := Round(GetCIELValue(c));
|
||||
a := Round(GetCIEAValue(c));
|
||||
b := Round(GetCIEBValue(c));
|
||||
needNewGradient := a <> FA;
|
||||
FSelected := c;
|
||||
FL := l;
|
||||
FL := L;
|
||||
FA := a;
|
||||
FB := b;
|
||||
if needNewGradient then
|
||||
@ -254,9 +247,9 @@ begin
|
||||
FA := a;
|
||||
FB := b;
|
||||
FSelected := c;
|
||||
mxx := Round((FB + 128) * Width / 255);
|
||||
// myy := Round((100 - FL) * 255 / 100 * Height / 255);
|
||||
myy := Round((100 - FL) / 100 * Height);
|
||||
mx := Round((FB + 128) * Width / 255);
|
||||
// my := Round((100 - FL) * 255 / 100 * Height / 255);
|
||||
my := Round((100 - FL) / 100 * Height);
|
||||
if needNewGradient then
|
||||
CreateGradient;
|
||||
Invalidate;
|
||||
|
@ -18,7 +18,6 @@ type
|
||||
TCIEBColorPicker = class(TmbColorPickerControl)
|
||||
private
|
||||
FL, FA, FB: integer;
|
||||
dx, dy, mxx, myy: integer;
|
||||
procedure SetLValue(l: integer);
|
||||
procedure SetAValue(a: integer);
|
||||
procedure SetBValue(b: integer);
|
||||
@ -66,10 +65,6 @@ begin
|
||||
FL := 100;
|
||||
FA := -128;
|
||||
FB := 127;
|
||||
dx := 0;
|
||||
dy := 0;
|
||||
mxx := 0;
|
||||
myy := 0;
|
||||
MarkerStyle := msCircle;
|
||||
end;
|
||||
|
||||
@ -93,8 +88,6 @@ begin
|
||||
FL := Round(GetCIELValue(FSelected));
|
||||
FA := Round(GetCIEAValue(FSelected));
|
||||
FB := Round(GetCIEBValue(FSelected));
|
||||
dx := x;
|
||||
dy := y;
|
||||
if Focused or (csDesigning in ComponentState) then
|
||||
c := clBlack
|
||||
else
|
||||
@ -138,10 +131,10 @@ begin
|
||||
delta := IfThen(ssCtrl in Shift, 10, 1);
|
||||
|
||||
case Key of
|
||||
VK_LEFT : SelectColor(mxx - delta, myy);
|
||||
VK_RIGHT : SelectColor(mxx + delta, myy);
|
||||
VK_UP : SelectColor(mxx, myy - delta);
|
||||
VK_DOWN : SelectColor(mxx, myy + delta);
|
||||
VK_LEFT : SelectColor(mx - delta, my);
|
||||
VK_RIGHT : SelectColor(mx + delta, my);
|
||||
VK_UP : SelectColor(mx, my - delta);
|
||||
VK_DOWN : SelectColor(mx, my + delta);
|
||||
else eraseKey := false;
|
||||
end;
|
||||
|
||||
@ -178,14 +171,14 @@ end;
|
||||
procedure TCIEBColorPicker.Paint;
|
||||
begin
|
||||
Canvas.StretchDraw(ClientRect, FBufferBmp);
|
||||
DrawMarker(mxx, myy);
|
||||
DrawMarker(mx, my);
|
||||
end;
|
||||
|
||||
procedure TCIEBColorPicker.Resize;
|
||||
begin
|
||||
mxx := Round((FA + 128) * (Width / 255));
|
||||
mx := Round((FA + 128) * (Width / 255));
|
||||
// myy := Round(((100 - FL) * 255 / 100) * (Height / 255));
|
||||
myy := Round(( 100 - FL) / 100 * Height);
|
||||
my := Round(( 100 - FL) / 100 * Height);
|
||||
inherited;
|
||||
end;
|
||||
|
||||
@ -202,8 +195,8 @@ begin
|
||||
if c = FSelected then
|
||||
exit;
|
||||
|
||||
mxx := x;
|
||||
myy := y;
|
||||
mx := x;
|
||||
my := y;
|
||||
l := Round(GetCIELValue(c));
|
||||
a := Round(GetCIEAValue(c));
|
||||
b := Round(GetCIEBValue(c));
|
||||
@ -241,7 +234,7 @@ end;
|
||||
|
||||
procedure TCIEBColorPicker.SetSelectedColor(c: TColor);
|
||||
var
|
||||
l, a, b: Integer;
|
||||
L, a, b: Integer;
|
||||
needNewGradient: Boolean;
|
||||
begin
|
||||
if WebSafe then
|
||||
@ -249,17 +242,17 @@ begin
|
||||
if c = FSelected then
|
||||
exit;
|
||||
|
||||
l := Round(GetCIELValue(c));
|
||||
L := Round(GetCIELValue(c));
|
||||
a := Round(GetCIEAValue(c));
|
||||
b := Round(GetCIEBValue(c));
|
||||
needNewGradient := (b <> FB);
|
||||
FL := l;
|
||||
FL := L;
|
||||
FA := a;
|
||||
FB := b;
|
||||
FSelected := c;
|
||||
mxx := Round((FA + 128) * Width / 255);
|
||||
// myy := Round((100 - FL) * 255 / 100* Height / 255);
|
||||
myy := Round((100 - FL) / 100 * Height);
|
||||
mx := Round((FA + 128) * Width / 255);
|
||||
// my := Round((100 - FL) * 255 / 100* Height / 255);
|
||||
my := Round((100 - FL) / 100 * Height);
|
||||
if needNewGradient then
|
||||
CreateGradient;
|
||||
Invalidate;
|
||||
|
@ -15,7 +15,6 @@ type
|
||||
TCIELColorPicker = class(TmbColorPickerControl)
|
||||
private
|
||||
FL, FA, FB: integer;
|
||||
dx, dy, mxx, myy: integer;
|
||||
procedure SetLValue(l: integer);
|
||||
procedure SetAValue(a: integer);
|
||||
procedure SetBValue(b: integer);
|
||||
@ -63,11 +62,6 @@ begin
|
||||
FL := 100;
|
||||
FA := -128;
|
||||
FB := 127;
|
||||
FManual := false;
|
||||
dx := 0;
|
||||
dy := 0;
|
||||
mxx := 0;
|
||||
myy := 0;
|
||||
MarkerStyle := msCircle;
|
||||
end;
|
||||
|
||||
@ -91,8 +85,6 @@ begin
|
||||
FL := Round(GetCIELValue(FSelected));
|
||||
FA := Round(GetCIEAValue(FSelected));
|
||||
FB := Round(GetCIEBValue(FSelected));
|
||||
dx := x;
|
||||
dy := y;
|
||||
if Focused or (csDesigning in ComponentState) then
|
||||
c := clBlack
|
||||
else
|
||||
@ -133,10 +125,10 @@ begin
|
||||
delta := IfThen(ssCtrl in Shift, 10, 1);
|
||||
|
||||
case Key of
|
||||
VK_LEFT : SelectColor(mxx - delta, myy);
|
||||
VK_Right : SelectColor(mxx + delta, myy);
|
||||
VK_UP : SelectColor(mxx, myy - delta);
|
||||
VK_DOWN : SelectColor(mxx, myy + delta);
|
||||
VK_LEFT : SelectColor(mx - delta, my);
|
||||
VK_Right : SelectColor(mx + delta, my);
|
||||
VK_UP : SelectColor(mx, my - delta);
|
||||
VK_DOWN : SelectColor(mx, my + delta);
|
||||
else eraseKey := false;
|
||||
end;
|
||||
|
||||
@ -173,15 +165,15 @@ end;
|
||||
procedure TCIELColorPicker.Paint;
|
||||
begin
|
||||
Canvas.StretchDraw(ClientRect, FBufferBmp);
|
||||
CorrectCoords(mxx, myy);
|
||||
DrawMarker(mxx, myy);
|
||||
CorrectCoords(mx, my);
|
||||
DrawMarker(mx, my);
|
||||
end;
|
||||
|
||||
procedure TCIELColorPicker.Resize;
|
||||
begin
|
||||
FManual := false;
|
||||
mxx := Round((FA + 128) * Width / 255);
|
||||
myy := Round((255 - (FB + 128)) * Height / 255);
|
||||
mx := Round((FA + 128) * Width / 255);
|
||||
my := Round((255 - (FB + 128)) * Height / 255);
|
||||
inherited;
|
||||
end;
|
||||
|
||||
@ -198,8 +190,8 @@ begin
|
||||
if c = FSelected then
|
||||
exit;
|
||||
|
||||
mxx := x;
|
||||
myy := y;
|
||||
mx := x;
|
||||
my := y;
|
||||
l := Round(GetCIELValue(c));
|
||||
a := Round(GetCIEAValue(c));
|
||||
b := Round(GetCIEBValue(c));
|
||||
@ -237,7 +229,7 @@ end;
|
||||
|
||||
procedure TCIELColorPicker.SetSelectedColor(c: TColor);
|
||||
var
|
||||
l, a, b: Integer;
|
||||
L, a, b: Integer;
|
||||
needNewGradient: Boolean;
|
||||
begin
|
||||
if WebSafe then
|
||||
@ -245,16 +237,16 @@ begin
|
||||
if c = FSelected then
|
||||
exit;
|
||||
|
||||
l := Round(GetCIELValue(c));
|
||||
L := Round(GetCIELValue(c));
|
||||
a := Round(GetCIEAValue(c));
|
||||
b := Round(GetCIEBValue(c));
|
||||
needNewGradient := l <> FL;
|
||||
FL := l;
|
||||
needNewGradient := L <> FL;
|
||||
FL := L;
|
||||
FA := a;
|
||||
FB := b;
|
||||
FSelected := c;
|
||||
mxx := Round((FA + 128) * Width / 255);
|
||||
myy := Round((255 - (FB + 128)) * Height / 255);
|
||||
mx := Round((FA + 128) * Width / 255);
|
||||
my := Round((255 - (FB + 128)) * Height / 255);
|
||||
if needNewGradient then
|
||||
CreateGradient;
|
||||
Invalidate;
|
||||
|
@ -14,7 +14,6 @@ type
|
||||
TGAxisColorPicker = class(TmbColorPickerControl)
|
||||
private
|
||||
FR, FG, FB: integer;
|
||||
dx, dy, mxx, myy: integer;
|
||||
procedure SetRValue(r: integer);
|
||||
procedure SetGValue(g: integer);
|
||||
procedure SetBValue(b: integer);
|
||||
@ -63,10 +62,6 @@ begin
|
||||
FR := 0;
|
||||
FSelected := clLime;
|
||||
FManual := false;
|
||||
dx := 0;
|
||||
dy := 0;
|
||||
mxx := 0;
|
||||
myy := 0;
|
||||
MarkerStyle := msCircle;
|
||||
end;
|
||||
|
||||
@ -90,8 +85,6 @@ begin
|
||||
FR := GetRValue(FSelected);
|
||||
FG := GetGValue(FSelected);
|
||||
FB := GetBValue(FSelected);
|
||||
dx := x;
|
||||
dy := y;
|
||||
if Focused or (csDesigning in ComponentState) then
|
||||
c := clBlack
|
||||
else
|
||||
@ -123,10 +116,10 @@ begin
|
||||
delta := IfThen(ssCtrl in Shift, 10, 1);
|
||||
|
||||
case Key of
|
||||
VK_LEFT : SelectColor(mxx - delta, myy);
|
||||
VK_RIGHT : SelectColor(mxx + delta, myy);
|
||||
VK_UP : SelectColor(mxx, myy - delta);
|
||||
VK_DOWN : SelectColor(mxx, myy + delta);
|
||||
VK_LEFT : SelectColor(mx - delta, my);
|
||||
VK_RIGHT : SelectColor(mx + delta, my);
|
||||
VK_UP : SelectColor(mx, my - delta);
|
||||
VK_DOWN : SelectColor(mx, my + delta);
|
||||
else eraseKey := false;
|
||||
end;
|
||||
|
||||
@ -161,14 +154,14 @@ end;
|
||||
procedure TGAxisColorPicker.Paint;
|
||||
begin
|
||||
Canvas.StretchDraw(ClientRect, FBufferBmp);
|
||||
DrawMarker(mxx, myy);
|
||||
DrawMarker(mx, my);
|
||||
end;
|
||||
|
||||
procedure TGAxisColorPicker.Resize;
|
||||
begin
|
||||
FManual := false;
|
||||
mxx := Round(FB * Width / 255);
|
||||
myy := Round((255 - FR) * Height / 255);
|
||||
mx := Round(FB * Width / 255);
|
||||
my := Round((255 - FR) * Height / 255);
|
||||
inherited;
|
||||
end;
|
||||
|
||||
@ -179,8 +172,8 @@ var
|
||||
needNewGradient: Boolean;
|
||||
begin
|
||||
CorrectCoords(x, y);
|
||||
mxx := x;
|
||||
myy := y;
|
||||
mx := x;
|
||||
my := y;
|
||||
c := GetColorAtPoint(x, y);
|
||||
if c = FSelected then
|
||||
exit;
|
||||
@ -241,8 +234,8 @@ begin
|
||||
FG := g;
|
||||
FB := b;
|
||||
FSelected := c;
|
||||
mxx := Round(FB * Width / 255); // BLUE is x
|
||||
myy := Round((255 - FR) * Height / 255); // RED is y
|
||||
mx := Round(FB * Width / 255); // BLUE is x
|
||||
my := Round((255 - FR) * Height / 255); // RED is y
|
||||
if needNewGradient then
|
||||
CreateGradient;
|
||||
Invalidate;
|
||||
|
@ -20,7 +20,6 @@ type
|
||||
private
|
||||
FHue, FSat, FLum, FLumSel: Double;
|
||||
FMaxHue, FMaxSat, FMaxLum: Integer;
|
||||
dx, dy, mxx, myy: integer;
|
||||
function GetHue: Integer;
|
||||
function GetLum: Integer;
|
||||
function GetSat: Integer;
|
||||
@ -112,8 +111,6 @@ begin
|
||||
RGBToHSL(FSelected, FHue, FSat, L);
|
||||
{$ENDIF}
|
||||
|
||||
dx := x;
|
||||
dy := y;
|
||||
if Focused or (csDesigning in ComponentState) then
|
||||
c := clBlack
|
||||
else
|
||||
@ -184,10 +181,10 @@ begin
|
||||
delta := IfThen(ssCtrl in Shift, 10, 1);
|
||||
|
||||
case Key of
|
||||
VK_LEFT : SelectColor(mxx - delta, myy);
|
||||
VK_RIGHT : SelectColor(mxx + delta, myy);
|
||||
VK_UP : SelectColor(mxx, myy - delta);
|
||||
VK_DOWN : SelectColor(mxx, myy + delta);
|
||||
VK_LEFT : SelectColor(mx - delta, my);
|
||||
VK_RIGHT : SelectColor(mx + delta, my);
|
||||
VK_UP : SelectColor(mx, my - delta);
|
||||
VK_DOWN : SelectColor(mx, my + delta);
|
||||
else eraseKey := false;
|
||||
end;
|
||||
{
|
||||
@ -264,7 +261,7 @@ end;
|
||||
procedure THSColorPicker.Paint;
|
||||
begin
|
||||
Canvas.StretchDraw(ClientRect, FBufferBmp);
|
||||
DrawMarker(mxx, myy);
|
||||
DrawMarker(mx, my);
|
||||
end;
|
||||
|
||||
function THSColorPicker.PredictColor: TColor;
|
||||
@ -291,8 +288,8 @@ var
|
||||
c: TColor;
|
||||
begin
|
||||
CorrectCoords(x, y);
|
||||
mxx := x;
|
||||
myy := y;
|
||||
mx := x;
|
||||
my := y;
|
||||
c := GetColorAtPoint(x, y);
|
||||
if WebSafe then c := GetWebSafe(c);
|
||||
{$IFDEF USE_COLOR_TO_RGB}
|
||||
@ -452,9 +449,9 @@ end;
|
||||
|
||||
procedure THSCOlorPicker.UpdateCoords;
|
||||
begin
|
||||
mxx := Round(FHue * Width);
|
||||
myy := Round((1.0 - FSat) * Height);
|
||||
CorrectCoords(mxx, myy);
|
||||
mx := Round(FHue * Width);
|
||||
my := Round((1.0 - FSat) * Height);
|
||||
CorrectCoords(mx, my);
|
||||
end;
|
||||
|
||||
end.
|
||||
|
@ -339,7 +339,7 @@ begin
|
||||
DeleteObject(rgn);
|
||||
DrawSatCirc;
|
||||
DrawHueLine;
|
||||
DrawMarker(mdx, mdy);
|
||||
DrawMarker(mx, my);
|
||||
end;
|
||||
|
||||
function THSVColorPicker.RadHue(New: integer): integer;
|
||||
@ -362,8 +362,8 @@ var
|
||||
dx, dy, r, radius: integer;
|
||||
H, S: Double;
|
||||
begin
|
||||
mdx := x;
|
||||
mdy := y;
|
||||
mx := x;
|
||||
my := y;
|
||||
|
||||
radius := Min(Width, Height) div 2;
|
||||
dx := x - radius;
|
||||
@ -572,8 +572,8 @@ begin
|
||||
r := -FSat * radius;
|
||||
angle := -(FHue * 2 + 1) * pi;
|
||||
SinCos(angle, sinAngle, cosAngle);
|
||||
mdx := round(cosAngle * r) + radius;
|
||||
mdy := round(sinAngle * r) + radius;
|
||||
mx := round(cosAngle * r) + radius;
|
||||
my := round(sinAngle * r) + radius;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
@ -12,7 +12,6 @@ type
|
||||
TRAxisColorPicker = class(TmbColorPickerControl)
|
||||
private
|
||||
FR, FG, FB: integer;
|
||||
dx, dy, mxx, myy: integer;
|
||||
procedure SetRValue(r: integer);
|
||||
procedure SetGValue(g: integer);
|
||||
procedure SetBValue(b: integer);
|
||||
@ -60,11 +59,6 @@ begin
|
||||
FB := 0;
|
||||
FR := 255;
|
||||
FSelected := clRed;
|
||||
FManual := false;
|
||||
dx := 0;
|
||||
dy := 0;
|
||||
mxx := 0;
|
||||
myy := 0;
|
||||
MarkerStyle := msCircle;
|
||||
end;
|
||||
|
||||
@ -88,8 +82,6 @@ begin
|
||||
FR := GetRValue(FSelected);
|
||||
FG := GetGValue(FSelected);
|
||||
FB := GetBValue(FSelected);
|
||||
dx := x;
|
||||
dy := y;
|
||||
if Focused or (csDesigning in ComponentState) then
|
||||
c := clBlack
|
||||
else
|
||||
@ -121,10 +113,10 @@ begin
|
||||
delta := IfThen(ssCtrl in Shift, 10, 1);
|
||||
|
||||
case Key of
|
||||
VK_LEFT : SelectColor(mxx - delta, myy);
|
||||
VK_RIGHT : SelectColor(mxx + delta, myy);
|
||||
VK_UP : SelectColor(mxx, myy - delta);
|
||||
VK_DOWN : SelectColor(mxx, myy + delta);
|
||||
VK_LEFT : SelectColor(mx - delta, my);
|
||||
VK_RIGHT : SelectColor(mx + delta, my);
|
||||
VK_UP : SelectColor(mx, my - delta);
|
||||
VK_DOWN : SelectColor(mx, my + delta);
|
||||
else eraseKey := false;
|
||||
end;
|
||||
|
||||
@ -160,14 +152,14 @@ end;
|
||||
procedure TRAxisColorPicker.Paint;
|
||||
begin
|
||||
Canvas.StretchDraw(ClientRect, FBufferBmp);
|
||||
DrawMarker(mxx, myy);
|
||||
DrawMarker(mx, my);
|
||||
end;
|
||||
|
||||
procedure TRAxisColorPicker.Resize;
|
||||
begin
|
||||
FManual := false;
|
||||
mxx := Round(FB * Width / 255);
|
||||
myy := Round((255 - FG) * Height / 255);
|
||||
mx := Round(FB * Width / 255);
|
||||
my := Round((255 - FG) * Height / 255);
|
||||
inherited;
|
||||
end;
|
||||
|
||||
@ -178,8 +170,8 @@ var
|
||||
needNewGradient: Boolean;
|
||||
begin
|
||||
CorrectCoords(x, y);
|
||||
mxx := x;
|
||||
myy := y;
|
||||
mx := x;
|
||||
my := y;
|
||||
c := GetColorAtPoint(x, y);
|
||||
if c = FSelected then
|
||||
exit;
|
||||
@ -240,8 +232,8 @@ begin
|
||||
FB := b;
|
||||
FSelected := c;
|
||||
FManual := false;
|
||||
mxx := Round(FB * Width / 255); // BLUE on x
|
||||
myy := Round((255 - FG) * Height / 255); // GREEN on y
|
||||
mx := Round(FB * Width / 255); // BLUE on x
|
||||
my := Round((255 - FG) * Height / 255); // GREEN on y
|
||||
if needNewGradient then
|
||||
CreateGradient;
|
||||
Invalidate;
|
||||
|
@ -143,10 +143,10 @@ begin
|
||||
delta := IfThen(ssCtrl in Shift, 10, 1);
|
||||
|
||||
case Key of
|
||||
VK_LEFT : SelectColor(mdx - delta, mdy);
|
||||
VK_RIGHT : SelectColor(mdx + delta, mdy);
|
||||
VK_UP : SelectColor(mdx, mdy - delta);
|
||||
VK_DOWN : SelectColor(mdx, mdy + delta);
|
||||
VK_LEFT : SelectColor(mx - delta, my);
|
||||
VK_RIGHT : SelectColor(mx + delta, my);
|
||||
VK_UP : SelectColor(mx, my - delta);
|
||||
VK_DOWN : SelectColor(mx, my + delta);
|
||||
else eraseKey := false;
|
||||
end;
|
||||
{
|
||||
@ -228,7 +228,7 @@ procedure TSLColorPicker.Paint;
|
||||
begin
|
||||
Canvas.StretchDraw(ClientRect, FBufferBMP);
|
||||
UpdateCoords;
|
||||
DrawMarker(mdx, mdy);
|
||||
DrawMarker(mx, my);
|
||||
end;
|
||||
|
||||
procedure TSLColorPicker.Resize;
|
||||
@ -353,8 +353,8 @@ end;
|
||||
|
||||
procedure TSLColorPicker.UpdateCoords;
|
||||
begin
|
||||
mdx := round(FSat * (Width - 1));
|
||||
mdy := round((1.0 - FLum) * (Height - 1));
|
||||
mx := round(FSat * (Width - 1));
|
||||
my := round((1.0 - FLum) * (Height - 1));
|
||||
end;
|
||||
|
||||
|
||||
|
@ -23,30 +23,20 @@ type
|
||||
protected
|
||||
FManual: Boolean;
|
||||
FSelected: TColor;
|
||||
mx, my, mdx, mdy: integer;
|
||||
mx, my: integer;
|
||||
procedure CreateGradient; override;
|
||||
function GetHintStr(X, Y: Integer): String; override;
|
||||
function GetSelectedColor: TColor; virtual;
|
||||
procedure InternalDrawMarker(X, Y: Integer; C: TColor);
|
||||
procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
|
||||
procedure MouseMove(Shift: TShiftState; X, Y: Integer); override;
|
||||
procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
|
||||
procedure SetSelectedColor(C: TColor); virtual;
|
||||
procedure WebSafeChanged; dynamic;
|
||||
{$IFDEF DELPHI}
|
||||
procedure CMGotFocus(var Message: TCMGotFocus); message CM_ENTER;
|
||||
procedure CMLostFocus(var Message: TCMLostFocus); message CM_EXIT;
|
||||
procedure CMMouseLeave(var Message: TMessage); message CM_MOUSELEAVE;
|
||||
{$ELSE}
|
||||
procedure CMGotFocus(var Message: TLMessage); message CM_ENTER;
|
||||
procedure CMLostFocus(var Message: TLMessage); message CM_EXIT;
|
||||
procedure CMMouseLeave(var Message: TLMessage); message CM_MOUSELEAVE;
|
||||
{$ENDIF}
|
||||
property MarkerStyle: TMarkerStyle read FMarkerStyle write SetMarkerStyle;
|
||||
public
|
||||
constructor Create(AOwner: TComponent); override;
|
||||
property ColorUnderCursor;
|
||||
property Manual: boolean read FManual;
|
||||
published
|
||||
property SelectedColor: TColor read GetSelectedColor write SetSelectedColor;
|
||||
property HintFormat: string read FHintFormat write FHintFormat;
|
||||
@ -67,9 +57,6 @@ type
|
||||
property TabStop default true;
|
||||
property Color;
|
||||
property ParentColor;
|
||||
{$IFDEF DELPHI_7_UP}{$IFDEF DELPHI}
|
||||
property ParentBackground default true;
|
||||
{$ENDIF}{$ENDIF}
|
||||
property DragCursor;
|
||||
property DragMode;
|
||||
property DragKind;
|
||||
@ -94,9 +81,7 @@ type
|
||||
implementation
|
||||
|
||||
uses
|
||||
{$IFDEF FPC}
|
||||
IntfGraphics, fpimage,
|
||||
{$ENDIF}
|
||||
ScanLines, PalUtils, SelPropUtils;
|
||||
|
||||
constructor TmbCustomPicker.Create(AOwner: TComponent);
|
||||
@ -107,28 +92,23 @@ begin
|
||||
TabStop := true;
|
||||
mx := 0;
|
||||
my := 0;
|
||||
mdx := 0;
|
||||
mdy := 0;
|
||||
FHintFormat := 'Hex #%hex'#10#13'RGB[%r, %g, %b]'#10#13'HSL[%hslH, %hslS, %hslL]'#10#13'HSV[%hsvH, %hsvS, %hsvV]'#10#13'CMYK[%c, %m, %y, %k]'#10#13'L*a*b*[%cieL, %cieA, %cieB]'#10#13'XYZ[%cieX, %cieY, %cieZ]';
|
||||
FWebSafe := false;
|
||||
end;
|
||||
|
||||
procedure TmbCustomPicker.CMGotFocus(
|
||||
var Message: {$IFDEF FPC}TLMessage{$ELSE}TCMGotFocus{$ENDIF} );
|
||||
procedure TmbCustomPicker.CMGotFocus(var Message: TLMessage);
|
||||
begin
|
||||
inherited;
|
||||
Invalidate;
|
||||
end;
|
||||
|
||||
procedure TmbCustomPicker.CMLostFocus(
|
||||
var Message: {$IFDEF FPC}TLMessage{$ELSE}TCMLostFocus{$ENDIF} );
|
||||
procedure TmbCustomPicker.CMLostFocus(var Message: TLMessage);
|
||||
begin
|
||||
inherited;
|
||||
Invalidate;
|
||||
end;
|
||||
|
||||
procedure TmbCustomPicker.CMMouseLeave(
|
||||
var Message: {$IFDEF FPC}TLMessage{$ELSE}TMessage{$ENDIF});
|
||||
procedure TmbCustomPicker.CMMouseLeave(var Message: TLMessage);
|
||||
begin
|
||||
mx := 0;
|
||||
my := 0;
|
||||
@ -195,29 +175,6 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TmbCustomPicker.MouseDown(Button: TMouseButton; Shift: TShiftState;
|
||||
X, Y: Integer);
|
||||
begin
|
||||
inherited;
|
||||
mx := x;
|
||||
my := y;
|
||||
end;
|
||||
|
||||
procedure TmbCustomPicker.MouseMove(Shift: TShiftState; X, Y: Integer);
|
||||
begin
|
||||
inherited;
|
||||
mx := x;
|
||||
my := y;
|
||||
end;
|
||||
|
||||
procedure TmbCustomPicker.MouseUp(Button: TMouseButton; Shift: TShiftState;
|
||||
X, Y: Integer);
|
||||
begin
|
||||
inherited;
|
||||
mx := x;
|
||||
my := y;
|
||||
end;
|
||||
|
||||
procedure TmbCustomPicker.SetMarkerStyle(s: TMarkerStyle);
|
||||
begin
|
||||
if FMarkerStyle <> s then
|
||||
|
Reference in New Issue
Block a user