Recent

Author Topic: BGRA Toolbar not changing background color  (Read 7910 times)

rkamarowski

  • New Member
  • *
  • Posts: 40
BGRA Toolbar not changing background color
« on: July 20, 2015, 08:16:25 pm »
I've installed the BGRA controls, and the TBCToolbar is not changing color when changing the Color property. Is this a known problem, or am I doing something wrong?

bob k.

lainz

  • Hero Member
  • *****
  • Posts: 3699
  • Leandro Diaz
Re: BGRA Toolbar not changing background color
« Reply #1 on: July 20, 2015, 08:19:27 pm »
I've installed the BGRA controls, and the TBCToolbar is not changing color when changing the Color property. Is this a known problem, or am I doing something wrong?

bob k.

Ok. The purpouse of TBCToolbar is to you customize the event OnRedraw and add your own painting stuff. For that reason changing Color does nothing.

circular

  • Hero Member
  • *****
  • Posts: 3442
    • Personal webpage
Re: BGRA Toolbar not changing background color
« Reply #2 on: July 20, 2015, 08:45:09 pm »
Hi! I have found a solution 007.

I suggest to change DrawWindows7ToolBar by:
Code: [Select]
function SetHue(AColor: TBGRAPixel; g_hue: integer): TBGRAPixel;
var hsla: THSLAPixel;
begin
  if g_hue = -1 then result := AColor else
    begin
      hsla := BGRAToGSBA(AColor);
      hsla.hue := g_hue;
      result := GSBAToBGRA(hsla);
    end;
end;

procedure DrawWindows7ToolBar(Bitmap: TBGRABitmap; AColor: TColor = clDefault);
var
  c1, c2, c3, c4: TBGRAPixel;
  ARect, ARect2: TRect;
  g_hue: integer;
begin
  if AColor = clDefault then
    g_hue := -1
  else
    g_hue := BGRAToGSBA(ColorToBGRA(ColorToRGB(AColor))).hue;
  ARect := Rect(0, 0, Bitmap.Width, Bitmap.Height);
  // Font: RGBToColor(30,57,91)

  Bitmap.HorizLine(ARect.Left, ARect.Top, ARect.Right-1, SetHue(BGRA(169, 191, 214), g_hue), dmSet);
  Bitmap.HorizLine(ARect.Left, ARect.Top + 1, ARect.Right-1, SetHue(BGRA(250, 252, 253), g_hue), dmSet);
  Bitmap.HorizLine(ARect.Left, ARect.Top + 2, ARect.Right-1, SetHue(BGRA(253, 254, 255), g_hue), dmSet);

  c1 := SetHue(BGRA(252, 254, 255), g_hue);
  c2 := SetHue(BGRA(243, 248, 253), g_hue);
  c3 := SetHue(BGRA(238, 243, 250), g_hue);
  c4 := SetHue(BGRA(238, 244, 251), g_hue);
  ARect2 := Rect(ARect.Left, ARect.Top + 3, ARect.Right, ARect.Bottom - 3);
  DoubleGradientAlphaFill(Bitmap, ARect2, c1, c2, c3, c4, gdVertical,
    gdVertical, gdVertical, 0.5);

  c1 := SetHue(BGRA(249, 252, 255), g_hue);
  c2 := SetHue(BGRA(230, 240, 250), g_hue);
  c3 := SetHue(BGRA(220, 230, 244), g_hue);
  c4 := SetHue(BGRA(221, 233, 247), g_hue);
  ARect2 := Rect(ARect.Left + 1, ARect.Top + 3, ARect.Right - 1, ARect.Bottom - 3);
  DoubleGradientAlphaFill(Bitmap, ARect2, c1, c2, c3, c4, gdVertical,
    gdVertical, gdVertical, 0.5);

  Bitmap.HorizLine(ARect.Left, ARect.Bottom - 3, ARect.Right-1, SetHue(BGRA(228, 239, 251), g_hue), dmSet);
  Bitmap.HorizLine(ARect.Left, ARect.Bottom - 2, ARect.Right-1, SetHue(BGRA(205, 218, 234), g_hue), dmSet);
  Bitmap.HorizLine(ARect.Left, ARect.Bottom - 1, ARect.Right-1, SetHue(BGRA(160, 175, 195), g_hue), dmSet);
end;

Then in TBCToolbar.Paint, to add Color as a parameter when calling DrawWindows7ToolBar.

If Color = clDefault, it will look the same, otherwise it will be colorized.

Regards
Conscience is the debugger of the mind

rkamarowski

  • New Member
  • *
  • Posts: 40
Re: BGRA Toolbar not changing background color
« Reply #3 on: July 20, 2015, 10:14:01 pm »
Thank you.

lainz

  • Hero Member
  • *****
  • Posts: 3699
  • Leandro Diaz
Re: BGRA Toolbar not changing background color
« Reply #4 on: July 21, 2015, 12:08:11 am »
Hi! I have found a solution 007.

I suggest to change DrawWindows7ToolBar by:
Code: [Select]
function SetHue(AColor: TBGRAPixel; g_hue: integer): TBGRAPixel;
var hsla: THSLAPixel;
begin
  if g_hue = -1 then result := AColor else
    begin
      hsla := BGRAToGSBA(AColor);
      hsla.hue := g_hue;
      result := GSBAToBGRA(hsla);
    end;
end;

procedure DrawWindows7ToolBar(Bitmap: TBGRABitmap; AColor: TColor = clDefault);
var
  c1, c2, c3, c4: TBGRAPixel;
  ARect, ARect2: TRect;
  g_hue: integer;
begin
  if AColor = clDefault then
    g_hue := -1
  else
    g_hue := BGRAToGSBA(ColorToBGRA(ColorToRGB(AColor))).hue;
  ARect := Rect(0, 0, Bitmap.Width, Bitmap.Height);
  // Font: RGBToColor(30,57,91)

  Bitmap.HorizLine(ARect.Left, ARect.Top, ARect.Right-1, SetHue(BGRA(169, 191, 214), g_hue), dmSet);
  Bitmap.HorizLine(ARect.Left, ARect.Top + 1, ARect.Right-1, SetHue(BGRA(250, 252, 253), g_hue), dmSet);
  Bitmap.HorizLine(ARect.Left, ARect.Top + 2, ARect.Right-1, SetHue(BGRA(253, 254, 255), g_hue), dmSet);

  c1 := SetHue(BGRA(252, 254, 255), g_hue);
  c2 := SetHue(BGRA(243, 248, 253), g_hue);
  c3 := SetHue(BGRA(238, 243, 250), g_hue);
  c4 := SetHue(BGRA(238, 244, 251), g_hue);
  ARect2 := Rect(ARect.Left, ARect.Top + 3, ARect.Right, ARect.Bottom - 3);
  DoubleGradientAlphaFill(Bitmap, ARect2, c1, c2, c3, c4, gdVertical,
    gdVertical, gdVertical, 0.5);

  c1 := SetHue(BGRA(249, 252, 255), g_hue);
  c2 := SetHue(BGRA(230, 240, 250), g_hue);
  c3 := SetHue(BGRA(220, 230, 244), g_hue);
  c4 := SetHue(BGRA(221, 233, 247), g_hue);
  ARect2 := Rect(ARect.Left + 1, ARect.Top + 3, ARect.Right - 1, ARect.Bottom - 3);
  DoubleGradientAlphaFill(Bitmap, ARect2, c1, c2, c3, c4, gdVertical,
    gdVertical, gdVertical, 0.5);

  Bitmap.HorizLine(ARect.Left, ARect.Bottom - 3, ARect.Right-1, SetHue(BGRA(228, 239, 251), g_hue), dmSet);
  Bitmap.HorizLine(ARect.Left, ARect.Bottom - 2, ARect.Right-1, SetHue(BGRA(205, 218, 234), g_hue), dmSet);
  Bitmap.HorizLine(ARect.Left, ARect.Bottom - 1, ARect.Right-1, SetHue(BGRA(160, 175, 195), g_hue), dmSet);
end;

Then in TBCToolbar.Paint, to add Color as a parameter when calling DrawWindows7ToolBar.

If Color = clDefault, it will look the same, otherwise it will be colorized.

Regards

Thankyou. I'll update asap. Currently SourceForge is down, I'll put that in GitHub and when SF get back I'll update there too.

rkamarowski

  • New Member
  • *
  • Posts: 40
Re: BGRA Toolbar not changing background color
« Reply #5 on: July 21, 2015, 06:35:26 pm »
I'm new to Lazarus. I'm not sure where to call the function and procedure you gave me.  From the onReDraw event?
« Last Edit: July 21, 2015, 06:49:01 pm by rkamarowski »

lainz

  • Hero Member
  • *****
  • Posts: 3699
  • Leandro Diaz
Re: BGRA Toolbar not changing background color
« Reply #6 on: July 21, 2015, 08:10:37 pm »
I'm new to Lazarus. I'm not sure where to call the function and procedure you gave me.  From the onReDraw event?

Just go to https://github.com/bgrabitmap/bgracontrols and download that repository. Then you have the updated bctoolbar.pas file.

This is the file for the latest sources: https://github.com/bgrabitmap/bgracontrols/archive/master.zip

rkamarowski

  • New Member
  • *
  • Posts: 40
Re: BGRA Toolbar not changing background color
« Reply #7 on: July 21, 2015, 09:48:11 pm »
thank you.

rkamarowski

  • New Member
  • *
  • Posts: 40
Re: BGRA Toolbar not changing background color
« Reply #8 on: July 22, 2015, 07:35:29 pm »
I have the same question concerning the BCButtonToolbar. Is this something I have to do on my own? The StateClicked, StateHover and StateNormal don't change color.

lainz

  • Hero Member
  • *****
  • Posts: 3699
  • Leandro Diaz
Re: BGRA Toolbar not changing background color
« Reply #9 on: July 22, 2015, 08:53:00 pm »
I have the same question concerning the BCButtonToolbar. Is this something I have to do on my own? The StateClicked, StateHover and StateNormal don't change color.

There is nothing like BCButtonToolbar.

To theme the buttons you must use TToolBar from Lazarus trunk, I've sent a patch that allows you to override the drawing of the toolbar and toolbuttons. But we can't add that to BGRAControls yet because is not available for lazarus release. But maybe that is not so simple if you're just starting.

If you use BCButton or BCImageButton or other buttons that comes with BGRAControls check the demos.

What you want to do? Maybe is easier to help you if you tell us what you want to achieve.

lainz

  • Hero Member
  • *****
  • Posts: 3699
  • Leandro Diaz
Re: BGRA Toolbar not changing background color
« Reply #10 on: July 22, 2015, 09:40:49 pm »
I have the same question concerning the BCButtonToolbar. Is this something I have to do on my own? The StateClicked, StateHover and StateNormal don't change color.

I think I get it. You say BCButton? That control should be changed by each state each property to get the result you want.

There are some presets like "Windows 7 toolbar" and others that you can change with the IDE.

Maybe a global Color property can be added like was added by Circular for the ToolBar.

What do you think Circular? You can do that?

circular

  • Hero Member
  • *****
  • Posts: 3442
    • Personal webpage
Re: BGRA Toolbar not changing background color
« Reply #11 on: July 22, 2015, 09:45:30 pm »
I don't know. I am a bit confused. What kind of buttons are we talking about?
Conscience is the debugger of the mind

lainz

  • Hero Member
  • *****
  • Posts: 3699
  • Leandro Diaz
Re: BGRA Toolbar not changing background color
« Reply #12 on: July 22, 2015, 11:03:13 pm »
I think he says BCButton. Yeah, a lot of properties and colors... Maybe is possible that he uses a 'Colorize' in this event:

Code: [Select]
procedure TForm1.BCButton1AfterRenderBCButton(Sender: TObject;
  const ABGRA: TBGRABitmap; AState: TBCButtonState; ARect: TRect);
begin
  // Some colorize filter here
end;   

And apply just a filter to change the color to fit their toolbar look.

In first place, he must go to Object Inspector > Assign Style > Windows7-tolbutton.bcbtn > Assign style.

circular

  • Hero Member
  • *****
  • Posts: 3442
    • Personal webpage
Re: BGRA Toolbar not changing background color
« Reply #13 on: July 22, 2015, 11:11:57 pm »
Hmm... colorizing would be a bit slow compared to drawing directly with an adequate color. The option you suggested before, setting the colors of a BCButton, is faster.
Conscience is the debugger of the mind

lainz

  • Hero Member
  • *****
  • Posts: 3699
  • Leandro Diaz
Re: BGRA Toolbar not changing background color
« Reply #14 on: July 23, 2015, 02:00:27 am »
Ok. This can help:

Attached the project that colorizes the win7 toolbar button.

 

TinyPortal © 2005-2018