You've already forked lazarus-ccr
mbColorLib: Improved highlighting of selected combs in HexaColorPicker.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5484 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -196,7 +196,7 @@ type
|
|||||||
implementation
|
implementation
|
||||||
|
|
||||||
uses
|
uses
|
||||||
PalUtils;
|
PalUtils, mbUtils;
|
||||||
|
|
||||||
{ THexaColorPicker }
|
{ THexaColorPicker }
|
||||||
|
|
||||||
@ -304,7 +304,7 @@ begin
|
|||||||
try
|
try
|
||||||
// OffScreen.PixelFormat := pf32bit;
|
// OffScreen.PixelFormat := pf32bit;
|
||||||
OffScreen.Width := Width;
|
OffScreen.Width := Width;
|
||||||
OffScreen.Height := FColorCombRect.Bottom - FColorCombRect.Top + FBWCombRect.Bottom - FBWCombRect.Top;
|
OffScreen.Height := HeightOf(FColorCombRect) + HeightOf(FBWCombRect);
|
||||||
//Parent background
|
//Parent background
|
||||||
{$IFDEF FPC}
|
{$IFDEF FPC}
|
||||||
if Color = clDefault then
|
if Color = clDefault then
|
||||||
@ -351,8 +351,11 @@ begin
|
|||||||
Index := FCustomIndex - 1;
|
Index := FCustomIndex - 1;
|
||||||
FSelectedCombIndex := index;
|
FSelectedCombIndex := index;
|
||||||
Pen.Style := psSolid;
|
Pen.Style := psSolid;
|
||||||
|
{
|
||||||
Pen.Mode := pmXOR;
|
Pen.Mode := pmXOR;
|
||||||
Pen.Color := clWhite;
|
Pen.Color := clWhite;
|
||||||
|
}
|
||||||
|
Pen.Color := HighContrastColor(FColorCombs[Index].Color);
|
||||||
Pen.Width := 2;
|
Pen.Width := 2;
|
||||||
Brush.Style := bsClear;
|
Brush.Style := bsClear;
|
||||||
DrawComb(OffScreen.Canvas, FColorCombs[Index].Position.X + XOffs, FColorCombs[Index].Position.Y + YOffs, FCombSize);
|
DrawComb(OffScreen.Canvas, FColorCombs[Index].Position.X + XOffs, FColorCombs[Index].Position.Y + YOffs, FCombSize);
|
||||||
@ -371,9 +374,12 @@ begin
|
|||||||
Pen.Color := FBWCombs[I].Color;
|
Pen.Color := FBWCombs[I].Color;
|
||||||
Brush.Color := FBWCombs[I].Color;
|
Brush.Color := FBWCombs[I].Color;
|
||||||
if I in [0, High(FBWCombs)] then
|
if I in [0, High(FBWCombs)] then
|
||||||
DrawComb(OffScreen.Canvas, FBWCombs[I].Position.X + XOffs, FBWCombs[I].Position.Y + YOffs, 2 * FCombSize)
|
begin
|
||||||
else
|
if Pen.Color = clWhite then
|
||||||
DrawComb(OffScreen.Canvas, FBWCombs[I].Position.X + XOffs, FBWCombs[I].Position.Y + YOffs, FCombSize);
|
Pen.Color := clGray;
|
||||||
|
DrawComb(OffScreen.Canvas, FBWCombs[I].Position.X + XOffs, FBWCombs[I].Position.Y + YOffs, 2 * FCombSize)
|
||||||
|
end else
|
||||||
|
DrawComb(OffScreen.Canvas, FBWCombs[I].Position.X + XOffs, FBWCombs[I].Position.Y + YOffs, FCombSize);
|
||||||
end;
|
end;
|
||||||
// mark selected comb
|
// mark selected comb
|
||||||
if FCustomIndex < 0 then
|
if FCustomIndex < 0 then
|
||||||
@ -384,12 +390,20 @@ begin
|
|||||||
else
|
else
|
||||||
FSelectedCombIndex := -index;
|
FSelectedCombIndex := -index;
|
||||||
Pen.Style := psSolid;
|
Pen.Style := psSolid;
|
||||||
|
{
|
||||||
Pen.Mode := pmXOR;
|
Pen.Mode := pmXOR;
|
||||||
Pen.Color := clWhite;
|
Pen.Color := clWhite;
|
||||||
|
}
|
||||||
|
Pen.Mode := pmCopy;
|
||||||
|
Pen.Color := HighContrastColor(FBWCombs[Index].Color);
|
||||||
Pen.Width := 2;
|
Pen.Width := 2;
|
||||||
Brush.Style := bsClear;
|
Brush.Style := bsClear;
|
||||||
if Index in [0, High(FBWCombs)] then
|
if Index in [0, High(FBWCombs)] then
|
||||||
begin
|
begin
|
||||||
|
if Index = High(FBWCombs) then begin
|
||||||
|
Pen.Color := clWhite;
|
||||||
|
Pen.Mode := pmXOR;
|
||||||
|
end;
|
||||||
if ((FColorCombs[0].Color = Cardinal(clWhite)) and (Index = 0)) or
|
if ((FColorCombs[0].Color = Cardinal(clWhite)) and (Index = 0)) or
|
||||||
((FColorCombs[0].Color = Cardinal(clBlack)) and (Index = High(FBWCombs)))
|
((FColorCombs[0].Color = Cardinal(clBlack)) and (Index = High(FBWCombs)))
|
||||||
then
|
then
|
||||||
|
@ -5,13 +5,18 @@ unit mbUtils;
|
|||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Classes, SysUtils, Graphics;
|
Classes, SysUtils, Graphics, LCLIntf;
|
||||||
|
|
||||||
procedure Clamp(var AValue:Integer; AMin, AMax: Integer);
|
procedure Clamp(var AValue:Integer; AMin, AMax: Integer);
|
||||||
procedure DrawHorDottedLine(ACanvas: TCanvas; X1, X2, Y: Integer; AColor: TColor);
|
procedure DrawHorDottedLine(ACanvas: TCanvas; X1, X2, Y: Integer; AColor: TColor);
|
||||||
function PointInCircle(p: TPoint; Size: integer): boolean;
|
function PointInCircle(p: TPoint; Size: integer): boolean;
|
||||||
function PtInCircle(p, ctr: TPoint; Radius: Integer): Boolean;
|
function PtInCircle(p, ctr: TPoint; Radius: Integer): Boolean;
|
||||||
|
|
||||||
|
function HighContrastColor(AColor: TColor): TColor;
|
||||||
|
|
||||||
|
function HeightOf(R: TRect): Integer;
|
||||||
|
function WidthOf(R: TRect): Integer;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
procedure Clamp(var AValue: integer; AMin, AMax: integer);
|
procedure Clamp(var AValue: integer; AMin, AMax: integer);
|
||||||
@ -41,6 +46,23 @@ begin
|
|||||||
Result := sqr(p.x - ctr.x) + sqr(p.y - ctr.y) <= sqr(Radius);
|
Result := sqr(p.x - ctr.x) + sqr(p.y - ctr.y) <= sqr(Radius);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function HeightOf(R: TRect): Integer;
|
||||||
|
begin
|
||||||
|
Result := R.Bottom - R.Top;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function WidthOf(R: TRect): Integer;
|
||||||
|
begin
|
||||||
|
Result := R.Right - R.Left;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function HighContrastColor(AColor: TColor): TColor;
|
||||||
|
begin
|
||||||
|
if GetRValue(AColor) + GetGValue(AColor) + GetBValue(AColor) > 3*128 then
|
||||||
|
Result := clBlack
|
||||||
|
else
|
||||||
|
Result := clWhite;
|
||||||
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user