mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-16 04:19:19 +02:00
Merge branch 'DisabledDrawEffectStyle' into 'main'
LazUtils: Added DisabledDrawEffectStyle to control disabled image appearance See merge request freepascal.org/lazarus/lazarus!298
This commit is contained in:
commit
9f98ea7602
@ -268,6 +268,7 @@ function RawImageQueryFlagsToString(AFlags: TRawImageQueryFlags): string;
|
||||
|
||||
var
|
||||
MissingBits: array[0..15] of array[0..7] of word;
|
||||
DisabledDrawEffectStyle: (ddesGrayscale, ddesDarken, ddesLighten) = ddesGrayscale;
|
||||
|
||||
implementation
|
||||
|
||||
@ -1651,6 +1652,7 @@ var
|
||||
AData: PRGBAQuad;
|
||||
P: Pointer;
|
||||
i, j: integer;
|
||||
Gray: Byte;
|
||||
begin
|
||||
// check here for Description. Only RGBA data can be processed here.
|
||||
if not CheckDescription then
|
||||
@ -1676,9 +1678,21 @@ begin
|
||||
begin
|
||||
with AData^ do
|
||||
begin
|
||||
Red := (Red + Green + Blue) div 3;
|
||||
Green := Red;
|
||||
Blue := Red;
|
||||
Gray := (Red + Green + Blue) div 3;
|
||||
// Apply existing alpha and reduce visibility by a further 66%
|
||||
if DisabledDrawEffectStyle = ddesLighten then
|
||||
begin
|
||||
Alpha := Byte((Integer(Gray) * Alpha) div 768);
|
||||
Gray := $FF;
|
||||
end
|
||||
else if DisabledDrawEffectStyle = ddesDarken then
|
||||
begin
|
||||
Alpha := Byte((Integer($FF - Gray) * Alpha) div 768);
|
||||
Gray := $00;
|
||||
end;
|
||||
Red := Gray;
|
||||
Green := Gray;
|
||||
Blue := Gray;
|
||||
end;
|
||||
inc(AData);
|
||||
end;
|
||||
|
@ -1317,6 +1317,26 @@ boundaries.
|
||||
<seealso/>
|
||||
</element>
|
||||
|
||||
<element name="DisabledDrawEffectStyle">
|
||||
<short>Controls the appearance of disabled images.</short>
|
||||
<descr>
|
||||
<p>
|
||||
This variable controls how <link id="TRawImage.PerformEffect"/>
|
||||
represents <link id="TGraphicsDrawEffect.gdeDisabled">gdeDisabled</link>.
|
||||
Applications should set it based on the background color for their
|
||||
interfaces.
|
||||
</p>
|
||||
</descr>
|
||||
</element>
|
||||
<element name="DisabledDrawEffectStyle.ddesGrayscale">
|
||||
<short>Convert RGB values to grayscale.</short>
|
||||
</element>
|
||||
<element name="DisabledDrawEffectStyle.ddesDarken">
|
||||
<short>Convert to black with alpha representing grayscale.</short>
|
||||
</element>
|
||||
<element name="DisabledDrawEffectStyle.ddesLighten">
|
||||
<short>Convert to white with alpha representing grayscale.</short>
|
||||
</element>
|
||||
</module>
|
||||
<!-- GraphType -->
|
||||
</package>
|
||||
|
Loading…
Reference in New Issue
Block a user