View Issue Details

IDProjectCategoryView StatusLast Update
0038567LazarusWidgetsetpublic2021-03-21 11:39
ReporterCudaText man Assigned ToJuha Manninen  
PrioritynormalSeverityminorReproducibilityalways
Status assignedResolutionopen 
OSUbuntu 20.04 
Product Version2.1 (SVN) 
Summary0038567: gtk3: Broken bitmap in SpeedButton, wrong Checkbox color
Descriptionrun demo on gtk3.
1) bitmap is totally broken on SpeedBtn. Check the image in any file viewer, file bmp1.bmp.
2) 2 Checkboxes have GREEN font color, wrong.
Additional InformationLazarus 2.1.0 r64665M FPC 3.2.1 x86_64-linux-gtk2
with applied patch from Anton Kavalenka from
https://bugs.freepascal.org/view.php?id=38562
TagsNo tags attached.
Fixed in Revisionr64802, r64846
LazTarget-
WidgetsetGTK 3
Attached Files

Activities

CudaText man

2021-03-02 09:08

reporter  

gtk3.png (16,038 bytes)   
gtk3.png (16,038 bytes)   
tst-icon-draw-gtk3.zip (8,504 bytes)

Anton Kavalenka

2021-03-03 13:44

reporter   ~0129351

Green checkboxes leaved intentionally to check (it's CheckBox at last) if somebody uses GTK3 WS.

CudaText man

2021-03-03 13:52

reporter   ~0129353

Okay. what about broken bitmap on SpeedBtn?

Anton Kavalenka

2021-03-03 13:53

reporter   ~0129354

Will look

CudaText man

2021-03-04 10:08

reporter   ~0129376

Anton, thanks for your patches. You are the main supporter for gtk3.

Anton Kavalenka

2021-03-06 07:38

reporter   ~0129421

GTK3 currently has no Theme support. DrawFrameControl does noting.
Set TSpeedButton.Transparent to false and the Glyph would be drawn properly.

CudaText man

2021-03-06 10:53

reporter   ~0129424

So gtk3 bug will not be fixed, or what?

Anton Kavalenka

2021-03-07 07:45

reporter   ~0129457

will try to fix.

CudaText man

2021-03-07 11:27

reporter   ~0129467

Thanks in advance. this bug is a blocker for ATButton component.

Anton Kavalenka

2021-03-07 15:53

reporter   ~0129482

Patch fixes the problem. GTK3 pixbuf wants alpha. 32-bit bitmaps are loaded but alpha channel is not handled properly.
Currently the patch contains stupid low-byte clearing cycle.
Need extra knowledge from @Juha Manninen to properly convert coming RawImage to ARGB32.

Also patch fixes setting of some widgets to indexed colors.
Also patch tries to implement drawFrameControl via style context (but without luck)
gtk3.diff (5,072 bytes)   
Index: lcl/interfaces/gtk3/gtk3lclintf.inc
===================================================================
--- lcl/interfaces/gtk3/gtk3lclintf.inc	(revision 64761)
+++ lcl/interfaces/gtk3/gtk3lclintf.inc	(working copy)
@@ -196,6 +196,8 @@
   NewData: PByte;
   ImageFormat: cairo_format_t;
   ARowStride: PtrUInt;
+  x,y:integer;
+  pdst,psrc:pbyte;
 begin
   Result := False;
   ABitmap := 0;
@@ -204,7 +206,19 @@
   if ARawImage.DataSize > 0 then
   begin
     NewData := GetMem(ARawImage.DataSize);
-    Move(ARawImage.Data^, NewData^, ARawImage.DataSize);
+    //Move(ARawImage.Data^, NewData^, ARawImage.DataSize);
+    ARowStride := GetBytesPerLine(Desc.Width, Desc.BitsPerPixel, rileDWordBoundary);
+    psrc:=ARawImage.Data;
+    pdst:=NewData;
+    for y:=0 to Desc.height -1 do
+    begin
+      for x:=0 to Desc.Width-1 do
+      begin
+        pinteger(pdst)^:=pinteger(psrc)^ or $FF000000;
+        inc(pdst,4);
+        inc(psrc,4);
+      end;
+    end;
   end
   else
     NewData := nil;
@@ -747,7 +761,7 @@
       if InvertPixels then
         WorkMask.invertPixels(QImageInvertRGB);
         *)
-      if WorkMask.bits<>nil then
+      if (WorkMask.bits<>nil) and (ARawImage.Mask<>nil) then
       Move(WorkMask.bits^, ARawImage.Mask^, ARawImage.MaskSize);
       // if InvertPixels then
       //  WorkMask.invertPixels(QImageInvertRGB);
Index: lcl/interfaces/gtk3/gtk3objects.pas
===================================================================
--- lcl/interfaces/gtk3/gtk3objects.pas	(revision 64761)
+++ lcl/interfaces/gtk3/gtk3objects.pas	(working copy)
@@ -264,6 +264,7 @@
     procedure fillRect(x, y, w, h: Integer; ABrush: HBRUSH); overload;
     procedure fillRect(x, y, w, h: Integer); overload;
     function RoundRect(X1, Y1, X2, Y2: Integer; RX, RY: Integer): Boolean;
+    function drawFrameControl(arect:TRect;uType,uState:cardinal):boolean;
     function drawFocusRect(const aRect: TRect): boolean;
     function getBpp: integer;
     function getDepth: integer;
@@ -2103,6 +2104,44 @@
   end;
 end;
 
+function TGtk3DeviceContext.drawFrameControl(arect:TRect;uType,uState:cardinal):boolean;
+var
+  Context: PGtkStyleContext;
+  AValue: TGValue;
+  pw:PGtkWidget;
+begin
+  Result:=false;
+  if Parent <> nil then
+    Context := Parent^.get_style_context
+  else
+  begin
+    Context:=TGtkStyleContext.new();
+    Context^.add_class('button');
+  end;
+  if Context = nil then
+  begin
+    DebugLn('WARNING: TGtk3WidgetSet.DrawFrameControl on non widget context isn''t implemented.');
+    exit;
+  end;
+
+  cairo_set_operator(pcr, CAIRO_OPERATOR_OVER);
+  cairo_set_source_rgba(pcr,1,1,1,1);
+  pw:=Self.Parent;
+  while Assigned(pw) do
+  begin
+
+    Context:=pw^.get_style_context;
+    with aRect do
+    begin
+      gtk_render_background(Context,pcr, Left, Top, Right - Left, Bottom - Top);
+      gtk_render_frame(Context,pcr, Left, Top, Right - Left, Bottom - Top);
+    end;
+    pw:=pw^.parent;
+  end;
+
+  Result := True;
+end;
+
 function TGtk3DeviceContext.drawFocusRect(const aRect: TRect): boolean;
 var
   Context: PGtkStyleContext;
Index: lcl/interfaces/gtk3/gtk3widgets.pas
===================================================================
--- lcl/interfaces/gtk3/gtk3widgets.pas	(revision 64761)
+++ lcl/interfaces/gtk3/gtk3widgets.pas	(working copy)
@@ -2370,7 +2370,7 @@
       *)
     end else
     begin
-      ARgba := TColortoTGdkRGBA(AValue);
+      ARgba := TColortoTGdkRGBA(ColorToRGB(AValue));
       {$info GTK3: set GdkRGBA.alpah to 1.0?}
 
       {ColorToCairoRGB(ColorToRGB(AValue), R, G, B);
@@ -6734,10 +6734,15 @@
   Result := PGtkWidget(check);
   check^.set_use_underline(True);
   {fWidgetRGBA[0].G:=0.8;
-  fWidgetRGBA[0].Alpha:=0.7;
-  check^.override_color(GTK_STATE_NORMAL,@Self.FWidgetRGBA[0]);}
+  fWidgetRGBA[0].Alpha:=1;
+  check^.override_color(GTK_STATE_FLAG_NORMAL,@Self.FWidgetRGBA[0]);}
+  (*fWidgetRGBA[0].G:=0.8;
+  fWidgetRGBA[0].B:=0.9;
+  fWidgetRGBA[0].Alpha:=0.9;
+  check^.override_color(GTK_STATE_FLAG_ACTIVE,@Self.FWidgetRGBA[0]); *)
   // nil resets color to gtk default
-  FWidget^.override_background_color(GTK_STATE_FLAG_NORMAL, nil);
+ { FWidget^.override_color(GTK_STATE_FLAG_NORMAL, nil);
+  FWidget^.override_background_color(GTK_STATE_FLAG_NORMAL, nil);}
 end;
 
 { TGtk3RadioButton }
Index: lcl/interfaces/gtk3/gtk3winapi.inc
===================================================================
--- lcl/interfaces/gtk3/gtk3winapi.inc	(revision 64761)
+++ lcl/interfaces/gtk3/gtk3winapi.inc	(working copy)
@@ -600,11 +600,9 @@
 function TGtk3WidgetSet.DrawFrameControl(DC: HDC; const aRect: TRect; uType,
   uState: Cardinal): Boolean;
 begin
-  {$IFDEF GTK3DEBUGNOTIMPLEMENTED}
-  DebugLn('WARNING: TGtk3WidgetSet.DrawFrameControl not implemented ...');
-  {$ENDIF}
-  Result := False;
-  // inherited DrawFrameControl(DC, aRect, uType, uState);
+  Result:=false;
+  if IsValidDC(DC) then
+    Result:=TGtk3DeviceContext(DC).drawFrameControl(aRect,uType,uState);
 end;
 
 function TGtk3WidgetSet.DrawFocusRect(DC: HDC; const aRect: TRect): boolean;
gtk3.diff (5,072 bytes)   

CudaText man

2021-03-07 16:34

reporter   ~0129487

test with last patch-- now my icons in demo, are painted with black BG color!

Juha Manninen

2021-03-07 20:58

developer   ~0129498

Line 217 in gtk3lclintf.inc, in TGtk3WidgetSet.RawImage_CreateBitmaps
      pinteger(pdst)^:=pinteger(psrc)^ or $FF000000;
gives a range check error with the given demo app (tst-icon-draw-gtk3) in my Linux 64-bit system.
Please test wit all debug flags and checks enabled.

> Need extra knowledge from @Juha Manninen to properly convert coming RawImage to ARGB32.

Sorry, my knowledge of graphic programming is limited. Many other Lazarus devels know the topic better.
I somehow ended up applying LCL-GTK3 patches.
You should ask detailed technical questions in Lazarus mailing list, or maybe in forum.

Anton Kavalenka

2021-03-13 17:12

reporter   ~0129632

Some updates
gtk3next.diff (9,090 bytes)   
Index: lcl/interfaces/gtk3/gtk3lclintf.inc
===================================================================
--- lcl/interfaces/gtk3/gtk3lclintf.inc	(revision 64792)
+++ lcl/interfaces/gtk3/gtk3lclintf.inc	(working copy)
@@ -180,6 +180,8 @@
   Result:=inherited GetAcceleratorString(AVKey,AShiftState);
 end;
 
+
+
 {------------------------------------------------------------------------------
   Function: RawImage_CreateBitmap
   Params: ARawImage:
@@ -196,6 +198,9 @@
   NewData: PByte;
   ImageFormat: cairo_format_t;
   ARowStride: PtrUInt;
+  x,y:integer;
+  src,dst,pdst,psrc,SrcRowPtr,DstRowPtr:pbyte;
+  ridx,gidx,bidx,aidx:byte;
 begin
   Result := False;
   ABitmap := 0;
@@ -203,8 +208,57 @@
 
   if ARawImage.DataSize > 0 then
   begin
-    NewData := GetMem(ARawImage.DataSize);
-    Move(ARawImage.Data^, NewData^, ARawImage.DataSize);
+    case Desc.LineEnd of
+    rileQWordBoundary:
+      begin
+        ARowStride := Desc.Width;
+        if Desc.Width and 1 <> 0 then Inc(ARowStride);
+        ARowStride := ARowStride shl 2;
+      end;
+    rileDQWordBoundary:
+      begin
+        ARowStride := Desc.Width shr 1;
+        if Desc.Width and 3 <> 0 then Inc(ARowStride);
+        ARowStride := ARowStride shl 3;
+      end;
+    else
+      ARowStride := Desc.Width shl 2;
+    end;
+
+    // check if the pixels are in order, pixbuf expects them in R-G-B-A
+    Desc.GetRGBIndices(Ridx, Gidx, Bidx, AIdx);
+
+    GetMem(NewData, ArawImage.DataSize);
+
+    //if (Ridx <> 0) or (Gidx <> 1) or (Bidx <> 2) or (AIdx <> 3) then
+    begin
+      // put components in right order
+
+      DstRowPtr := NewData;
+      SrcRowPtr := ArawImage.Data;
+      y := Desc.Height;
+      while y > 0 do
+      begin
+        Src := SrcRowPtr;
+        Dst := DstRowPtr;
+        x := Desc.Width;
+        while x > 0 do
+        begin
+          Dst[0] := Src[Ridx];
+          Dst[1] := Src[Gidx];
+          Dst[2] := Src[Bidx];
+          Dst[3] := $ff;//Src[Aidx] ;
+
+          Inc(Src, 4);
+          Inc(Dst, 4);
+          Dec(x);
+        end;
+        Inc(SrcRowPtr, ARowstride);
+        Inc(DstRowPtr, ARowstride);
+        Dec(y);
+      end;
+    end;
+
   end
   else
     NewData := nil;
@@ -218,22 +272,27 @@
   end;
   ARowStride := GetBytesPerLine(Desc.Width, Desc.BitsPerPixel, rileDWordBoundary);
   ABitmap := HBitmap(TGtk3Image.Create(NewData, Desc.Width, Desc.Height, ARowStride, ImageFormat,
-                     not ASkipMask));  // Using ASkipMask for DataOwner param prevents a crash later.
+                     {not ASkipMask}true));  // Using ASkipMask for DataOwner param prevents a crash later.
   Result := ABitmap <> 0;
 
+ { if ASkipMask then
+  FreeMem(NewData); }
+
   if ASkipMask then Exit;
 
   if (ARawImage.Mask <> nil) and (ARawImage.MaskSize > 0) then
   begin
     NewData := GetMem(ARawImage.MaskSize);
-    Move(ARawImage.Mask^, NewData^, ARawImage.MaskSize);
+    //FillChar(NewData^,  ARawImage.MaskSize,$ff);
+    Move(ARawImage.Mask^, NewData^, ARawImage.MaskSize)
   end
   else
     NewData := nil;
 
-  ARowStride := GetBytesPerLine(Desc.Width, Desc.BitsPerPixel, rileDWordBoundary);
-  AMask := HBitmap(TGtk3Image.Create(NewData, Desc.Width, Desc.Height, ARowStride, CAIRO_FORMAT_A1, True));
 
+  ARowStride := GetBytesPerLine(Desc.Width, {Desc.BitsPerPixel}8, rileDWordBoundary);
+  AMask := HBitmap(TGtk3Image.Create(NewData, Desc.Width, Desc.Height, ARowStride, CAIRO_FORMAT_A8, True));
+
 end;
 
 {------------------------------------------------------------------------------
@@ -747,7 +806,7 @@
       if InvertPixels then
         WorkMask.invertPixels(QImageInvertRGB);
         *)
-      if WorkMask.bits<>nil then
+      if (WorkMask.bits<>nil) and (ARawImage.Mask<>nil) then
       Move(WorkMask.bits^, ARawImage.Mask^, ARawImage.MaskSize);
       // if InvertPixels then
       //  WorkMask.invertPixels(QImageInvertRGB);
Index: lcl/interfaces/gtk3/gtk3objects.pas
===================================================================
--- lcl/interfaces/gtk3/gtk3objects.pas	(revision 64792)
+++ lcl/interfaces/gtk3/gtk3objects.pas	(working copy)
@@ -264,6 +264,7 @@
     procedure fillRect(x, y, w, h: Integer; ABrush: HBRUSH); overload;
     procedure fillRect(x, y, w, h: Integer); overload;
     function RoundRect(X1, Y1, X2, Y2: Integer; RX, RY: Integer): Boolean;
+    function drawFrameControl(arect:TRect;uType,uState:cardinal):boolean;
     function drawFocusRect(const aRect: TRect): boolean;
     function getBpp: integer;
     function getDepth: integer;
@@ -714,11 +715,12 @@
     sz:=fHandle^.get_size;
     if fHandle^.get_size_is_absolute then
     begin
-      sz:=12;// sz div PANGO_SCALE;
+      sz:= sz div PANGO_SCALE;
     end else
     begin
       { in points }
-      sz:=round(96*sz/PANGO_SCALE/72);//round(2.03*sz/PANGO_SCALE);
+      //sz:=round(96*sz/PANGO_SCALE/72);//round(2.03*sz/PANGO_SCALE);
+      sz := MulDiv(sz, 96{Screen.PixelsPerInch}, 72 * PANGO_SCALE)
     end;
 
     fLogFont.lfHeight:=sz;//round(sz/PANGO_SCALE);
@@ -2103,6 +2105,79 @@
   end;
 end;
 
+function TGtk3DeviceContext.drawFrameControl(arect:TRect;uType,uState:cardinal):boolean;
+var
+  Context: PGtkStyleContext;
+  AValue: TGValue;
+  pw:PGtkWidget;
+  path:PGtkwIdgetPath;
+  pc:pgchar;
+  w:PgtkWidget;
+begin
+
+  Result:=false;
+
+ { if Parent <> nil then
+    Context := Parent^.get_style_context
+  else
+  begin
+    Context:=TGtkStyleContext.new();
+    Context^.add_class('button');
+  end;
+  if Context = nil then
+  begin
+    DebugLn('WARNING: TGtk3WidgetSet.DrawFrameControl on non widget context isn''t implemented.');
+    exit;
+  end;  }
+
+  w:=nil;
+
+  if uType=DFC_BUTTON then
+  begin
+    w:=GetStyleWidget(lgsButton);
+  end else
+  if uType=DFC_MENU then
+  begin
+    w:=GetStyleWidget(lgsMenu);
+  end;
+
+  if not Assigned(w) then exit;
+
+  Context:=w^.get_style_context;
+  path:=w^.get_path;
+  gtk_style_context_set_path (context, path);
+  gtk_style_context_set_state (context,(* gtk_widget_path_iter_get_state (path, -1)*) -1);
+
+  {GTK_STATE_FLAG_NORMAL: TGtkStateFlags = 0;
+  GTK_STATE_FLAG_ACTIVE: TGtkStateFlags = 1;
+  GTK_STATE_FLAG_PRELIGHT: TGtkStateFlags = 2;
+  GTK_STATE_FLAG_SELECTED: TGtkStateFlags = 4;
+  GTK_STATE_FLAG_INSENSITIVE: TGtkStateFlags = 8;
+  GTK_STATE_FLAG_INCONSISTENT: TGtkStateFlags = 16;
+  GTK_STATE_FLAG_FOCUSED: TGtkStateFlags = 32;
+  GTK_STATE_FLAG_BACKDROP: TGtkStateFlags = 64;
+  GTK_STATE_FLAG_DIR_LTR: TGtkStateFlags = 128;
+  GTK_STATE_FLAG_DIR_RTL: TGtkStateFlags = 256;
+  }
+  gtk_style_context_set_state (context, GTK_STATE_FLAG_FOCUSED or GTK_STATE_FLAG_PRELIGHT);
+
+  pw:=w;
+  while Assigned(pw) do
+  begin
+
+    Context:=pw^.get_style_context;
+    path:=pw^.get_path;
+    with aRect do
+    begin
+      gtk_render_background(Context,pcr, Left, Top, Right - Left, Bottom - Top);
+      gtk_render_frame(Context,pcr, Left, Top, Right - Left, Bottom - Top);
+    end;
+    pw:=pw^.parent;
+  end;
+
+  Result := True;
+end;
+
 function TGtk3DeviceContext.drawFocusRect(const aRect: TRect): boolean;
 var
   Context: PGtkStyleContext;
Index: lcl/interfaces/gtk3/gtk3widgets.pas
===================================================================
--- lcl/interfaces/gtk3/gtk3widgets.pas	(revision 64792)
+++ lcl/interfaces/gtk3/gtk3widgets.pas	(working copy)
@@ -2370,7 +2370,7 @@
       *)
     end else
     begin
-      ARgba := TColortoTGdkRGBA(AValue);
+      ARgba := TColortoTGdkRGBA(ColorToRGB(AValue));
       {$info GTK3: set GdkRGBA.alpah to 1.0?}
 
       {ColorToCairoRGB(ColorToRGB(AValue), R, G, B);
@@ -6734,10 +6734,15 @@
   Result := PGtkWidget(check);
   check^.set_use_underline(True);
   {fWidgetRGBA[0].G:=0.8;
-  fWidgetRGBA[0].Alpha:=0.7;
-  check^.override_color(GTK_STATE_NORMAL,@Self.FWidgetRGBA[0]);}
+  fWidgetRGBA[0].Alpha:=1;
+  check^.override_color(GTK_STATE_FLAG_NORMAL,@Self.FWidgetRGBA[0]);}
+  (*fWidgetRGBA[0].G:=0.8;
+  fWidgetRGBA[0].B:=0.9;
+  fWidgetRGBA[0].Alpha:=0.9;
+  check^.override_color(GTK_STATE_FLAG_ACTIVE,@Self.FWidgetRGBA[0]); *)
   // nil resets color to gtk default
-  FWidget^.override_background_color(GTK_STATE_FLAG_NORMAL, nil);
+ { FWidget^.override_color(GTK_STATE_FLAG_NORMAL, nil);
+  FWidget^.override_background_color(GTK_STATE_FLAG_NORMAL, nil);}
 end;
 
 { TGtk3RadioButton }
Index: lcl/interfaces/gtk3/gtk3winapi.inc
===================================================================
--- lcl/interfaces/gtk3/gtk3winapi.inc	(revision 64792)
+++ lcl/interfaces/gtk3/gtk3winapi.inc	(working copy)
@@ -600,11 +600,9 @@
 function TGtk3WidgetSet.DrawFrameControl(DC: HDC; const aRect: TRect; uType,
   uState: Cardinal): Boolean;
 begin
-  {$IFDEF GTK3DEBUGNOTIMPLEMENTED}
-  DebugLn('WARNING: TGtk3WidgetSet.DrawFrameControl not implemented ...');
-  {$ENDIF}
-  Result := False;
-  // inherited DrawFrameControl(DC, aRect, uType, uState);
+  Result:=false;
+  if IsValidDC(DC) then
+    Result:=TGtk3DeviceContext(DC).drawFrameControl(aRect,uType,uState);
 end;
 
 function TGtk3WidgetSet.DrawFocusRect(DC: HDC; const aRect: TRect): boolean;
gtk3next.diff (9,090 bytes)   

Juha Manninen

2021-03-14 09:13

developer   ~0129645

I applied the last patch in r64802. Compiles and works. Thanks.
Should I keep this issue open?

CudaText man

2021-03-14 09:47

reporter   ~0129647

Pls do not close yet. with last patch:

- colors of "3 squares" bitmap changes (RGB swaps?) on mouse-over for SpeenBtn
- 3 icons with yellow background now are shown with black one. Picture: gtk2 vs gtk3
gtk2-gtk3.png (33,143 bytes)   
gtk2-gtk3.png (33,143 bytes)   

Anton Kavalenka

2021-03-17 08:29

reporter   ~0129728

Last edited: 2021-03-17 08:33

View 3 revisions

I get lost.
Something in bitmap-loading code leaves alpha-channel filled with garbage.
ImageList bitmap reading works properly.

My solution with forcibly clearing alpha - wrong, but easy to fix.
gtk3lclintf.inc:250 Dst[3] := Src[Aidx] ;

Anyway remains problem with garbled Alpha

Anton Kavalenka

2021-03-20 12:47

reporter   ~0129777

This patch completely disables mask creation (zero-filled mask of proper size), this maybe proper solution as anywhere the Alpha-blending is used.
About swapped R<->B - cannot even imagine where it comes from.
gtk3mask.diff (1,202 bytes)   
Index: lcl/interfaces/gtk3/gtk3lclintf.inc
===================================================================
--- lcl/interfaces/gtk3/gtk3lclintf.inc	(revision 64843)
+++ lcl/interfaces/gtk3/gtk3lclintf.inc	(working copy)
@@ -247,7 +247,7 @@
           Dst[0] := Src[Ridx];
           Dst[1] := Src[Gidx];
           Dst[2] := Src[Bidx];
-          Dst[3] := $ff;//Src[Aidx] ;
+          Dst[3] := Src[Aidx] ;
 
           Inc(Src, 4);
           Inc(Dst, 4);
@@ -282,15 +282,15 @@
 
   if (ARawImage.Mask <> nil) and (ARawImage.MaskSize > 0) then
   begin
-    NewData := GetMem(ARawImage.MaskSize);
-    //FillChar(NewData^,  ARawImage.MaskSize,$ff);
-    Move(ARawImage.Mask^, NewData^, ARawImage.MaskSize);
+    NewData := GetMem(ARawImage.MaskSize*8);
+    FillChar(NewData^,  ARawImage.MaskSize*8,$00);
+    //Move(ARawImage.Mask^, NewData^, ARawImage.MaskSize*8);
   end
   else
     NewData := nil;
 
 
-  ARowStride := GetBytesPerLine(Desc.Width, {Desc.BitsPerPixel}8, rileDWordBoundary);
+  ARowStride := GetBytesPerLine(Desc.Width, {Desc.BitsPerPixel}8, rilebyteBoundary);
   AMask := HBitmap(TGtk3Image.Create(NewData, Desc.Width, Desc.Height, ARowStride, CAIRO_FORMAT_A8, True));
 
 end;
gtk3mask.diff (1,202 bytes)   

Anton Kavalenka

2021-03-20 12:49

reporter   ~0129778

CudaText man

2021-03-20 19:37

reporter   ~0129786

wow, good work! It solves the bug.

CudaText man

2021-03-20 19:42

reporter   ~0129787

But R/B colors are swapped on the 3-square-bitmap.

Juha Manninen

2021-03-21 08:28

developer   ~0129800

Last edited: 2021-03-21 08:29

View 2 revisions

I applied the patch in r64846. Thanks.
The 3-square-bitmap changes colors when I move mouse onto the SpeedButton. See the pics.
Again testing with Manjaro 64-bit + KDE Plasma.
GTK3MouseIn.png (6,077 bytes)   
GTK3MouseIn.png (6,077 bytes)   
GTK3MouseOut.png (6,031 bytes)   
GTK3MouseOut.png (6,031 bytes)   

Anton Kavalenka

2021-03-21 10:44

reporter   ~0129803

Color swapping is the heavy legacy of supporting bitmap as reference-counted win32- like handle objects. Bad LCL design mimicking GDI.
It is very hard to debug, since almost impossible guess where this RawImage
came from.
My first guess - the imagelist effect builder did so.

CudaText man

2021-03-21 11:39

reporter   ~0129804

Post status is 'feedback' so I reply: yes, I also see swapped colors.

Issue History

Date Modified Username Field Change
2021-03-02 09:08 CudaText man New Issue
2021-03-02 09:08 CudaText man File Added: gtk3.png
2021-03-02 09:08 CudaText man File Added: tst-icon-draw-gtk3.zip
2021-03-03 13:44 Anton Kavalenka Note Added: 0129351
2021-03-03 13:52 CudaText man Note Added: 0129353
2021-03-03 13:53 Anton Kavalenka Note Added: 0129354
2021-03-04 10:08 CudaText man Note Added: 0129376
2021-03-06 07:38 Anton Kavalenka Note Added: 0129421
2021-03-06 07:38 Anton Kavalenka File Added: Здымак экрана, 2021-03-06 09-33-44.png
2021-03-06 10:53 CudaText man Note Added: 0129424
2021-03-07 07:45 Anton Kavalenka Note Added: 0129457
2021-03-07 11:27 CudaText man Note Added: 0129467
2021-03-07 15:53 Anton Kavalenka Note Added: 0129482
2021-03-07 15:53 Anton Kavalenka File Added: gtk3.diff
2021-03-07 16:34 CudaText man Note Added: 0129487
2021-03-07 16:34 CudaText man File Added: Screenshot from 2021-03-07 18-33-18.png
2021-03-07 20:58 Juha Manninen Note Added: 0129498
2021-03-13 17:12 Anton Kavalenka Note Added: 0129632
2021-03-13 17:12 Anton Kavalenka File Added: gtk3next.diff
2021-03-13 17:12 Anton Kavalenka File Added: Здымак экрана, 2021-03-13 19-10-11.png
2021-03-14 09:12 Juha Manninen Assigned To => Juha Manninen
2021-03-14 09:12 Juha Manninen Status new => assigned
2021-03-14 09:13 Juha Manninen Status assigned => feedback
2021-03-14 09:13 Juha Manninen LazTarget => -
2021-03-14 09:13 Juha Manninen Note Added: 0129645
2021-03-14 09:13 Juha Manninen Fixed in Revision => r64802
2021-03-14 09:13 Juha Manninen Widgetset GTK 3 => GTK 3
2021-03-14 09:47 CudaText man Note Added: 0129647
2021-03-14 09:47 CudaText man File Added: gtk2-gtk3.png
2021-03-14 09:47 CudaText man Status feedback => assigned
2021-03-17 08:29 Anton Kavalenka Note Added: 0129728
2021-03-17 08:31 Anton Kavalenka Note Edited: 0129728 View Revisions
2021-03-17 08:33 Anton Kavalenka Note Edited: 0129728 View Revisions
2021-03-20 12:47 Anton Kavalenka Note Added: 0129777
2021-03-20 12:47 Anton Kavalenka File Added: gtk3mask.diff
2021-03-20 12:49 Anton Kavalenka Note Added: 0129778
2021-03-20 12:49 Anton Kavalenka File Added: Здымак экрана, 2021-03-20 14-48-35.png
2021-03-20 19:37 CudaText man Note Added: 0129786
2021-03-20 19:42 CudaText man Note Added: 0129787
2021-03-21 08:24 Juha Manninen Fixed in Revision r64802 => r64802, r64846
2021-03-21 08:24 Juha Manninen Widgetset GTK 3 => GTK 3
2021-03-21 08:28 Juha Manninen Note Added: 0129800
2021-03-21 08:28 Juha Manninen File Added: GTK3MouseOut.png
2021-03-21 08:28 Juha Manninen File Added: GTK3MouseIn.png
2021-03-21 08:29 Juha Manninen Note Edited: 0129800 View Revisions
2021-03-21 08:30 Juha Manninen Status assigned => feedback
2021-03-21 10:44 Anton Kavalenka Note Added: 0129803
2021-03-21 11:39 CudaText man Note Added: 0129804
2021-03-21 11:39 CudaText man Status feedback => assigned