mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-13 10:59:06 +02:00
Gtk3: fixed selecting and returning proper color from TColorDialog.
This commit is contained in:
parent
e8fc8fb0ca
commit
8ac0fa2e95
@ -295,7 +295,7 @@ function Gtk3ScrollTypeToScrollCode(ScrollType: TGtkScrollType): LongWord;
|
||||
|
||||
function TGDKColorToTColor(const value : TGDKColor) : TColor;
|
||||
function TColorToTGDKColor(const value : TColor) : TGDKColor;
|
||||
function TGdkRGBAToTColor(const value : TGdkRGBA) : TColor;
|
||||
function TGdkRGBAToTColor(const value : TGdkRGBA; IgnoreAlpha: Boolean = True) : TColor;
|
||||
function TColortoTGdkRGBA(const value : TColor; IgnoreAlpha: Boolean = True) : TGdkRGBA;
|
||||
function ColorToCairoRGB(AColor: TColor; out ARed, AGreen, ABlue: Double): Boolean;
|
||||
function RectFromGtkAllocation(AGtkAllocation: TGtkAllocation): TRect;
|
||||
@ -348,15 +348,16 @@ begin
|
||||
Result:=((d + 512) shr 10);
|
||||
end;
|
||||
|
||||
function TGdkRGBAToTColor(const value: TGdkRGBA): TColor;
|
||||
function TGdkRGBAToTColor(const value: TGdkRGBA; IgnoreAlpha: Boolean): TColor;
|
||||
begin
|
||||
Result := Trunc(value.red * $FF)
|
||||
or (Trunc(value.green * $FF) shl 8)
|
||||
or (Trunc(value.blue * $FF) shl 16)
|
||||
or (Trunc(value.alpha * $FF) shl 24);
|
||||
or (Trunc(value.blue * $FF) shl 16);
|
||||
if not IgnoreAlpha then
|
||||
Result := Result or (Trunc(value.alpha * $FF) shl 24);
|
||||
end;
|
||||
|
||||
function TColortoTGdkRGBA(const value: TColor; IgnoreAlpha: Boolean = True): TGdkRGBA;
|
||||
function TColortoTGdkRGBA(const value: TColor; IgnoreAlpha: Boolean): TGdkRGBA;
|
||||
begin
|
||||
Result.red := (value and $FF) / 255;
|
||||
Result.green := ((value shr 8) and $FF) / 255;
|
||||
|
@ -8366,22 +8366,13 @@ end;
|
||||
class procedure TGtk3newColorSelectionDialog.color_to_rgba(clr: TColor; out
|
||||
rgba: TgdkRGBA);
|
||||
begin
|
||||
clr:=ColorToRgb(clr);
|
||||
rgba.red:=Red(clr)/255;
|
||||
rgba.blue:=Blue(clr)/255;
|
||||
rgba.green:=Green(clr)/255;
|
||||
rgba.alpha:=(clr shl 24)/255;
|
||||
rgba := TColortoTGdkRGBA(clr);
|
||||
end;
|
||||
|
||||
class function TGtk3newColorSelectionDialog.rgba_to_color(const rgba: TgdkRGBA
|
||||
): TColor;
|
||||
var
|
||||
q:array[0..3] of byte absolute Result;
|
||||
begin
|
||||
q[0]:= round(255*rgba.red);
|
||||
q[1]:= round(255*rgba.green);
|
||||
q[2]:= round(255*rgba.blue);
|
||||
q[3]:= round(255*rgba.alpha);
|
||||
Result := TGdkRGBAToTColor(rgba);
|
||||
end;
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user