|
@@ -1,3 +1,4 @@
|
|
|
|
+// SPDX-License-Identifier: GPL-3.0-only
|
|
unit UChooseColorInterface;
|
|
unit UChooseColorInterface;
|
|
|
|
|
|
{$mode objfpc}{$H+}
|
|
{$mode objfpc}{$H+}
|
|
@@ -24,6 +25,7 @@ type
|
|
EColor: TEdit;
|
|
EColor: TEdit;
|
|
LColor: TLabel;
|
|
LColor: TLabel;
|
|
procedure ContainerResize(Sender: TObject);
|
|
procedure ContainerResize(Sender: TObject);
|
|
|
|
+ procedure SetColorTarget(AValue: TColorTarget);
|
|
procedure vsColorViewMouseDown(Sender: TObject; Button: TMouseButton;
|
|
procedure vsColorViewMouseDown(Sender: TObject; Button: TMouseButton;
|
|
{%H-}Shift: TShiftState; X, Y: Integer);
|
|
{%H-}Shift: TShiftState; X, Y: Integer);
|
|
procedure vsColorViewMouseMove(Sender: TObject; {%H-}Shift: TShiftState; X,
|
|
procedure vsColorViewMouseMove(Sender: TObject; {%H-}Shift: TShiftState; X,
|
|
@@ -44,47 +46,54 @@ type
|
|
FTextAreaHeightComputed: Boolean;
|
|
FTextAreaHeightComputed: Boolean;
|
|
FBarsAlign, FButtonsAlign: TAlign;
|
|
FBarsAlign, FButtonsAlign: TAlign;
|
|
FButtonsCenter: boolean;
|
|
FButtonsCenter: boolean;
|
|
- FTitleFontHeight: integer;
|
|
|
|
|
|
+ FTitleFontHeight: single;
|
|
FColorTitleVisible: boolean;
|
|
FColorTitleVisible: boolean;
|
|
- FWheelArea: TRect;
|
|
|
|
FFormBackgroundColor, FFormTextColor: TBGRAPixel;
|
|
FFormBackgroundColor, FFormTextColor: TBGRAPixel;
|
|
FColorBeforeEColor: TBGRAPixel;
|
|
FColorBeforeEColor: TBGRAPixel;
|
|
|
|
|
|
FInFormMouseMove: Boolean;
|
|
FInFormMouseMove: Boolean;
|
|
- FormMouseMovePos: TPoint;
|
|
|
|
|
|
+ FormMouseMovePos: TPointF;
|
|
|
|
|
|
|
|
+ FColorTarget: TColorTarget;
|
|
FCurrentColor: TBGRAPixel;
|
|
FCurrentColor: TBGRAPixel;
|
|
FColorLight: word;
|
|
FColorLight: word;
|
|
- ColorX,colorY: integer;
|
|
|
|
|
|
+ FColorX,FColorY: single;
|
|
FSelectZone: (szNone, szColorCircle, szLightScale, szAlphascale);
|
|
FSelectZone: (szNone, szColorCircle, szLightScale, szAlphascale);
|
|
|
|
+ FBitmapScale: single;
|
|
FColorCircle: record center: TPointF;
|
|
FColorCircle: record center: TPointF;
|
|
- bounds: TRect;
|
|
|
|
|
|
+ bounds: TRectF;
|
|
bmp,bmpMaxlight: TBGRABitmap; end;
|
|
bmp,bmpMaxlight: TBGRABitmap; end;
|
|
- FLightscale: record bounds: TRect;
|
|
|
|
|
|
+ FLightscale: record bounds: TRectF;
|
|
bmp: TBGRABitmap;
|
|
bmp: TBGRABitmap;
|
|
- cursorRect: TRect; end;
|
|
|
|
- FAlphascale: record bounds: TRect;
|
|
|
|
|
|
+ cursorRect: TRectF; end;
|
|
|
|
+ FAlphascale: record bounds: TRectF;
|
|
bmp: TBGRABitmap;
|
|
bmp: TBGRABitmap;
|
|
- cursorRect: TRect; end;
|
|
|
|
|
|
+ cursorRect: TRectF; end;
|
|
|
|
|
|
- FTopMargin, FBarWidth, FButtonSize, FCursorPlace, FMargin, FInternalMargin,
|
|
|
|
- FCursorMargin, FCursorSize, FColorXYSize, FCursorXYOpacity: integer;
|
|
|
|
|
|
+ FTopMargin, FBarWidth, FCursorPlace, FMargin, FInternalMargin,
|
|
|
|
+ FCursorMargin, FCursorSize, FColorXYSize, FCursorXYWidth: single;
|
|
|
|
+ FButtonSize: integer;
|
|
|
|
|
|
FInitialized: boolean;
|
|
FInitialized: boolean;
|
|
FLazPaintInstance: TLazPaintCustomInstance;
|
|
FLazPaintInstance: TLazPaintCustomInstance;
|
|
|
|
|
|
- function GetAvailableBmpHeight: integer;
|
|
|
|
- function GetAvailableBmpWidth: integer;
|
|
|
|
|
|
+ function GetAvailableVSHeight: integer;
|
|
|
|
+ function GetAvailableVSWidth: integer;
|
|
|
|
+ function InterfaceToPixel(APoint: TPointF): TPoint;
|
|
|
|
+ function InterfaceToPixel(ARect: TRectF): TRect;
|
|
|
|
+ function LCLPosToInterface(APoint: TPoint): TPointF;
|
|
|
|
+ function PixelToInterface(APoint: TPoint): TPointF;
|
|
function GetEditorVisible: boolean;
|
|
function GetEditorVisible: boolean;
|
|
procedure SetDarkTheme(AValue: boolean);
|
|
procedure SetDarkTheme(AValue: boolean);
|
|
procedure SetLazPaintInstance(AValue: TLazPaintCustomInstance);
|
|
procedure SetLazPaintInstance(AValue: TLazPaintCustomInstance);
|
|
procedure UpdateColorview(UpdateColorCircle, UpdateLightScale, Redraw: boolean);
|
|
procedure UpdateColorview(UpdateColorCircle, UpdateLightScale, Redraw: boolean);
|
|
procedure SetColorLight(value: word);
|
|
procedure SetColorLight(value: word);
|
|
function ColorWithLight(c: TBGRAPixel; light: word): TBGRAPixel;
|
|
function ColorWithLight(c: TBGRAPixel; light: word): TBGRAPixel;
|
|
- function BitmapWithLight(bmpsrc: TBGRABitmap; light: word; lookFor: TBGRAPixel; var pColorX,pColorY: integer): TBGRABitmap;
|
|
|
|
|
|
+ function BitmapWithLight(bmpsrc: TBGRABitmap; light: word; lookFor: TBGRAPixel; var pColorX,pColorY: single): TBGRABitmap;
|
|
function ColorLightOf(c: TBGRAPixel): word;
|
|
function ColorLightOf(c: TBGRAPixel): word;
|
|
- function DrawTriangleCursor(dest: TBGRABitmap; bounds: TRect; value: byte): TRect;
|
|
|
|
- procedure DoSelect(X,Y: integer);
|
|
|
|
|
|
+ function DrawTriangleCursor(dest: TBGRABitmap; bounds: TRectF; value, maxValue: integer): TRectF;
|
|
|
|
+ procedure DoClick(X,Y: single);
|
|
|
|
+ procedure DoSelect(X,Y: single);
|
|
function MakeIconBase(size: integer): TBitmap;
|
|
function MakeIconBase(size: integer): TBitmap;
|
|
function MakeAddIcon(size: integer): TBitmap;
|
|
function MakeAddIcon(size: integer): TBitmap;
|
|
function MakeRemoveIcon(size: integer): TBitmap;
|
|
function MakeRemoveIcon(size: integer): TBitmap;
|
|
@@ -92,17 +101,17 @@ type
|
|
|
|
|
|
procedure ApplyTheme;
|
|
procedure ApplyTheme;
|
|
procedure UpdateButtonLayout;
|
|
procedure UpdateButtonLayout;
|
|
- function SetRectBounds(var ABounds: TRect; ANewBounds: TRect): boolean;
|
|
|
|
|
|
+ function SetRectBounds(var ABounds: TRectF; ANewBounds: TRectF): boolean;
|
|
function PreferredBarsAlignWithWidth: TAlign;
|
|
function PreferredBarsAlignWithWidth: TAlign;
|
|
procedure UpdateLayout;
|
|
procedure UpdateLayout;
|
|
function GetAlphaScaleBmp: TBGRABitmap;
|
|
function GetAlphaScaleBmp: TBGRABitmap;
|
|
function GetLightScaleBmp: TBGRABitmap;
|
|
function GetLightScaleBmp: TBGRABitmap;
|
|
function GetColorCircleMaxLightBmp: TBGRABitmap;
|
|
function GetColorCircleMaxLightBmp: TBGRABitmap;
|
|
function GetColorCircleBmp: TBGRABitmap;
|
|
function GetColorCircleBmp: TBGRABitmap;
|
|
- property AvailableBmpHeight: integer read GetAvailableBmpHeight;
|
|
|
|
- property AvailableBmpWidth: integer read GetAvailableBmpWidth;
|
|
|
|
|
|
+ property AvailableVSHeight: integer read GetAvailableVSHeight;
|
|
|
|
+ property AvailableVSWidth: integer read GetAvailableVSWidth;
|
|
public
|
|
public
|
|
- ColorTarget: TColorTarget;
|
|
|
|
|
|
+
|
|
|
|
|
|
constructor Create(AContainer: TWinControl; ADPI: integer);
|
|
constructor Create(AContainer: TWinControl; ADPI: integer);
|
|
destructor Destroy; override;
|
|
destructor Destroy; override;
|
|
@@ -116,11 +125,13 @@ type
|
|
property DarkTheme: boolean read FDarkTheme write SetDarkTheme;
|
|
property DarkTheme: boolean read FDarkTheme write SetDarkTheme;
|
|
property LazPaintInstance: TLazPaintCustomInstance read FLazPaintInstance write SetLazPaintInstance;
|
|
property LazPaintInstance: TLazPaintCustomInstance read FLazPaintInstance write SetLazPaintInstance;
|
|
property EditorVisible: boolean read GetEditorVisible;
|
|
property EditorVisible: boolean read GetEditorVisible;
|
|
|
|
+ property ColorTarget: TColorTarget read FColorTarget write SetColorTarget;
|
|
end;
|
|
end;
|
|
|
|
|
|
implementation
|
|
implementation
|
|
|
|
|
|
-uses math, Forms, UResourceStrings, LCLType, UDarkTheme, LCScaleDPI, UGraph, BGRAText;
|
|
|
|
|
|
+uses math, Forms, UResourceStrings, LCLType, UDarkTheme, LCScaleDPI, UGraph, BGRAText,
|
|
|
|
+ BGRAClasses;
|
|
|
|
|
|
{ TChooseColorInterface }
|
|
{ TChooseColorInterface }
|
|
|
|
|
|
@@ -134,29 +145,16 @@ begin
|
|
EColor.Hide;
|
|
EColor.Hide;
|
|
LColor.Show;
|
|
LColor.Show;
|
|
end;
|
|
end;
|
|
- if PtInRect(Point(X,Y), FColorCircle.Bounds) then
|
|
|
|
- begin
|
|
|
|
- FSelectZone := szColorCircle;
|
|
|
|
- DoSelect(X,Y);
|
|
|
|
- end else
|
|
|
|
- if PtInRect(Point(X,Y), FAlphascale.Bounds) or PtInRect(Point(X,Y), FAlphascale.cursorRect) then
|
|
|
|
- begin
|
|
|
|
- FSelectZone := szAlphascale;
|
|
|
|
- DoSelect(X,Y);
|
|
|
|
- end else
|
|
|
|
- if PtInRect(Point(X,Y), FLightscale.Bounds) or PtInRect(Point(X,Y), FLightscale.cursorRect) then
|
|
|
|
- begin
|
|
|
|
- FSelectZone := szLightscale;
|
|
|
|
- DoSelect(X,Y);
|
|
|
|
- end;
|
|
|
|
|
|
+ with LCLPosToInterface(Point(X, Y)) do
|
|
|
|
+ DoClick(X,Y);
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
|
|
procedure TChooseColorInterface.ContainerResize(Sender: TObject);
|
|
procedure TChooseColorInterface.ContainerResize(Sender: TObject);
|
|
begin
|
|
begin
|
|
NeedTextAreaHeight;
|
|
NeedTextAreaHeight;
|
|
- vsColorView.Width := AvailableBmpWidth;
|
|
|
|
- vsColorView.Height := AvailableBmpHeight;
|
|
|
|
|
|
+ vsColorView.Width := AvailableVSWidth;
|
|
|
|
+ vsColorView.Height := AvailableVSHeight;
|
|
EColor.Left := ExternalMargin;
|
|
EColor.Left := ExternalMargin;
|
|
EColor.Width := Container.ClientWidth - 2*ExternalMargin;
|
|
EColor.Width := Container.ClientWidth - 2*ExternalMargin;
|
|
LColor.Left := ExternalMargin;
|
|
LColor.Left := ExternalMargin;
|
|
@@ -166,14 +164,21 @@ begin
|
|
UpdateLayout;
|
|
UpdateLayout;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+procedure TChooseColorInterface.SetColorTarget(AValue: TColorTarget);
|
|
|
|
+begin
|
|
|
|
+ if FColorTarget=AValue then Exit;
|
|
|
|
+ FColorTarget:=AValue;
|
|
|
|
+ vsColorView.DiscardBitmap;
|
|
|
|
+end;
|
|
|
|
+
|
|
procedure TChooseColorInterface.vsColorViewMouseMove(Sender: TObject;
|
|
procedure TChooseColorInterface.vsColorViewMouseMove(Sender: TObject;
|
|
Shift: TShiftState; X, Y: Integer);
|
|
Shift: TShiftState; X, Y: Integer);
|
|
begin
|
|
begin
|
|
- FormMouseMovePos := Point(X,Y);
|
|
|
|
|
|
+ FormMouseMovePos := LCLPosToInterface(Point(X,Y));
|
|
if FInFormMouseMove then Exit;
|
|
if FInFormMouseMove then Exit;
|
|
FInFormMouseMove := True;
|
|
FInFormMouseMove := True;
|
|
Application.ProcessMessages; //empty message stack
|
|
Application.ProcessMessages; //empty message stack
|
|
- DoSelect(FormMouseMovePos.X,FormMouseMovePos.Y);
|
|
|
|
|
|
+ DoSelect(FormMouseMovePos.X, FormMouseMovePos.Y);
|
|
FInFormMouseMove := False;
|
|
FInFormMouseMove := False;
|
|
end;
|
|
end;
|
|
|
|
|
|
@@ -185,80 +190,115 @@ end;
|
|
|
|
|
|
procedure TChooseColorInterface.vsColorViewRedraw(Sender: TObject;
|
|
procedure TChooseColorInterface.vsColorViewRedraw(Sender: TObject;
|
|
Bitmap: TBGRABitmap);
|
|
Bitmap: TBGRABitmap);
|
|
-var x,y: integer;
|
|
|
|
- boundRight,w: integer;
|
|
|
|
- size: single;
|
|
|
|
|
|
+var
|
|
|
|
+ textBoundRight: single;
|
|
|
|
+
|
|
|
|
+ procedure AddTitle(xRef: single; AText: string);
|
|
|
|
+ var x, w: single;
|
|
|
|
+ begin
|
|
|
|
+ w := Bitmap.TextSize(AText).cx / FBitmapScale;
|
|
|
|
+ x := xRef - w/2;
|
|
|
|
+ x := min(x, textBoundRight - w);
|
|
|
|
+ x := max(x, FButtonSize + FMargin + FMargin / 2);
|
|
|
|
+ if x > textBoundRight - w then exit;
|
|
|
|
+ with InterfaceToPixel(PointF(x, FMargin/2)) do
|
|
|
|
+ Bitmap.TextOut(x, y, AText, FFormTextColor, taLeftJustify);
|
|
|
|
+ textBoundRight := x - FMargin/2;
|
|
|
|
+ end;
|
|
|
|
+
|
|
|
|
+var
|
|
|
|
+ bmpRect: TRect;
|
|
|
|
+ previewSize: single;
|
|
|
|
+ previewRect: TRectF;
|
|
c: TBGRAPixel;
|
|
c: TBGRAPixel;
|
|
|
|
+ bmpColorXYSize: integer;
|
|
|
|
+ bmpCursorWidth, i: integer;
|
|
|
|
+ bmpCursorOpacity: byte;
|
|
|
|
+ s: String;
|
|
begin
|
|
begin
|
|
- Bitmap.FontHeight := FTitleFontHeight;
|
|
|
|
|
|
+ if vsColorView.Width <> 0 then
|
|
|
|
+ FBitmapScale := Bitmap.Width / vsColorView.Width
|
|
|
|
+ else FBitmapScale := 1;
|
|
|
|
+ Bitmap.FontHeight := round(FTitleFontHeight * FBitmapScale);
|
|
Bitmap.FontAntialias := True;
|
|
Bitmap.FontAntialias := True;
|
|
- boundRight := Bitmap.Width;
|
|
|
|
|
|
+ textBoundRight := Bitmap.Width / FBitmapScale;
|
|
if Assigned(GetAlphaScaleBmp) then
|
|
if Assigned(GetAlphaScaleBmp) then
|
|
begin
|
|
begin
|
|
- w := Bitmap.TextSize(rsOpacity).cx;
|
|
|
|
if FBarsAlign = alRight then
|
|
if FBarsAlign = alRight then
|
|
- begin
|
|
|
|
- x := (FAlphascale.bounds.Left+FAlphascale.bounds.Right-w) div 2;
|
|
|
|
- if x + w > boundRight then
|
|
|
|
- x := boundRight-w;
|
|
|
|
- Bitmap.TextOut(x, FMargin div 2, rsOpacity, FFormTextColor, taLeftJustify);
|
|
|
|
- boundRight := x - FMargin div 2;
|
|
|
|
- end;
|
|
|
|
- Bitmap.PutImage(FAlphascale.bounds.Left, FAlphascale.bounds.top,
|
|
|
|
- GetAlphaScaleBmp, dmDrawWithTransparency);
|
|
|
|
- Bitmap.Rectangle(FAlphascale.bounds,
|
|
|
|
|
|
+ AddTitle((FAlphascale.bounds.Left + FAlphascale.bounds.Right) / 2, rsOpacity);
|
|
|
|
+ bmpRect := InterfaceToPixel(FAlphascale.bounds);
|
|
|
|
+ Bitmap.PutImage(bmpRect.Left, bmpRect.Top, GetAlphaScaleBmp, dmDrawWithTransparency);
|
|
|
|
+ Bitmap.Rectangle(bmpRect,
|
|
BGRA(FFormTextColor.red, FFormTextColor.green, FFormTextColor.Blue,128),
|
|
BGRA(FFormTextColor.red, FFormTextColor.green, FFormTextColor.Blue,128),
|
|
dmDrawWithTransparency);
|
|
dmDrawWithTransparency);
|
|
- FAlphascale.cursorRect := DrawTriangleCursor(Bitmap, FAlphascale.bounds, FCurrentColor.alpha);
|
|
|
|
- end else FAlphascale.cursorRect := EmptyRect;
|
|
|
|
|
|
+ FAlphascale.cursorRect := DrawTriangleCursor(Bitmap, FAlphascale.bounds, FCurrentColor.alpha, 255);
|
|
|
|
+ end else FAlphascale.cursorRect := EmptyRectF;
|
|
|
|
|
|
if Assigned(GetLightscaleBmp) then
|
|
if Assigned(GetLightscaleBmp) then
|
|
begin
|
|
begin
|
|
- w := Bitmap.TextSize(rsLight).cx;
|
|
|
|
if FBarsAlign = alRight then
|
|
if FBarsAlign = alRight then
|
|
- begin
|
|
|
|
- x := (FLightscale.bounds.Left + FLightscale.bounds.Right-w) div 2;
|
|
|
|
- if x+ w > boundRight then
|
|
|
|
- x:= boundRight-w;
|
|
|
|
- Bitmap.TextOut(x, FMargin div 2, rsLight, FFormTextColor, taLeftJustify);
|
|
|
|
- boundRight := x - FMargin div 2;
|
|
|
|
- end;
|
|
|
|
- Bitmap.PutImage(FLightscale.bounds.Left, FLightscale.bounds.top, GetLightscaleBmp, dmFastBlend);
|
|
|
|
- Bitmap.Rectangle(FLightscale.bounds,
|
|
|
|
|
|
+ AddTitle((FLightscale.bounds.Left + FLightscale.bounds.Right) / 2, rsLight);
|
|
|
|
+ bmpRect := InterfaceToPixel(FLightscale.bounds);
|
|
|
|
+ Bitmap.PutImage(bmpRect.Left, bmpRect.top, GetLightscaleBmp, dmFastBlend);
|
|
|
|
+ Bitmap.Rectangle(bmpRect,
|
|
BGRA(FFormTextColor.red, FFormTextColor.green, FFormTextColor.Blue, 128),
|
|
BGRA(FFormTextColor.red, FFormTextColor.green, FFormTextColor.Blue, 128),
|
|
dmDrawWithTransparency);
|
|
dmDrawWithTransparency);
|
|
- FLightscale.cursorRect := DrawTriangleCursor(Bitmap, FLightscale.bounds, FColorLight div 256);
|
|
|
|
- end else FLightscale.cursorRect := EmptyRect;
|
|
|
|
|
|
+ FLightscale.cursorRect := DrawTriangleCursor(Bitmap, FLightscale.bounds, FColorLight, 65535);
|
|
|
|
+ end else FLightscale.cursorRect := EmptyRectF;
|
|
|
|
|
|
if Assigned(GetColorCircleBmp) and not FColorCircle.bounds.IsEmpty then
|
|
if Assigned(GetColorCircleBmp) and not FColorCircle.bounds.IsEmpty then
|
|
begin
|
|
begin
|
|
if FColorTitleVisible then
|
|
if FColorTitleVisible then
|
|
begin
|
|
begin
|
|
- w := Bitmap.TextSize(rsColors).cx;
|
|
|
|
- x := round(FColorCircle.center.X - w/2);
|
|
|
|
- x := min(x, boundRight-w);
|
|
|
|
- x := max(x, FButtonSize + FMargin + FMargin div 2);
|
|
|
|
- if x <= boundRight-w then
|
|
|
|
- Bitmap.TextOut(x, FMargin div 2, rsColors, FFormTextColor, taLeftJustify);
|
|
|
|
|
|
+ case ColorTarget of
|
|
|
|
+ ctForeColorSolid..ctForeColorEndGrad: s := rsPen;
|
|
|
|
+ ctBackColorSolid..ctBackColorEndGrad: s := rsBack;
|
|
|
|
+ ctOutlineColorSolid..ctOutlineColorEndGrad: s := rsTextOutline;
|
|
|
|
+ else s := rsColors;
|
|
|
|
+ end;
|
|
|
|
+ case ColorTarget of
|
|
|
|
+ ctForeColorStartGrad,ctBackColorStartGrad,ctOutlineColorStartGrad: s += '[1]';
|
|
|
|
+ ctForeColorEndGrad,ctBackColorEndGrad,ctOutlineColorEndGrad: s += '[2]';
|
|
|
|
+ end;
|
|
|
|
+ AddTitle(FColorCircle.center.X, s);
|
|
|
|
+ end;
|
|
|
|
+ bmpRect := InterfaceToPixel(FColorCircle.bounds);
|
|
|
|
+ Bitmap.PutImage(bmpRect.Left, bmpRect.top, GetColorCircleBmp, dmDrawWithTransparency);
|
|
|
|
+ bmpCursorWidth := round(FCursorXYWidth * FBitmapScale);
|
|
|
|
+ if FCursorXYWidth * FBitmapScale < 1 then
|
|
|
|
+ bmpCursorOpacity := round(FCursorXYWidth * FBitmapScale * 255)
|
|
|
|
+ else bmpCursorOpacity := 255;
|
|
|
|
+ with InterfaceToPixel(FColorCircle.bounds.TopLeft + PointF(FColorX, FColorY)) do
|
|
|
|
+ begin
|
|
|
|
+ bmpColorXYSize := round(FColorXYSize * FBitmapScale);
|
|
|
|
+ bmpRect := rect(x-bmpColorXYSize, y-bmpColorXYSize, x+bmpColorXYSize+1, y+bmpColorXYSize+1);
|
|
|
|
+ bmpRect.Inflate(-1, -1);
|
|
|
|
+ Bitmap.Rectangle(bmpRect, BGRA(0,0,0,bmpCursorOpacity), dmDrawWithTransparency);
|
|
|
|
+ bmpRect.Inflate(1, 1);
|
|
|
|
+ for i := 1 to bmpCursorWidth do
|
|
|
|
+ begin
|
|
|
|
+ Bitmap.Rectangle(bmpRect, BGRA(255,255,255,bmpCursorOpacity), dmDrawWithTransparency);
|
|
|
|
+ bmpRect.Inflate(1, 1);
|
|
|
|
+ end;
|
|
|
|
+ Bitmap.Rectangle(bmpRect, BGRA(0,0,0,bmpCursorOpacity), dmDrawWithTransparency);
|
|
|
|
+ end;
|
|
|
|
+ previewSize := round(FBarWidth*0.9);
|
|
|
|
+ previewRect.Left := FMargin - ExternalMargin;
|
|
|
|
+ if FBarsAlign = alBottom then
|
|
|
|
+ previewRect.Top := FLightscale.bounds.Top - FMargin - previewSize
|
|
|
|
+ else previewRect.Top := Bitmap.Height/FBitmapScale - FMargin - previewSize;
|
|
|
|
+ previewRect.Right := previewRect.Left + previewSize;
|
|
|
|
+ previewRect.Bottom := previewRect.Top + previewSize;
|
|
|
|
+
|
|
|
|
+ if previewRect.Top >= BCButton_RemoveFromPalette.Top + BCButton_RemoveFromPalette.Height
|
|
|
|
+ + FMargin / 2 then
|
|
|
|
+ begin
|
|
|
|
+ c := GetCurrentColor;
|
|
|
|
+ c.alpha := 255;
|
|
|
|
+ with InterfaceToPixel(previewRect) do
|
|
|
|
+ Bitmap.RoundRectAntialias(Left, Top, Right - 1, Bottom - 1,
|
|
|
|
+ previewSize/6, previewSize/6, BGRA(0,0,0,192), bmpCursorWidth, c, []);
|
|
end;
|
|
end;
|
|
- Bitmap.PutImage(FColorCircle.bounds.Left, FColorCircle.bounds.top, GetColorCircleBmp, dmDrawWithTransparency);
|
|
|
|
- x := FColorCircle.bounds.Left+ColorX;
|
|
|
|
- y := FColorCircle.bounds.top+ColorY;
|
|
|
|
- Bitmap.Rectangle(x-FColorXYSize-1, y-FColorXYSize-1, x+FColorXYSize+2, y+FColorXYSize+2,
|
|
|
|
- BGRA(0,0,0,FCursorXYOpacity), dmDrawWithTransparency);
|
|
|
|
- Bitmap.Rectangle(x-FColorXYSize, y-FColorXYSize, x+FColorXYSize+1, y+FColorXYSize+1,
|
|
|
|
- BGRA(255,255,255,FCursorXYOpacity), dmDrawWithTransparency);
|
|
|
|
- Bitmap.Rectangle(x-FColorXYSize+1, y-FColorXYSize+1, x+FColorXYSize, y+FColorXYSize,
|
|
|
|
- BGRA(0,0,0,FCursorXYOpacity), dmDrawWithTransparency);
|
|
|
|
- size := round(FBarWidth*0.9);
|
|
|
|
- c := GetCurrentColor;
|
|
|
|
- c.alpha := 255;
|
|
|
|
- x := FMargin - ExternalMargin;
|
|
|
|
- if FBarsAlign = alBottom then y := round(FLightscale.bounds.Top-FMargin-1-size)
|
|
|
|
- else y := round(Bitmap.Height - FMargin - size);
|
|
|
|
- if y >= BCButton_RemoveFromPalette.Top + BCButton_RemoveFromPalette.Height + FMargin div 2 then
|
|
|
|
- Bitmap.RoundRectAntialias(x, y, x + size, y + size,
|
|
|
|
- size/6,size/6, BGRA(0,0,0,192), 1, c, []);
|
|
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
|
|
@@ -334,16 +374,39 @@ begin
|
|
SafeSetFocus(EColor);
|
|
SafeSetFocus(EColor);
|
|
end;
|
|
end;
|
|
|
|
|
|
-function TChooseColorInterface.GetAvailableBmpHeight: integer;
|
|
|
|
|
|
+function TChooseColorInterface.GetAvailableVSHeight: integer;
|
|
begin
|
|
begin
|
|
result := Container.ClientHeight - FTextAreaHeight - ExternalMargin;
|
|
result := Container.ClientHeight - FTextAreaHeight - ExternalMargin;
|
|
end;
|
|
end;
|
|
|
|
|
|
-function TChooseColorInterface.GetAvailableBmpWidth: integer;
|
|
|
|
|
|
+function TChooseColorInterface.GetAvailableVSWidth: integer;
|
|
begin
|
|
begin
|
|
result := Container.ClientWidth - ExternalMargin*2;
|
|
result := Container.ClientWidth - ExternalMargin*2;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+function TChooseColorInterface.InterfaceToPixel(APoint: TPointF): TPoint;
|
|
|
|
+begin
|
|
|
|
+ result := (APoint * FBitmapScale).Truncate;
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+function TChooseColorInterface.InterfaceToPixel(ARect: TRectF): TRect;
|
|
|
|
+begin
|
|
|
|
+ result.TopLeft := InterfaceToPixel(ARect.TopLeft);
|
|
|
|
+ result.BottomRight := InterfaceToPixel(ARect.BottomRight);
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+function TChooseColorInterface.LCLPosToInterface(APoint: TPoint): TPointF;
|
|
|
|
+begin
|
|
|
|
+ result.x := APoint.x + 0.5 / FBitmapScale;
|
|
|
|
+ result.y := APoint.y + 0.5 / FBitmapScale;
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+function TChooseColorInterface.PixelToInterface(APoint: TPoint): TPointF;
|
|
|
|
+begin
|
|
|
|
+ result.x := (APoint.x + 0.5) / FBitmapScale;
|
|
|
|
+ result.y := (APoint.y + 0.5) / FBitmapScale;
|
|
|
|
+end;
|
|
|
|
+
|
|
function TChooseColorInterface.GetEditorVisible: boolean;
|
|
function TChooseColorInterface.GetEditorVisible: boolean;
|
|
begin
|
|
begin
|
|
result := Assigned(EColor) and EColor.Visible;
|
|
result := Assigned(EColor) and EColor.Visible;
|
|
@@ -420,7 +483,7 @@ begin
|
|
end;
|
|
end;
|
|
|
|
|
|
function TChooseColorInterface.BitmapWithLight(bmpsrc: TBGRABitmap;
|
|
function TChooseColorInterface.BitmapWithLight(bmpsrc: TBGRABitmap;
|
|
- light: word; lookFor: TBGRAPixel; var pColorX, pColorY: integer): TBGRABitmap;
|
|
|
|
|
|
+ light: word; lookFor: TBGRAPixel; var pColorX, pColorY: single): TBGRABitmap;
|
|
var xb,yb: integer;
|
|
var xb,yb: integer;
|
|
psrc,pdest: PBGRAPixel;
|
|
psrc,pdest: PBGRAPixel;
|
|
dist,newDist: integer;
|
|
dist,newDist: integer;
|
|
@@ -464,8 +527,12 @@ begin
|
|
result.InvalidateBitmap;
|
|
result.InvalidateBitmap;
|
|
if colorXYnb <> 0 then
|
|
if colorXYnb <> 0 then
|
|
begin
|
|
begin
|
|
- pColorX := (ColorXsum + colorXYnb shr 1) div colorXYnb;
|
|
|
|
- pColorY := (ColorYsum + colorXYnb shr 1) div colorXYnb;
|
|
|
|
|
|
+ with PixelToInterface(Point((ColorXsum + colorXYnb shr 1) div colorXYnb,
|
|
|
|
+ (ColorYsum + colorXYnb shr 1) div colorXYnb)) do
|
|
|
|
+ begin
|
|
|
|
+ pColorX := x;
|
|
|
|
+ pColorY := y;
|
|
|
|
+ end;
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
|
|
@@ -478,29 +545,52 @@ begin
|
|
end;
|
|
end;
|
|
|
|
|
|
function TChooseColorInterface.DrawTriangleCursor(dest: TBGRABitmap;
|
|
function TChooseColorInterface.DrawTriangleCursor(dest: TBGRABitmap;
|
|
- bounds: TRect; value: byte): TRect;
|
|
|
|
-var x,y: integer;
|
|
|
|
|
|
+ bounds: TRectF; value, maxValue: integer): TRectF;
|
|
|
|
+var x,y: single;
|
|
|
|
+ bmpCursorSize: integer;
|
|
begin
|
|
begin
|
|
|
|
+ bmpCursorSize := round(FCursorSize * FBitmapScale);
|
|
if FBarsAlign = alRight then
|
|
if FBarsAlign = alRight then
|
|
begin
|
|
begin
|
|
x := bounds.right + FCursorMargin;
|
|
x := bounds.right + FCursorMargin;
|
|
- y := bounds.bottom-1 - round(value/255*(bounds.height-1));
|
|
|
|
- dest.FillPolyAntialias([pointF(x, y), pointF(x+FCursorSize, y-FCursorSize),
|
|
|
|
- pointF(x+FCursorSize, y+FCursorSize)], FFormTextColor);
|
|
|
|
- result := rect(floor(x-FCursorSize/2), floor(y-FCursorSize*1.5),
|
|
|
|
- ceil(x+FCursorSize*1.5), ceil(y+FCursorSize*1.5));
|
|
|
|
|
|
+ y := bounds.top + (maxValue - value) / (maxValue + 1) * bounds.height;
|
|
|
|
+ with InterfaceToPixel(PointF(x, y)) do
|
|
|
|
+ dest.FillPolyAntialias([pointF(x, y), pointF(x+bmpCursorSize, y-bmpCursorSize),
|
|
|
|
+ pointF(x+bmpCursorSize, y+bmpCursorSize)], FFormTextColor);
|
|
|
|
+ result := rectF(x - FCursorSize/2, y - FCursorSize*1.5,
|
|
|
|
+ x + FCursorSize*1.5, y + FCursorSize*1.5);
|
|
end else
|
|
end else
|
|
begin
|
|
begin
|
|
- x := bounds.left + round(value/255*(bounds.Width-1));
|
|
|
|
|
|
+ x := bounds.left + value / (maxValue + 1) * bounds.Width;
|
|
y := bounds.bottom + FCursorMargin;
|
|
y := bounds.bottom + FCursorMargin;
|
|
- dest.FillPolyAntialias([pointF(x, y), pointF(x+FCursorSize,y+FCursorSize),
|
|
|
|
- pointF(x-FCursorSize, y+FCursorSize)], FFormTextColor);
|
|
|
|
- result := rect(floor(x-FCursorSize*1.5), floor(y-FCursorSize/2),
|
|
|
|
- ceil(x+FCursorSize*1.5), ceil(y+FCursorSize*1.5));
|
|
|
|
|
|
+ with InterfaceToPixel(PointF(x, y)) do
|
|
|
|
+ dest.FillPolyAntialias([pointF(x, y), pointF(x+bmpCursorSize,y+bmpCursorSize),
|
|
|
|
+ pointF(x-bmpCursorSize, y+bmpCursorSize)], FFormTextColor);
|
|
|
|
+ result := rectF(x - FCursorSize*1.5, y - FCursorSize/2,
|
|
|
|
+ x + FCursorSize*1.5, y + FCursorSize*1.5);
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
|
|
-procedure TChooseColorInterface.DoSelect(X, Y: integer);
|
|
|
|
|
|
+procedure TChooseColorInterface.DoClick(X, Y: single);
|
|
|
|
+begin
|
|
|
|
+ if FColorCircle.Bounds.Contains(PointF(X,Y)) then
|
|
|
|
+ begin
|
|
|
|
+ FSelectZone := szColorCircle;
|
|
|
|
+ DoSelect(X,Y);
|
|
|
|
+ end else
|
|
|
|
+ if FAlphascale.Bounds.Contains(PointF(X,Y)) or FAlphascale.cursorRect.Contains(PointF(X,Y)) then
|
|
|
|
+ begin
|
|
|
|
+ FSelectZone := szAlphascale;
|
|
|
|
+ DoSelect(X,Y);
|
|
|
|
+ end else
|
|
|
|
+ if FLightscale.Bounds.Contains(PointF(X,Y)) or FLightscale.cursorRect.Contains(PointF(X,Y)) then
|
|
|
|
+ begin
|
|
|
|
+ FSelectZone := szLightscale;
|
|
|
|
+ DoSelect(X,Y);
|
|
|
|
+ end;
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+procedure TChooseColorInterface.DoSelect(X, Y: single);
|
|
var pix, newColor: TBGRAPixel;
|
|
var pix, newColor: TBGRAPixel;
|
|
newLight: Word;
|
|
newLight: Word;
|
|
dist: single;
|
|
dist: single;
|
|
@@ -509,8 +599,10 @@ begin
|
|
szAlphascale:
|
|
szAlphascale:
|
|
begin
|
|
begin
|
|
if FBarsAlign = alRight then
|
|
if FBarsAlign = alRight then
|
|
- FCurrentColor.alpha := max(0, min(255, 255-round((Y-FAlphascale.Bounds.Top)/(FAlphascale.Bounds.Height-1)*255)))
|
|
|
|
- else FCurrentColor.alpha := max(0, min(255, round((X-FAlphascale.Bounds.Left)/(FAlphascale.Bounds.Width-1)*255)));
|
|
|
|
|
|
+ FCurrentColor.alpha := max(0, min(255, 255 -
|
|
|
|
+ trunc((Y-FAlphascale.Bounds.Top) / FAlphascale.Bounds.Height * 256) ))
|
|
|
|
+ else FCurrentColor.alpha := max(0, min(255,
|
|
|
|
+ trunc((X-FAlphascale.Bounds.Left) / FAlphascale.Bounds.Width * 256) ));
|
|
UpdateColorview(False, False, True);
|
|
UpdateColorview(False, False, True);
|
|
end;
|
|
end;
|
|
szColorCircle:
|
|
szColorCircle:
|
|
@@ -520,18 +612,19 @@ begin
|
|
sqr((y-FColorCircle.center.Y)/FColorCircle.bounds.Height*2));
|
|
sqr((y-FColorCircle.center.Y)/FColorCircle.bounds.Height*2));
|
|
if dist > 1 then
|
|
if dist > 1 then
|
|
begin
|
|
begin
|
|
- x := round(FColorCircle.center.X + (x-FColorCircle.center.X)/dist);
|
|
|
|
- y := round(FColorCircle.center.Y + (y-FColorCircle.center.Y)/dist);
|
|
|
|
|
|
+ x := FColorCircle.center.X + (x - FColorCircle.center.X)/dist;
|
|
|
|
+ y := FColorCircle.center.Y + (y - FColorCircle.center.Y)/dist;
|
|
end;
|
|
end;
|
|
- pix := FColorCircle.bmpMaxlight.GetPixel(x-FColorCircle.Bounds.Left,y-FColorCircle.Bounds.top);
|
|
|
|
|
|
+ with InterfaceToPixel(PointF(x,y) - FColorCircle.bounds.TopLeft) do
|
|
|
|
+ pix := FColorCircle.bmpMaxlight.GetPixel(x,y);
|
|
if pix.alpha <> 0 then
|
|
if pix.alpha <> 0 then
|
|
begin
|
|
begin
|
|
newColor := BGRA(pix.Red,pix.Green,pix.Blue,FCurrentColor.Alpha);
|
|
newColor := BGRA(pix.Red,pix.Green,pix.Blue,FCurrentColor.Alpha);
|
|
if not FCurrentColor.EqualsExactly(newColor) then
|
|
if not FCurrentColor.EqualsExactly(newColor) then
|
|
begin
|
|
begin
|
|
FCurrentColor := newColor;
|
|
FCurrentColor := newColor;
|
|
- ColorX := x-FColorCircle.Bounds.Left;
|
|
|
|
- ColorY := y-FColorCircle.Bounds.top;
|
|
|
|
|
|
+ FColorX := x-FColorCircle.Bounds.Left;
|
|
|
|
+ FColorY := y-FColorCircle.Bounds.top;
|
|
UpdateColorview(False, True, True);
|
|
UpdateColorview(False, True, True);
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
@@ -539,8 +632,10 @@ begin
|
|
szLightScale:
|
|
szLightScale:
|
|
begin
|
|
begin
|
|
if FBarsAlign = alRight then
|
|
if FBarsAlign = alRight then
|
|
- newLight := max(0, min(65535, 65535 - round((Y-FLightscale.Bounds.Top)/(FLightscale.Bounds.Height-1)*65535)))
|
|
|
|
- else newLight := max(0, min(65535, round((X-FLightscale.Bounds.Left)/(FLightscale.Bounds.Width-1)*65535)));
|
|
|
|
|
|
+ newLight := max(0, min(65535, 65535 -
|
|
|
|
+ trunc((Y-FLightscale.Bounds.Top) / FLightscale.Bounds.Height * 65536) ))
|
|
|
|
+ else newLight := max(0, min(65535,
|
|
|
|
+ trunc((X-FLightscale.Bounds.Left) / FLightscale.Bounds.Width * 65536)));
|
|
SetColorLight(newLight);
|
|
SetColorLight(newLight);
|
|
end;
|
|
end;
|
|
else exit;
|
|
else exit;
|
|
@@ -640,8 +735,8 @@ begin
|
|
FFormTextColor := clLightText;
|
|
FFormTextColor := clLightText;
|
|
end else
|
|
end else
|
|
begin
|
|
begin
|
|
- FFormBackgroundColor := ColorToBGRA(ColorToRGB({$IFDEF DARWIN}clWindow{$ELSE}clBtnFace{$ENDIF}));
|
|
|
|
- FFormTextColor := ColorToBGRA(ColorToRGB(clWindowText));
|
|
|
|
|
|
+ FFormBackgroundColor := clForm;
|
|
|
|
+ FFormTextColor := clWindowText;
|
|
end;
|
|
end;
|
|
Container.Color := FFormBackgroundColor;
|
|
Container.Color := FFormBackgroundColor;
|
|
vsColorView.Color := FFormBackgroundColor;
|
|
vsColorView.Color := FFormBackgroundColor;
|
|
@@ -653,27 +748,27 @@ var
|
|
iconSize: Integer;
|
|
iconSize: Integer;
|
|
tmpIcon: TBitmap;
|
|
tmpIcon: TBitmap;
|
|
begin
|
|
begin
|
|
- FButtonSize := FBarWidth;
|
|
|
|
|
|
+ FButtonSize := round(FBarWidth);
|
|
BCButton_AddToPalette.Width := FButtonSize;
|
|
BCButton_AddToPalette.Width := FButtonSize;
|
|
BCButton_AddToPalette.Height := FButtonSize;
|
|
BCButton_AddToPalette.Height := FButtonSize;
|
|
BCButton_RemoveFromPalette.Width := FButtonSize;
|
|
BCButton_RemoveFromPalette.Width := FButtonSize;
|
|
BCButton_RemoveFromPalette.Height := FButtonSize;
|
|
BCButton_RemoveFromPalette.Height := FButtonSize;
|
|
- BCButton_AddToPalette.Left := FMargin - ExternalMargin;
|
|
|
|
- BCButton_AddToPalette.Top := FMargin div 2;
|
|
|
|
|
|
+ BCButton_AddToPalette.Left := round(FMargin - ExternalMargin);
|
|
|
|
+ BCButton_AddToPalette.Top := round(FMargin / 2);
|
|
if FButtonsAlign = alLeft then
|
|
if FButtonsAlign = alLeft then
|
|
begin
|
|
begin
|
|
if FButtonsCenter then
|
|
if FButtonsCenter then
|
|
- BCButton_AddToPalette.Top := (AvailableBmpHeight -
|
|
|
|
|
|
+ BCButton_AddToPalette.Top := (AvailableVSHeight -
|
|
BCButton_AddToPalette.Height - BCButton_RemoveFromPalette.Height) div 2;
|
|
BCButton_AddToPalette.Height - BCButton_RemoveFromPalette.Height) div 2;
|
|
- BCButton_RemoveFromPalette.Left := FMargin - ExternalMargin;
|
|
|
|
- BCButton_RemoveFromPalette.Top := BCButton_AddToPalette.Top+BCButton_AddToPalette.Height;
|
|
|
|
|
|
+ BCButton_RemoveFromPalette.Left := round(FMargin - ExternalMargin);
|
|
|
|
+ BCButton_RemoveFromPalette.Top := BCButton_AddToPalette.Top + BCButton_AddToPalette.Height;
|
|
end else
|
|
end else
|
|
begin
|
|
begin
|
|
if FButtonsCenter then
|
|
if FButtonsCenter then
|
|
- BCButton_AddToPalette.Left := (AvailableBmpWidth -
|
|
|
|
|
|
+ BCButton_AddToPalette.Left := (AvailableVSWidth -
|
|
BCButton_AddToPalette.Width - BCButton_RemoveFromPalette.Width) div 2;
|
|
BCButton_AddToPalette.Width - BCButton_RemoveFromPalette.Width) div 2;
|
|
- BCButton_RemoveFromPalette.Left := BCButton_AddToPalette.Left+BCButton_AddToPalette.Width;
|
|
|
|
- BCButton_RemoveFromPalette.Top := FMargin div 2;
|
|
|
|
|
|
+ BCButton_RemoveFromPalette.Left := BCButton_AddToPalette.Left + BCButton_AddToPalette.Width;
|
|
|
|
+ BCButton_RemoveFromPalette.Top := round(FMargin / 2);
|
|
end;
|
|
end;
|
|
iconSize := FButtonSize-4;
|
|
iconSize := FButtonSize-4;
|
|
if not Assigned(BCButton_AddToPalette.Glyph) or (BCButton_AddToPalette.Glyph.Width <> iconSize) then
|
|
if not Assigned(BCButton_AddToPalette.Glyph) or (BCButton_AddToPalette.Glyph.Width <> iconSize) then
|
|
@@ -690,8 +785,8 @@ begin
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
|
|
-function TChooseColorInterface.SetRectBounds(var ABounds: TRect;
|
|
|
|
- ANewBounds: TRect): boolean;
|
|
|
|
|
|
+function TChooseColorInterface.SetRectBounds(var ABounds: TRectF;
|
|
|
|
+ ANewBounds: TRectF): boolean;
|
|
begin
|
|
begin
|
|
result := (ABounds.Width <> ANewBounds.Width) or (ABounds.Height <> ANewBounds.Height);
|
|
result := (ABounds.Width <> ANewBounds.Width) or (ABounds.Height <> ANewBounds.Height);
|
|
ABounds := ANewBounds;
|
|
ABounds := ANewBounds;
|
|
@@ -699,23 +794,23 @@ end;
|
|
|
|
|
|
function TChooseColorInterface.PreferredBarsAlignWithWidth: TAlign;
|
|
function TChooseColorInterface.PreferredBarsAlignWithWidth: TAlign;
|
|
var
|
|
var
|
|
- oneBarWidth, tx,ty, internalMargin, margin: Integer;
|
|
|
|
|
|
+ oneBarWidth, internalMargin, margin, tx, ty: single;
|
|
begin
|
|
begin
|
|
- margin := DoScaleY(8, OriginalDPI, FDPI);
|
|
|
|
- oneBarWidth := DoScaleX(18, OriginalDPI, FDPI) + DoScaleX(10, OriginalDPI, FDPI) +
|
|
|
|
|
|
+ margin := DoScaleYF(8, OriginalDPI, FDPI);
|
|
|
|
+ oneBarWidth := DoScaleXF(18, OriginalDPI, FDPI) + DoScaleXF(10, OriginalDPI, FDPI) +
|
|
margin;
|
|
margin;
|
|
internalMargin := max(0, margin - ExternalMargin);
|
|
internalMargin := max(0, margin - ExternalMargin);
|
|
if (FLazPaintInstance = nil) or LazPaintInstance.BlackAndWhite then
|
|
if (FLazPaintInstance = nil) or LazPaintInstance.BlackAndWhite then
|
|
begin
|
|
begin
|
|
- tx := AvailableBmpWidth - 2*internalMargin;
|
|
|
|
|
|
+ tx := AvailableVSWidth - 2*internalMargin;
|
|
if tx <= oneBarWidth*4 then
|
|
if tx <= oneBarWidth*4 then
|
|
result := alRight
|
|
result := alRight
|
|
else
|
|
else
|
|
result := alBottom;
|
|
result := alBottom;
|
|
end else
|
|
end else
|
|
begin
|
|
begin
|
|
- tx := AvailableBmpWidth - 2*internalMargin;
|
|
|
|
- ty := AvailableBmpHeight - 2*margin;
|
|
|
|
|
|
+ tx := AvailableVSWidth - 2*internalMargin;
|
|
|
|
+ ty := AvailableVSHeight - 2*margin;
|
|
if tx >= ty then
|
|
if tx >= ty then
|
|
result := alRight
|
|
result := alRight
|
|
else result := alBottom;
|
|
else result := alBottom;
|
|
@@ -723,33 +818,34 @@ begin
|
|
end;
|
|
end;
|
|
|
|
|
|
procedure TChooseColorInterface.UpdateLayout;
|
|
procedure TChooseColorInterface.UpdateLayout;
|
|
-var bmpWidth, bmpHeight: integer;
|
|
|
|
|
|
+var vsWidth, vsHeight: single;
|
|
prevBarsAlign: TAlign;
|
|
prevBarsAlign: TAlign;
|
|
- newAlphaBounds, newLightscaleBounds: TRect;
|
|
|
|
|
|
+ newAlphaBounds, newLightscaleBounds: TRectF;
|
|
|
|
+ newColorCircleArea: TRectF;
|
|
needUpdateLightscale, needUpdateColorCircle: Boolean;
|
|
needUpdateLightscale, needUpdateColorCircle: Boolean;
|
|
- diffXY, delta: integer;
|
|
|
|
|
|
+ diffXY, delta: single;
|
|
reductionFactor: single;
|
|
reductionFactor: single;
|
|
|
|
|
|
- function AdaptSizeX(ASize: integer): integer;
|
|
|
|
|
|
+ function AdaptSizeX(ASize: integer): single;
|
|
begin
|
|
begin
|
|
- result := min(DoScaleX(ASize, OriginalDPI, FDPI), round(ASize*reductionFactor));
|
|
|
|
|
|
+ result := min(DoScaleXF(ASize, OriginalDPI, FDPI), ASize * reductionFactor);
|
|
end;
|
|
end;
|
|
- function AdaptSizeY(ASize: integer): integer;
|
|
|
|
|
|
+ function AdaptSizeY(ASize: integer): single;
|
|
begin
|
|
begin
|
|
- result := min(DoScaleY(ASize, OriginalDPI, FDPI), round(ASize*reductionFactor));
|
|
|
|
|
|
+ result := min(DoScaleYF(ASize, OriginalDPI, FDPI), ASize * reductionFactor);
|
|
end;
|
|
end;
|
|
|
|
|
|
begin
|
|
begin
|
|
if FLazPaintInstance = nil then exit;
|
|
if FLazPaintInstance = nil then exit;
|
|
|
|
|
|
prevBarsAlign := FBarsAlign;
|
|
prevBarsAlign := FBarsAlign;
|
|
- bmpWidth := AvailableBmpWidth;
|
|
|
|
- bmpHeight := AvailableBmpHeight;
|
|
|
|
|
|
+ vsWidth := AvailableVSWidth;
|
|
|
|
+ vsHeight := AvailableVSHeight;
|
|
|
|
|
|
if LazPaintInstance.BlackAndWhite then
|
|
if LazPaintInstance.BlackAndWhite then
|
|
- reductionFactor := min(bmpWidth, bmpHeight)/105
|
|
|
|
|
|
+ reductionFactor := min(vsWidth, vsHeight)/105
|
|
else
|
|
else
|
|
- reductionFactor := max(bmpWidth, bmpHeight)/200;
|
|
|
|
|
|
+ reductionFactor := max(vsWidth, vsHeight)/200;
|
|
FBarWidth := AdaptSizeX(18);
|
|
FBarWidth := AdaptSizeX(18);
|
|
FCursorPlace := AdaptSizeX(10);
|
|
FCursorPlace := AdaptSizeX(10);
|
|
FCursorMargin := AdaptSizeX(2);
|
|
FCursorMargin := AdaptSizeX(2);
|
|
@@ -759,16 +855,15 @@ begin
|
|
FInternalMargin := FMargin-ExternalMargin;
|
|
FInternalMargin := FMargin-ExternalMargin;
|
|
if FInternalMargin < 0 then FInternalMargin := 0;
|
|
if FInternalMargin < 0 then FInternalMargin := 0;
|
|
FTitleFontHeight := max(AdaptSizeY(12), 10);
|
|
FTitleFontHeight := max(AdaptSizeY(12), 10);
|
|
- FColorXYSize := DoScaleX(3, OriginalDPI, FDPI);
|
|
|
|
- FCursorXYOpacity := DoScaleX(128, OriginalDPI, FDPI);
|
|
|
|
- if FCursorXYOpacity > 255 then FCursorXYOpacity := 255;
|
|
|
|
|
|
+ FColorXYSize := DoScaleXF(3, OriginalDPI, FDPI);
|
|
|
|
+ FCursorXYWidth := DoScaleXF(0.5, OriginalDPI, FDPI);
|
|
|
|
|
|
- FWheelArea := Rect(FInternalMargin, FMargin, bmpWidth - FInternalMargin, bmpHeight - FMargin);
|
|
|
|
|
|
+ newColorCircleArea := RectF(FInternalMargin, FMargin, vsWidth - FInternalMargin, vsHeight - FMargin);
|
|
|
|
|
|
if FLazPaintInstance.BlackAndWhite then
|
|
if FLazPaintInstance.BlackAndWhite then
|
|
begin
|
|
begin
|
|
FButtonsCenter := true;
|
|
FButtonsCenter := true;
|
|
- if FWheelArea.Width <= FWheelArea.Height then
|
|
|
|
|
|
+ if newColorCircleArea.Width <= newColorCircleArea.Height then
|
|
begin
|
|
begin
|
|
FButtonsAlign := alLeft;
|
|
FButtonsAlign := alLeft;
|
|
FBarsAlign := alRight;
|
|
FBarsAlign := alRight;
|
|
@@ -784,78 +879,78 @@ begin
|
|
begin
|
|
begin
|
|
FButtonsAlign := alLeft;
|
|
FButtonsAlign := alLeft;
|
|
FButtonsCenter := false;
|
|
FButtonsCenter := false;
|
|
- if FWheelArea.Width >= FWheelArea.Height then
|
|
|
|
|
|
+ if newColorCircleArea.Width >= newColorCircleArea.Height then
|
|
FBarsAlign := alRight else FBarsAlign := alBottom;
|
|
FBarsAlign := alRight else FBarsAlign := alBottom;
|
|
UpdateButtonLayout;
|
|
UpdateButtonLayout;
|
|
end;
|
|
end;
|
|
|
|
|
|
- FWheelArea.Top := FTopMargin;
|
|
|
|
|
|
+ newColorCircleArea.Top := FTopMargin;
|
|
|
|
|
|
if FBarsAlign = alRight then
|
|
if FBarsAlign = alRight then
|
|
begin
|
|
begin
|
|
- newAlphaBounds := RectWithSize(FWheelArea.Right - FCursorPlace - FBarWidth, FWheelArea.Top,
|
|
|
|
- FBarWidth, FWheelArea.Height);
|
|
|
|
- FWheelArea.Right := newAlphaBounds.Left - FMargin;
|
|
|
|
|
|
+ newAlphaBounds := RectWithSizeF(newColorCircleArea.Right - FCursorPlace - FBarWidth, newColorCircleArea.Top,
|
|
|
|
+ FBarWidth, newColorCircleArea.Height);
|
|
|
|
+ newColorCircleArea.Right := newAlphaBounds.Left - FMargin;
|
|
end
|
|
end
|
|
else
|
|
else
|
|
begin
|
|
begin
|
|
- newAlphaBounds := RectWithSize(FWheelArea.Left, FWheelArea.Bottom - FCursorPlace - FBarWidth,
|
|
|
|
- FWheelArea.Width, FBarWidth);
|
|
|
|
- FWheelArea.Bottom := newAlphaBounds.Top - FMargin;
|
|
|
|
|
|
+ newAlphaBounds := RectWithSizeF(newColorCircleArea.Left, newColorCircleArea.Bottom - FCursorPlace - FBarWidth,
|
|
|
|
+ newColorCircleArea.Width, FBarWidth);
|
|
|
|
+ newColorCircleArea.Bottom := newAlphaBounds.Top - FMargin;
|
|
end;
|
|
end;
|
|
if SetRectBounds(FAlphascale.bounds, newAlphaBounds) or (FBarsAlign <> prevBarsAlign) then
|
|
if SetRectBounds(FAlphascale.bounds, newAlphaBounds) or (FBarsAlign <> prevBarsAlign) then
|
|
FreeAndNil(FAlphascale.bmp);
|
|
FreeAndNil(FAlphascale.bmp);
|
|
|
|
|
|
if FBarsAlign = alRight then
|
|
if FBarsAlign = alRight then
|
|
begin
|
|
begin
|
|
- newLightscaleBounds := RectWithSize(FWheelArea.Right - FCursorPlace - FBarWidth, FWheelArea.Top,
|
|
|
|
- FBarWidth, FWheelArea.Height);
|
|
|
|
- FWheelArea.Right := newLightscaleBounds.Left - FMargin;
|
|
|
|
|
|
+ newLightscaleBounds := RectWithSizeF(newColorCircleArea.Right - FCursorPlace - FBarWidth, newColorCircleArea.Top,
|
|
|
|
+ FBarWidth, newColorCircleArea.Height);
|
|
|
|
+ newColorCircleArea.Right := newLightscaleBounds.Left - FMargin;
|
|
end
|
|
end
|
|
else
|
|
else
|
|
begin
|
|
begin
|
|
- newLightscaleBounds := RectWithSize(FWheelArea.Left, FWheelArea.Bottom - FCursorPlace - FBarWidth,
|
|
|
|
- FWheelArea.Width, FBarWidth);
|
|
|
|
- FWheelArea.Bottom := newLightscaleBounds.Top - FMargin;
|
|
|
|
|
|
+ newLightscaleBounds := RectWithSizeF(newColorCircleArea.Left, newColorCircleArea.Bottom - FCursorPlace - FBarWidth,
|
|
|
|
+ newColorCircleArea.Width, FBarWidth);
|
|
|
|
+ newColorCircleArea.Bottom := newLightscaleBounds.Top - FMargin;
|
|
end;
|
|
end;
|
|
needUpdateLightscale := SetRectBounds(FLightscale.bounds, newLightscaleBounds)
|
|
needUpdateLightscale := SetRectBounds(FLightscale.bounds, newLightscaleBounds)
|
|
or (FBarsAlign <> prevBarsAlign);
|
|
or (FBarsAlign <> prevBarsAlign);
|
|
|
|
|
|
if FButtonsAlign = alLeft then
|
|
if FButtonsAlign = alLeft then
|
|
begin
|
|
begin
|
|
- delta := FMargin - (FWheelArea.Left + round(min(FWheelArea.Width, FWheelArea.Height)*(1-0.8)) - (FMargin - ExternalMargin + FButtonSize));
|
|
|
|
|
|
+ delta := FMargin - (newColorCircleArea.Left +
|
|
|
|
+ min(newColorCircleArea.Width, newColorCircleArea.Height)*(1-0.8) -
|
|
|
|
+ (FMargin - ExternalMargin + FButtonSize) );
|
|
if delta >= 0 then
|
|
if delta >= 0 then
|
|
- begin
|
|
|
|
- inc(FWheelArea.Left, delta);
|
|
|
|
- end;
|
|
|
|
|
|
+ incF(newColorCircleArea.Left, delta);
|
|
end;
|
|
end;
|
|
|
|
|
|
- diffXY := FWheelArea.Width - FWheelArea.Height;
|
|
|
|
|
|
+ diffXY := newColorCircleArea.Width - newColorCircleArea.Height;
|
|
if diffXY > 0 then
|
|
if diffXY > 0 then
|
|
begin
|
|
begin
|
|
- inc(FWheelArea.Left, diffXY div 2);
|
|
|
|
- FWheelArea.Right := FWheelArea.Left + FWheelArea.Height;
|
|
|
|
|
|
+ incF(newColorCircleArea.Left, diffXY / 2);
|
|
|
|
+ newColorCircleArea.Right := newColorCircleArea.Left + newColorCircleArea.Height;
|
|
end else
|
|
end else
|
|
begin
|
|
begin
|
|
- dec(FWheelArea.Top, diffXY div 2);
|
|
|
|
- FWheelArea.Bottom := FWheelArea.Top + FWheelArea.Width;
|
|
|
|
|
|
+ decF(newColorCircleArea.Top, diffXY / 2);
|
|
|
|
+ newColorCircleArea.Bottom := newColorCircleArea.Top + newColorCircleArea.Width;
|
|
end;
|
|
end;
|
|
|
|
|
|
- delta := min(FWheelArea.Left - (FButtonSize + FMargin) div 2, FWheelArea.Top - FMargin div 2);
|
|
|
|
- delta := min(delta, DoScaleX(120, OriginalDPI, FDPI) - FWheelArea.Width);
|
|
|
|
|
|
+ delta := min(newColorCircleArea.Left - (FButtonSize + FMargin) / 2, newColorCircleArea.Top - FMargin / 2);
|
|
|
|
+ delta := min(delta, DoScaleXF(120, OriginalDPI, FDPI) - newColorCircleArea.Width);
|
|
if delta > 0 then
|
|
if delta > 0 then
|
|
begin
|
|
begin
|
|
- dec(FWheelArea.Left, delta div 2);
|
|
|
|
- inc(FWheelArea.Right, (delta+1) div 2);
|
|
|
|
- dec(FWheelArea.Top, delta);
|
|
|
|
- FColorTitleVisible := delta <= FMargin div 2;
|
|
|
|
|
|
+ decF(newColorCircleArea.Left, delta / 2);
|
|
|
|
+ incF(newColorCircleArea.Right, (delta+1) / 2);
|
|
|
|
+ decF(newColorCircleArea.Top, delta);
|
|
|
|
+ FColorTitleVisible := delta <= FMargin / 2;
|
|
end else
|
|
end else
|
|
FColorTitleVisible := true;
|
|
FColorTitleVisible := true;
|
|
|
|
|
|
- FColorCircle.center := PointF((FWheelArea.Left + FWheelArea.Right)/2 - 0.5,
|
|
|
|
- (FWheelArea.Top + FWheelArea.Bottom)/2 - 0.5);
|
|
|
|
|
|
+ FColorCircle.center := PointF((newColorCircleArea.Left + newColorCircleArea.Right)/2 - 0.5,
|
|
|
|
+ (newColorCircleArea.Top + newColorCircleArea.Bottom)/2 - 0.5);
|
|
|
|
|
|
- needUpdateColorCircle := SetRectBounds(FColorCircle.bounds, FWheelArea);
|
|
|
|
|
|
+ needUpdateColorCircle := SetRectBounds(FColorCircle.bounds, newColorCircleArea);
|
|
if needUpdateColorCircle then FreeAndNil(FColorCircle.bmpMaxlight);
|
|
if needUpdateColorCircle then FreeAndNil(FColorCircle.bmpMaxlight);
|
|
|
|
|
|
UpdateColorview(needUpdateColorCircle, needUpdateLightscale, False);
|
|
UpdateColorview(needUpdateColorCircle, needUpdateLightscale, False);
|
|
@@ -865,7 +960,8 @@ function TChooseColorInterface.GetAlphaScaleBmp: TBGRABitmap;
|
|
begin
|
|
begin
|
|
if (FAlphascale.bmp = nil) and not FAlphascale.Bounds.IsEmpty then
|
|
if (FAlphascale.bmp = nil) and not FAlphascale.Bounds.IsEmpty then
|
|
begin
|
|
begin
|
|
- FAlphascale.bmp := TBGRABitmap.Create(FAlphascale.Bounds.Width, FAlphascale.Bounds.Height);
|
|
|
|
|
|
+ FAlphascale.bmp := TBGRABitmap.Create( round(FAlphascale.Bounds.Width * FBitmapScale),
|
|
|
|
+ round(FAlphascale.Bounds.Height * FBitmapScale) );
|
|
if FBarsAlign = alRight then
|
|
if FBarsAlign = alRight then
|
|
FAlphascale.bmp.GradientFill(0, 0, FAlphascale.bmp.width, FAlphascale.bmp.height,
|
|
FAlphascale.bmp.GradientFill(0, 0, FAlphascale.bmp.width, FAlphascale.bmp.height,
|
|
FFormTextColor, vsColorView.Color, gtLinear,
|
|
FFormTextColor, vsColorView.Color, gtLinear,
|
|
@@ -875,7 +971,7 @@ begin
|
|
FAlphascale.bmp.GradientFill(0, 0, FAlphascale.bmp.width, FAlphascale.bmp.height,
|
|
FAlphascale.bmp.GradientFill(0, 0, FAlphascale.bmp.width, FAlphascale.bmp.height,
|
|
FFormTextColor, vsColorView.Color, gtLinear,
|
|
FFormTextColor, vsColorView.Color, gtLinear,
|
|
PointF(FAlphascale.bmp.Width-0.5, 0), PointF(-0.5, 0), dmSet, True);
|
|
PointF(FAlphascale.bmp.Width-0.5, 0), PointF(-0.5, 0), dmSet, True);
|
|
- FAlphascale.bmp.FontHeight := FTitleFontHeight;
|
|
|
|
|
|
+ FAlphascale.bmp.FontHeight := round(FTitleFontHeight * FBitmapScale);
|
|
FAlphascale.bmp.FontVerticalAnchor:= fvaCapCenter;
|
|
FAlphascale.bmp.FontVerticalAnchor:= fvaCapCenter;
|
|
FAlphascale.bmp.TextOut(FMargin/2, FAlphascale.bmp.Height/2, rsOpacity, FFormTextColor, taLeftJustify);
|
|
FAlphascale.bmp.TextOut(FMargin/2, FAlphascale.bmp.Height/2, rsOpacity, FFormTextColor, taLeftJustify);
|
|
FAlphascale.bmp.FontVerticalAnchor:= fvaTop;
|
|
FAlphascale.bmp.FontVerticalAnchor:= fvaTop;
|
|
@@ -890,7 +986,8 @@ var
|
|
begin
|
|
begin
|
|
if (FLightscale.bmp = nil) and not FLightscale.Bounds.IsEmpty then
|
|
if (FLightscale.bmp = nil) and not FLightscale.Bounds.IsEmpty then
|
|
begin
|
|
begin
|
|
- FLightscale.bmp := TBGRABitmap.Create(FLightscale.Bounds.Width, FLightscale.Bounds.Height);
|
|
|
|
|
|
+ FLightscale.bmp := TBGRABitmap.Create( round(FLightscale.Bounds.Width * FBitmapScale),
|
|
|
|
+ round(FLightscale.Bounds.Height * FBitmapScale) );
|
|
tempColor := ColorWithLight(FCurrentColor,$FFFF);
|
|
tempColor := ColorWithLight(FCurrentColor,$FFFF);
|
|
tempColor.alpha := 255;
|
|
tempColor.alpha := 255;
|
|
if FBarsAlign = alRight then
|
|
if FBarsAlign = alRight then
|
|
@@ -902,7 +999,7 @@ begin
|
|
FLightscale.bmp.GradientFill(0, 0, FLightscale.bmp.width, FLightscale.bmp.height,
|
|
FLightscale.bmp.GradientFill(0, 0, FLightscale.bmp.width, FLightscale.bmp.height,
|
|
tempColor, BGRABlack, gtLinear,
|
|
tempColor, BGRABlack, gtLinear,
|
|
PointF(FLightscale.bmp.width-0.5, 0), PointF(-0.5, 0), dmSet, True);
|
|
PointF(FLightscale.bmp.width-0.5, 0), PointF(-0.5, 0), dmSet, True);
|
|
- FLightscale.bmp.FontHeight := FTitleFontHeight;
|
|
|
|
|
|
+ FLightscale.bmp.FontHeight := round(FTitleFontHeight * FBitmapScale);
|
|
FLightscale.bmp.FontVerticalAnchor:= fvaCapCenter;
|
|
FLightscale.bmp.FontVerticalAnchor:= fvaCapCenter;
|
|
FLightscale.bmp.TextOut(FMargin/2, FLightscale.bmp.Height/2, rsLight, BGRA(210,210,210), taLeftJustify);
|
|
FLightscale.bmp.TextOut(FMargin/2, FLightscale.bmp.Height/2, rsLight, BGRA(210,210,210), taLeftJustify);
|
|
FLightscale.bmp.FontVerticalAnchor:= fvaTop;
|
|
FLightscale.bmp.FontVerticalAnchor:= fvaTop;
|
|
@@ -915,7 +1012,8 @@ function TChooseColorInterface.GetColorCircleMaxLightBmp: TBGRABitmap;
|
|
begin
|
|
begin
|
|
if (FColorCircle.bmpMaxlight = nil) and not LazPaintInstance.BlackAndWhite
|
|
if (FColorCircle.bmpMaxlight = nil) and not LazPaintInstance.BlackAndWhite
|
|
and not FColorCircle.bounds.IsEmpty then
|
|
and not FColorCircle.bounds.IsEmpty then
|
|
- FColorCircle.bmpMaxlight := ComputeColorCircle(FColorCircle.Bounds.Width, FColorCircle.Bounds.Height, $FFFF);
|
|
|
|
|
|
+ FColorCircle.bmpMaxlight := ComputeColorCircle(round(FColorCircle.Bounds.Width * FBitmapScale),
|
|
|
|
+ round(FColorCircle.Bounds.Height * FBitmapScale), $FFFF);
|
|
|
|
|
|
result := FColorCircle.bmpMaxlight;
|
|
result := FColorCircle.bmpMaxlight;
|
|
end;
|
|
end;
|
|
@@ -924,7 +1022,7 @@ function TChooseColorInterface.GetColorCircleBmp: TBGRABitmap;
|
|
begin
|
|
begin
|
|
if (FColorCircle.bmp = nil) and Assigned(GetColorCircleMaxLightBmp) then
|
|
if (FColorCircle.bmp = nil) and Assigned(GetColorCircleMaxLightBmp) then
|
|
FColorCircle.bmp := BitmapWithLight(GetColorCircleMaxLightBmp, max(10000, FColorLight),
|
|
FColorCircle.bmp := BitmapWithLight(GetColorCircleMaxLightBmp, max(10000, FColorLight),
|
|
- FCurrentColor, ColorX, ColorY);
|
|
|
|
|
|
+ FCurrentColor, FColorX, FColorY);
|
|
result := FColorCircle.bmp;
|
|
result := FColorCircle.bmp;
|
|
end;
|
|
end;
|
|
|
|
|
|
@@ -945,10 +1043,12 @@ begin
|
|
vsColorView := TBGRAVirtualScreen.Create(Container);
|
|
vsColorView := TBGRAVirtualScreen.Create(Container);
|
|
vsColorView.Caption := '';
|
|
vsColorView.Caption := '';
|
|
vsColorView.Parent := Container;
|
|
vsColorView.Parent := Container;
|
|
|
|
+ vsColorView.BitmapAutoScale:= false;
|
|
vsColorView.OnMouseDown:= @vsColorViewMouseDown;
|
|
vsColorView.OnMouseDown:= @vsColorViewMouseDown;
|
|
vsColorView.OnMouseMove:= @vsColorViewMouseMove;
|
|
vsColorView.OnMouseMove:= @vsColorViewMouseMove;
|
|
vsColorView.OnMouseUp:= @vsColorViewMouseUp;
|
|
vsColorView.OnMouseUp:= @vsColorViewMouseUp;
|
|
vsColorView.OnRedraw:= @vsColorViewRedraw;
|
|
vsColorView.OnRedraw:= @vsColorViewRedraw;
|
|
|
|
+ FBitmapScale := 1;
|
|
BCButton_AddToPalette := TBCButton.Create(vsColorView);
|
|
BCButton_AddToPalette := TBCButton.Create(vsColorView);
|
|
BCButton_AddToPalette.Parent := vsColorView;
|
|
BCButton_AddToPalette.Parent := vsColorView;
|
|
BCButton_AddToPalette.OnClick := @BCButton_AddToPaletteClick;
|
|
BCButton_AddToPalette.OnClick := @BCButton_AddToPaletteClick;
|
|
@@ -1030,31 +1130,32 @@ end;
|
|
|
|
|
|
procedure TChooseColorInterface.AdjustControlHeight;
|
|
procedure TChooseColorInterface.AdjustControlHeight;
|
|
var
|
|
var
|
|
- oneBarWidth, h, margin, topMargin, barWidth, buttonSize: Integer;
|
|
|
|
|
|
+ oneBarWidth, h, margin, topMargin, barWidth: single;
|
|
|
|
+ buttonSize: Integer;
|
|
begin
|
|
begin
|
|
if not ((FLazPaintInstance = nil) or FLazPaintInstance.BlackAndWhite) then exit;
|
|
if not ((FLazPaintInstance = nil) or FLazPaintInstance.BlackAndWhite) then exit;
|
|
|
|
|
|
- margin := DoScaleY(8, OriginalDPI, FDPI);
|
|
|
|
- topMargin := DoScaleY(27, OriginalDPI, FDPI);
|
|
|
|
- barWidth := DoScaleX(18, OriginalDPI, FDPI);
|
|
|
|
- buttonSize := barWidth;
|
|
|
|
- oneBarWidth := barWidth + DoScaleX(10, OriginalDPI, FDPI) +
|
|
|
|
|
|
+ margin := DoScaleYF(8, OriginalDPI, FDPI);
|
|
|
|
+ topMargin := DoScaleYF(27, OriginalDPI, FDPI);
|
|
|
|
+ barWidth := DoScaleXF(18, OriginalDPI, FDPI);
|
|
|
|
+ buttonSize := round(barWidth);
|
|
|
|
+ oneBarWidth := barWidth + DoScaleXF(10, OriginalDPI, FDPI) +
|
|
margin;
|
|
margin;
|
|
if PreferredBarsAlignWithWidth = alRight then
|
|
if PreferredBarsAlignWithWidth = alRight then
|
|
begin
|
|
begin
|
|
if (FLazPaintInstance = nil) or FLazPaintInstance.BlackAndWhite then
|
|
if (FLazPaintInstance = nil) or FLazPaintInstance.BlackAndWhite then
|
|
h := oneBarWidth*4 + margin
|
|
h := oneBarWidth*4 + margin
|
|
else
|
|
else
|
|
- h := AvailableBmpWidth - oneBarWidth*2 + topMargin;
|
|
|
|
|
|
+ h := AvailableVSWidth - oneBarWidth*2 + topMargin;
|
|
end else
|
|
end else
|
|
begin
|
|
begin
|
|
if (FLazPaintInstance = nil) or FLazPaintInstance.BlackAndWhite then
|
|
if (FLazPaintInstance = nil) or FLazPaintInstance.BlackAndWhite then
|
|
h := oneBarWidth*2 + buttonSize + margin
|
|
h := oneBarWidth*2 + buttonSize + margin
|
|
else
|
|
else
|
|
- h := AvailableBmpWidth + oneBarWidth*2 + topMargin;
|
|
|
|
|
|
+ h := AvailableVSWidth + oneBarWidth*2 + topMargin;
|
|
end;
|
|
end;
|
|
NeedTextAreaHeight;
|
|
NeedTextAreaHeight;
|
|
- Container.Height := h + FTextAreaHeight + ExternalMargin;
|
|
|
|
|
|
+ Container.Height := round(h + FTextAreaHeight + ExternalMargin);
|
|
end;
|
|
end;
|
|
|
|
|
|
end.
|
|
end.
|