On Thursday 17 November 2016 23:03:05 Krzysztof wrote:
> Hi Martin,
>
> Do you remember my issues with Intel HD Skylake 520 and bmo_graymask?
> Setting bmo_colormask fixed this issue on both graphics: HD 520 and old HD
> 4400.
>
> Few things changed form that time: I have now Linux Mint 18 KDE edition
> (instead of Kubuntu 16.04) and recently had big updates on mesa from
> official stable repo.
>
> Today tried set main form icon in my new app and implement tray icon.
> Noticed regressions between bmo_graymask and bmo_colormask. See attached
> video
>
> bmo_colormask:
> 1. Main form icon has icon but background has weird artifacts

See below.

> 2. Tray icon doesn't have transparent background but that is known since
> MSE doesn't have support for it.
> But sometimes background has different 
> width when switching between colors
>
> bmo_graymask:
> 1. First of all, it is suprise that icons finally are showing at HD 520 at
> all (maybe messa updates have something to do with?)

Probably. :-)

> 2. Main form icon is not drawed but background's artifacts still appear

Works for me with attached files.

> 3. Tray icon after first timagelisttray.bitmap.init() has transparent
> background. How it is possible? :o
>
I don't know.

> BTW: I want to add customizable icon color in my app.
> Is timagelisttray.bitmap.init() correct way for do this? Or better clear
> imagelist and readd icons with glyphs.getcell(....,<newcolor>)?
>
Because the glyph outline is in mask only, calling timagelist.bitmap.init() is 
the most performant method.

> When creating this demo I noticed another issue with tray icon. Function
> below is from my old MSE app made on previous laptop. It is connected
> to ttraywidget.onresize event. I remember that onresize event was triggered
> twice, first with initial 50x50 and then with correct tray X window size
> (IIRC 26x26). Now it is called only once with 50x50 but icon
> is surprisingly drawed fine (rescaled?). Goal for this function was create
> tray icon fit exactly to X window size. As you can see in attached demo, I
> commented condition on <>50
>
It probably depends on the window-manager/desktop-environment how it handles 
try icon windows. I fear you need to expect everything...

Martin
object mainfo: tmainfo
  bounds_x = 986
  bounds_y = 763
  bounds_cx = 399
  bounds_cy = 237
  container.frame.localprops = []
  container.frame.localprops1 = []
  container.bounds = (
    0
    0
    399
    237
  )
  icon.options = [bmo_masked, bmo_graymask]
  onloaded = LoadIcons
  moduleclassname = 'tmainform'
  object ticon1: ticon
    bounds_x = 88
    bounds_y = 48
    imagelist = timagelist1
  end
  object tbutton1: tbutton
    taborder = 1
    bounds_x = 128
    bounds_y = 32
    bounds_cx = 66
    bounds_cy = 44
    state = [as_localimagelist]
    imagelist = timagelist1
  end
  object tbutton2: tbutton
    taborder = 2
    bounds_x = 72
    bounds_y = 128
    bounds_cx = 50
    bounds_cy = 20
    state = [as_localcaption, as_localonexecute]
    caption = 'black'
    onexecute = ChangeColor
  end
  object tbutton3: tbutton
    Tag = 1
    taborder = 3
    bounds_x = 136
    bounds_y = 128
    bounds_cx = 50
    bounds_cy = 20
    state = [as_localcaption, as_localonexecute]
    caption = 'red'
    onexecute = ChangeColor
  end
  object tbutton4: tbutton
    Tag = 2
    taborder = 4
    bounds_x = 200
    bounds_y = 128
    bounds_cx = 50
    bounds_cy = 20
    state = [as_localcaption, as_localonexecute]
    caption = 'blue'
    onexecute = ChangeColor
  end
  object tbutton5: tbutton
    Tag = 3
    taborder = 5
    bounds_x = 264
    bounds_y = 128
    bounds_cx = 50
    bounds_cy = 20
    state = [as_localcaption, as_localonexecute]
    caption = 'green'
    onexecute = ChangeColor
  end
  object ttraywidget1: ttraywidget
    taborder = 6
    bounds_x = 288
    bounds_y = 64
    bounds_cx = 50
    bounds_cy = 50
    onresize = InitTrayIcon
    imagelist = timagelisttray
  end
  object tbutton6: tbutton
    taborder = 7
    bounds_x = 208
    bounds_y = 48
    bounds_cx = 50
    bounds_cy = 20
    state = [as_localimagelist]
    imagelist = timagelist1
  end
  object timagelist1: timagelist
    options = [bmo_masked, bmo_graymask]
    left = 272
    top = 32
  end
  object timagelisttray: timagelist
    options = [bmo_masked, bmo_graymask]
    left = 272
    top = 4
  end
end
unit main_mfm;
{$ifdef FPC}{$mode objfpc}{$h+}{$endif}

interface

implementation
uses
 mseclasses,main;

const
 objdata: record size: integer; data: array[0..1485] of byte end =
      (size: 1486; data: (
  84,80,70,48,7,116,109,97,105,110,102,111,6,109,97,105,110,102,111,8,
  98,111,117,110,100,115,95,120,3,218,3,8,98,111,117,110,100,115,95,121,
  3,251,2,9,98,111,117,110,100,115,95,99,120,3,143,1,9,98,111,117,
  110,100,115,95,99,121,3,237,0,26,99,111,110,116,97,105,110,101,114,46,
  102,114,97,109,101,46,108,111,99,97,108,112,114,111,112,115,11,0,27,99,
  111,110,116,97,105,110,101,114,46,102,114,97,109,101,46,108,111,99,97,108,
  112,114,111,112,115,49,11,0,16,99,111,110,116,97,105,110,101,114,46,98,
  111,117,110,100,115,1,2,0,2,0,3,143,1,3,237,0,0,12,105,99,
  111,110,46,111,112,116,105,111,110,115,11,10,98,109,111,95,109,97,115,107,
  101,100,12,98,109,111,95,103,114,97,121,109,97,115,107,0,8,111,110,108,
  111,97,100,101,100,7,9,76,111,97,100,73,99,111,110,115,15,109,111,100,
  117,108,101,99,108,97,115,115,110,97,109,101,6,9,116,109,97,105,110,102,
  111,114,109,0,5,116,105,99,111,110,6,116,105,99,111,110,49,8,98,111,
  117,110,100,115,95,120,2,88,8,98,111,117,110,100,115,95,121,2,48,9,
  105,109,97,103,101,108,105,115,116,7,11,116,105,109,97,103,101,108,105,115,
  116,49,0,0,7,116,98,117,116,116,111,110,8,116,98,117,116,116,111,110,
  49,8,116,97,98,111,114,100,101,114,2,1,8,98,111,117,110,100,115,95,
  120,3,128,0,8,98,111,117,110,100,115,95,121,2,32,9,98,111,117,110,
  100,115,95,99,120,2,66,9,98,111,117,110,100,115,95,99,121,2,44,5,
  115,116,97,116,101,11,17,97,115,95,108,111,99,97,108,105,109,97,103,101,
  108,105,115,116,0,9,105,109,97,103,101,108,105,115,116,7,11,116,105,109,
  97,103,101,108,105,115,116,49,0,0,7,116,98,117,116,116,111,110,8,116,
  98,117,116,116,111,110,50,8,116,97,98,111,114,100,101,114,2,2,8,98,
  111,117,110,100,115,95,120,2,72,8,98,111,117,110,100,115,95,121,3,128,
  0,9,98,111,117,110,100,115,95,99,120,2,50,9,98,111,117,110,100,115,
  95,99,121,2,20,5,115,116,97,116,101,11,15,97,115,95,108,111,99,97,
  108,99,97,112,116,105,111,110,17,97,115,95,108,111,99,97,108,111,110,101,
  120,101,99,117,116,101,0,7,99,97,112,116,105,111,110,6,5,98,108,97,
  99,107,9,111,110,101,120,101,99,117,116,101,7,11,67,104,97,110,103,101,
  67,111,108,111,114,0,0,7,116,98,117,116,116,111,110,8,116,98,117,116,
  116,111,110,51,3,84,97,103,2,1,8,116,97,98,111,114,100,101,114,2,
  3,8,98,111,117,110,100,115,95,120,3,136,0,8,98,111,117,110,100,115,
  95,121,3,128,0,9,98,111,117,110,100,115,95,99,120,2,50,9,98,111,
  117,110,100,115,95,99,121,2,20,5,115,116,97,116,101,11,15,97,115,95,
  108,111,99,97,108,99,97,112,116,105,111,110,17,97,115,95,108,111,99,97,
  108,111,110,101,120,101,99,117,116,101,0,7,99,97,112,116,105,111,110,6,
  3,114,101,100,9,111,110,101,120,101,99,117,116,101,7,11,67,104,97,110,
  103,101,67,111,108,111,114,0,0,7,116,98,117,116,116,111,110,8,116,98,
  117,116,116,111,110,52,3,84,97,103,2,2,8,116,97,98,111,114,100,101,
  114,2,4,8,98,111,117,110,100,115,95,120,3,200,0,8,98,111,117,110,
  100,115,95,121,3,128,0,9,98,111,117,110,100,115,95,99,120,2,50,9,
  98,111,117,110,100,115,95,99,121,2,20,5,115,116,97,116,101,11,15,97,
  115,95,108,111,99,97,108,99,97,112,116,105,111,110,17,97,115,95,108,111,
  99,97,108,111,110,101,120,101,99,117,116,101,0,7,99,97,112,116,105,111,
  110,6,4,98,108,117,101,9,111,110,101,120,101,99,117,116,101,7,11,67,
  104,97,110,103,101,67,111,108,111,114,0,0,7,116,98,117,116,116,111,110,
  8,116,98,117,116,116,111,110,53,3,84,97,103,2,3,8,116,97,98,111,
  114,100,101,114,2,5,8,98,111,117,110,100,115,95,120,3,8,1,8,98,
  111,117,110,100,115,95,121,3,128,0,9,98,111,117,110,100,115,95,99,120,
  2,50,9,98,111,117,110,100,115,95,99,121,2,20,5,115,116,97,116,101,
  11,15,97,115,95,108,111,99,97,108,99,97,112,116,105,111,110,17,97,115,
  95,108,111,99,97,108,111,110,101,120,101,99,117,116,101,0,7,99,97,112,
  116,105,111,110,6,5,103,114,101,101,110,9,111,110,101,120,101,99,117,116,
  101,7,11,67,104,97,110,103,101,67,111,108,111,114,0,0,11,116,116,114,
  97,121,119,105,100,103,101,116,12,116,116,114,97,121,119,105,100,103,101,116,
  49,8,116,97,98,111,114,100,101,114,2,6,8,98,111,117,110,100,115,95,
  120,3,32,1,8,98,111,117,110,100,115,95,121,2,64,9,98,111,117,110,
  100,115,95,99,120,2,50,9,98,111,117,110,100,115,95,99,121,2,50,8,
  111,110,114,101,115,105,122,101,7,12,73,110,105,116,84,114,97,121,73,99,
  111,110,9,105,109,97,103,101,108,105,115,116,7,14,116,105,109,97,103,101,
  108,105,115,116,116,114,97,121,0,0,7,116,98,117,116,116,111,110,8,116,
  98,117,116,116,111,110,54,8,116,97,98,111,114,100,101,114,2,7,8,98,
  111,117,110,100,115,95,120,3,208,0,8,98,111,117,110,100,115,95,121,2,
  48,9,98,111,117,110,100,115,95,99,120,2,50,9,98,111,117,110,100,115,
  95,99,121,2,20,5,115,116,97,116,101,11,17,97,115,95,108,111,99,97,
  108,105,109,97,103,101,108,105,115,116,0,9,105,109,97,103,101,108,105,115,
  116,7,11,116,105,109,97,103,101,108,105,115,116,49,0,0,10,116,105,109,
  97,103,101,108,105,115,116,11,116,105,109,97,103,101,108,105,115,116,49,7,
  111,112,116,105,111,110,115,11,10,98,109,111,95,109,97,115,107,101,100,12,
  98,109,111,95,103,114,97,121,109,97,115,107,0,4,108,101,102,116,3,16,
  1,3,116,111,112,2,32,0,0,10,116,105,109,97,103,101,108,105,115,116,
  14,116,105,109,97,103,101,108,105,115,116,116,114,97,121,7,111,112,116,105,
  111,110,115,11,10,98,109,111,95,109,97,115,107,101,100,12,98,109,111,95,
  103,114,97,121,109,97,115,107,0,4,108,101,102,116,3,16,1,3,116,111,
  112,2,4,0,0,0)
 );

initialization
 registerobjectdata(@objdata,tmainfo,'');
end.
unit main;
{$ifdef FPC}{$mode objfpc}{$h+}{$endif}
interface
uses
 msetypes,mseglob,mseguiglob,mseguiintf,mseapplication,msestat,msemenus,msegui,
 msegraphics,msegraphutils,mseevent,mseclasses,msewidgets,mseforms,
 msesimplewidgets,msebitmap,msetraywidget;

type
 tmainfo = class(tmainform)
   ticon1: ticon;
   tbutton1: tbutton;
   timagelist1: timagelist;
   tbutton2: tbutton;
   tbutton3: tbutton;
   tbutton4: tbutton;
   tbutton5: tbutton;
   ttraywidget1: ttraywidget;
   timagelisttray: timagelist;
   tbutton6: tbutton;
   procedure LoadIcons(const sender: TObject);
   procedure ChangeColor(const sender: TObject);
   procedure InitTrayIcon(const sender: TObject);
 private
   procedure CreateTrayIcon(X,Y: Integer);
   procedure ReloadIcons;
 end;
var
 mainfo: tmainfo;
 
var
  iICO16_MAIN,
  iICO_TRAY: Integer; 
 
implementation

uses
 main_mfm, mseftglyphs, sysutils;
  
procedure tmainfo.LoadIcons(const sender: TObject);
var
  glyphs: tftglyphs;
  b: tmaskedbitmap;
  
  function _Add(ACode: LongWord; AColor: colorty=cl_default; X: SmallInt=0;
    Y: SmallInt=0): Integer;
  var bOk: Boolean;
  begin
    bOk := glyphs.getcell(b,ACode,mf(X, 0, 0, Y),cl_black);

    if not bOk then
      raise Exception.Create(Format('Could not get FA icon code %d',[ACode]));
    //if l.count=0 then
      //l.size:= b.bitmap.size;

    if b.height>timagelist1.height then
      raise Exception.Create(Format('Wront list height: %d<>%d',[timagelist1.height,b.bitmap.height]));
    if b.width>timagelist1.width then
      raise Exception.Create(Format('Wront list width: %d<>%d',[timagelist1.width,b.bitmap.width]));
    Result := timagelist1.addimage(b, [al_xcentered,al_ycentered]);
  end;

begin

  // 16 px
  glyphs:= tftglyphs.create('FontAwesome.otf',0,16);
  b := tmaskedbitmap.create(bmk_gray);
  try
    iICO16_MAIN            := _Add(61441);
  finally
    glyphs.free();
    b.Free;
  end;
  
  ReloadIcons;
end;

procedure tmainfo.ReloadIcons;
begin
  timagelist1.getimage(iICO16_MAIN, Self.icon); 
    //bmo_masked and bmo_graymask must be set in self.icon.options
    //otherwise the imagelist mask will not be copied but used for
    //copying the imaglist pixels
  ticon1.imagenum := iICO16_MAIN;
  ticon1.invalidate;
  tbutton1.imagenr := iICO16_MAIN;
  tbutton6.imagenr := iICO16_MAIN;
  ttraywidget1.invalidate;
end;

procedure tmainfo.ChangeColor(const sender: TObject);
begin
  case tbutton(sender).Tag of
  0:
    begin
      timagelist1.bitmap.init(cl_black);
      timagelisttray.bitmap.init(cl_black);
    end; 
  1:
    begin
      timagelist1.bitmap.init(cl_red);
      timagelisttray.bitmap.init(cl_red);
    end; 
  2:
    begin
      timagelist1.bitmap.init(cl_green);
      timagelisttray.bitmap.init(cl_green);
    end; 
  3:
    begin
      timagelist1.bitmap.init(cl_blue);
      timagelisttray.bitmap.init(cl_blue);
    end; 
  end;
  
  ReloadIcons;
end;

procedure tmainfo.InitTrayIcon(const sender: TObject);
begin
//  if (ttraywidget1.imagenum=-1) {and (ttraywidget1.width<>50) and (ttraywidget1.height<>50) }then
//  begin
    CreateTrayIcon(ttraywidget1.width, ttraywidget1.height);
    ttraywidget1.imagenum := iICO_TRAY;
//  end;
end;

procedure tmainfo.CreateTrayIcon(X: Integer; Y: Integer);
var
  glyphs: tftglyphs;
  b: tmaskedbitmap;
begin
  glyphs:= tftglyphs.create('FontAwesome.otf',0,Y);
  b := tmaskedbitmap.create(bmk_gray);
  try
    timagelisttray.clear();
    glyphs.getcell(b,61441{,mf(X, 0, 0, Y)},cl_black);
    timagelisttray.size := b.size;
    iICO_TRAY := timagelisttray.addimage(b, [al_xcentered,al_ycentered]);
  finally
    glyphs.free();
    b.Free;
  end;
end;

end.
------------------------------------------------------------------------------
_______________________________________________
mseide-msegui-talk mailing list
mseide-msegui-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk

Reply via email to