Recent

Author Topic: changing how disabled (tbgra)button are visualized  (Read 14489 times)

Blue1987

  • Full Member
  • ***
  • Posts: 165
changing how disabled (tbgra)button are visualized
« on: September 30, 2011, 01:16:06 pm »
using TBGRAbuttons... I would like to make disablede buttons semi-transparent (say alpha 100)...
is it possible?

thank you,
Paolo

Blue1987

  • Full Member
  • ***
  • Posts: 165
Re: changing how disabled (tbgra)button are visualized
« Reply #1 on: October 03, 2011, 12:55:04 am »
isn't it possible?

Blue1987

  • Full Member
  • ***
  • Posts: 165
Re: changing how disabled (tbgra)button are visualized
« Reply #2 on: October 04, 2011, 02:11:30 pm »
isn't it possible?

up...


how can I change how "enabled/disabled" components are displayed?

Shebuka

  • Sr. Member
  • ****
  • Posts: 422
Re: changing how disabled (tbgra)button are visualized
« Reply #3 on: October 04, 2011, 03:22:12 pm »
Try TBGRAImageButton and make the alpha layer transparent as your needs.

Blue1987

  • Full Member
  • ***
  • Posts: 165
Re: changing how disabled (tbgra)button are visualized
« Reply #4 on: October 04, 2011, 04:19:15 pm »
I am already using TBGRAbuttons...
I simply would like to change how DISABLED tgrabuttons are visualized...

but the question would be the same for a label, or any other component!


where are the "visual settings" for "enabled/disabled" components? how can I change them?

Blue1987

  • Full Member
  • ***
  • Posts: 165
Re: changing how disabled (tbgra)button are visualized
« Reply #5 on: October 06, 2011, 02:32:58 pm »
where are the "visual settings" for "enabled/disabled" components? how can I change them?

up  O:-)

lainz

  • Guest
Re: changing how disabled (tbgra)button are visualized
« Reply #6 on: October 06, 2011, 06:23:21 pm »
Most bgracontrols are like examples of the things you can do with BGRABitmap, if you want some new feature or addapt one to fit with your needs you can improve the code because it's LGPL.

BTW contact Dibo if you really need that state, he is the author of that component.

There is no 'visual settings' for enabled / disabled. Look, for example, the Paint code in BGRAImageButton: if Enabled then... check and draw the current state (that's modified when you move the mouse, clic, etc) else (when it is disabled) draw the disabled state.

Blue1987

  • Full Member
  • ***
  • Posts: 165
Re: changing how disabled (tbgra)button are visualized
« Reply #7 on: October 09, 2011, 03:34:45 pm »
Most bgracontrols are like examples of the things you can do with BGRABitmap, if you want some new feature or addapt one to fit with your needs you can improve the code because it's LGPL.

BTW contact Dibo if you really need that state, he is the author of that component.

There is no 'visual settings' for enabled / disabled. Look, for example, the Paint code in BGRAImageButton: if Enabled then... check and draw the current state (that's modified when you move the mouse, clic, etc) else (when it is disabled) draw the disabled state.

this is the solution I am tring to implement...

Code: [Select]
type

Tbgrabutton = class(BGRAButtons.TBGRAButton)
public
  procedure Paint; override;
end;


...


implementation

procedure TBGRAButton.Paint;
var
  bodya, bodyn: TBody;
  baserect: TRect;
begin
  //inherited Paint;
  { Mouse stage }
  case FMouseStage of
    msClicked: bodya := FBodyClicked;
    msHover: bodya := FBodyHover;
    msNormal: bodya := FBodyNormal;
  end;

  { Calculating base rect }
  baserect := ClientRect;
  Inc(baserect.Left, Round(FBorderWidth / 2));
  Inc(baserect.Top, Round(FBorderWidth / 2));
  Dec(baserect.Right, Round(FBorderWidth / 2) + 1);
  Dec(baserect.Bottom, Round(FBorderWidth / 2) + 1);

  { Clearing previous paint }
  FBGRA.Fill(BGRAPixelTransparent);

  { Drawing main button }
  if (FActiveButt = bbtButton) and (not FStaticButton) then
    bodyn := bodya
  else
    bodyn := FBodyNormal;

  DrawBasicBody(bodyn, Rect(baserect.Left, baserect.Top, baserect.Right -
    ifthen(FStyle = bbtDropDown, ARR_SPACE), baserect.Bottom));

  { Drop down arrow button }
  if FStyle = bbtDropDown then
  begin
    if (FActiveButt = bbtDropDown) and (not FStaticButton) then
      bodyn := bodya
    else
      bodyn := FBodyNormal;

    DrawBasicBody(bodyn, Rect(baserect.Right - ARR_SPACE, baserect.Top,
      baserect.Right, baserect.Bottom));
    { Drawing arrow }
    DrawArrow(bodyn, baserect);
  end;

  if FTextApplyGlobalOpacity then
  begin
    { Drawing text }
    DrawText(bodyn.FFont.Color, bodyn.FFont.Style, bodyn.FFont.Name);
    { Set global opacity }
   if Enabled then FBGRA.ApplyGlobalOpacity(FGlobalOpacity) else FBGRA.ApplyGlobalOpacity(100);
end
  else
  begin
    { Set global opacity }
    if Enabled then FBGRA.ApplyGlobalOpacity(FGlobalOpacity) else FBGRA.ApplyGlobalOpacity(100);
{ Drawing text }
    DrawText(bodyn.FFont.Color, bodyn.FFont.Style, bodyn.FFont.Name);
  end;

  { Convert to gray if not enabled }
  if not Enabled then
    ConvertToGrayScale;

  { Finally drawing on canvas }
  FBGRA.Draw(Self.Canvas, 0, 0, False);
end;



but when I try to compile I get the following errors:

Code: [Select]
Unit1.pas(2543,16)
Unit1.pas(2581,20) Error: Identifier not found "FMouseStage"
Unit1.pas(2582,14) Error: Identifier not found "msClicked"
Unit1.pas(2582,14) Error: Constant Expression expected
Unit1.pas(2582,37) Error: Identifier not found "FBodyClicked"
Unit1.pas(2583,12) Error: Identifier not found "msHover"
Unit1.pas(2583,12) Error: Constant Expression expected
Unit1.pas(2583,12) Error: duplicate case label
Unit1.pas(2583,33) Error: Identifier not found "FBodyHover"
Unit1.pas(2584,13) Error: Identifier not found "msNormal"
Unit1.pas(2584,13) Error: Constant Expression expected
Unit1.pas(2584,13) Error: duplicate case label
Unit1.pas(2584,35) Error: Identifier not found "FBodyNormal"
Unit1.pas(2589,41) Error: Identifier not found "FBorderWidth"
Unit1.pas(2589,3) Error: Incompatible types: got "untyped" expected "LongInt"
Unit1.pas(2590,40) Error: Identifier not found "FBorderWidth"
Unit1.pas(2590,3) Error: Incompatible types: got "untyped" expected "LongInt"
Unit1.pas(2591,42) Error: Identifier not found "FBorderWidth"
Unit1.pas(2591,3) Error: Incompatible types: got "untyped" expected "LongInt"
Unit1.pas(2592,43) Error: Identifier not found "FBorderWidth"
Unit1.pas(2592,3) Error: Incompatible types: got "untyped" expected "LongInt"
Unit1.pas(2595,8) Error: Identifier not found "FBGRA"
Unit1.pas(2595,34) Error: Identifier not found "BGRAPixelTransparent"
Unit1.pas(2598,19) Error: Identifier not found "FActiveButt"
Unit1.pas(2598,54) Error: Identifier not found "FStaticButton"
Unit1.pas(2601,25) Error: Identifier not found "FBodyNormal"
Unit1.pas(2603,16) Error: Identifier not found "DrawBasicBody"
Unit1.pas(2604,11) Error: Identifier not found "ifthen"
Unit1.pas(2604,19) Error: Identifier not found "FStyle"
Unit1.pas(2604,43) Error: Identifier not found "ARR_SPACE"
Unit1.pas(2607,13) Error: Identifier not found "FStyle"
Unit1.pas(2609,21) Error: Identifier not found "FActiveButt"
Unit1.pas(2609,58) Error: Identifier not found "FStaticButton"
Unit1.pas(2612,27) Error: Identifier not found "FBodyNormal"
Unit1.pas(2614,18) Error: Identifier not found "DrawBasicBody"
Unit1.pas(2614,57) Error: Identifier not found "ARR_SPACE"
Unit1.pas(2617,14) Error: Identifier not found "DrawArrow"
Unit1.pas(2620,30) Error: Identifier not found "FTextApplyGlobalOpacity"
Unit1.pas(2623,20) Error: identifier idents no member "FFont"
Unit1.pas(2623,39) Error: identifier idents no member "FFont"
Unit1.pas(2623,58) Error: identifier idents no member "FFont"
Unit1.pas(2625,26) Error: Identifier not found "FBGRA"
Unit1.pas(2625,60) Error: Identifier not found "FGlobalOpacity"
Unit1.pas(2625,72) Error: Identifier not found "FBGRA"
Unit1.pas(2630,26) Error: Identifier not found "FBGRA"
Unit1.pas(2630,60) Error: Identifier not found "FGlobalOpacity"
Unit1.pas(2630,72) Error: Identifier not found "FBGRA"
Unit1.pas(2632,20) Error: identifier idents no member "FFont"
Unit1.pas(2632,39) Error: identifier idents no member "FFont"
Unit1.pas(2632,58) Error: identifier idents no member "FFont"
Unit1.pas(2637,23) Error: Identifier not found "ConvertToGrayScale"
Unit1.pas(2637,23) Fatal: There were 50 errors compiling module, stopping

Blue1987

  • Full Member
  • ***
  • Posts: 165
Re: changing how disabled (tbgra)button are visualized
« Reply #8 on: October 14, 2011, 02:23:03 am »
Most bgracontrols are like examples of the things you can do with BGRABitmap, if you want some new feature or addapt one to fit with your needs you can improve the code because it's LGPL.

BTW contact Dibo if you really need that state, he is the author of that component.

There is no 'visual settings' for enabled / disabled. Look, for example, the Paint code in BGRAImageButton: if Enabled then... check and draw the current state (that's modified when you move the mouse, clic, etc) else (when it is disabled) draw the disabled state.

this is the solution I am tring to implement...

Code: [Select]
type

Tbgrabutton = class(BGRAButtons.TBGRAButton)
public
  procedure Paint; override;
end;


...


implementation

procedure TBGRAButton.Paint;
var
  bodya, bodyn: TBody;
  baserect: TRect;
begin
  //inherited Paint;
  { Mouse stage }
  case FMouseStage of
    msClicked: bodya := FBodyClicked;
    msHover: bodya := FBodyHover;
    msNormal: bodya := FBodyNormal;
  end;

  { Calculating base rect }
  baserect := ClientRect;
  Inc(baserect.Left, Round(FBorderWidth / 2));
  Inc(baserect.Top, Round(FBorderWidth / 2));
  Dec(baserect.Right, Round(FBorderWidth / 2) + 1);
  Dec(baserect.Bottom, Round(FBorderWidth / 2) + 1);

  { Clearing previous paint }
  FBGRA.Fill(BGRAPixelTransparent);

  { Drawing main button }
  if (FActiveButt = bbtButton) and (not FStaticButton) then
    bodyn := bodya
  else
    bodyn := FBodyNormal;

  DrawBasicBody(bodyn, Rect(baserect.Left, baserect.Top, baserect.Right -
    ifthen(FStyle = bbtDropDown, ARR_SPACE), baserect.Bottom));

  { Drop down arrow button }
  if FStyle = bbtDropDown then
  begin
    if (FActiveButt = bbtDropDown) and (not FStaticButton) then
      bodyn := bodya
    else
      bodyn := FBodyNormal;

    DrawBasicBody(bodyn, Rect(baserect.Right - ARR_SPACE, baserect.Top,
      baserect.Right, baserect.Bottom));
    { Drawing arrow }
    DrawArrow(bodyn, baserect);
  end;

  if FTextApplyGlobalOpacity then
  begin
    { Drawing text }
    DrawText(bodyn.FFont.Color, bodyn.FFont.Style, bodyn.FFont.Name);
    { Set global opacity }
   if Enabled then FBGRA.ApplyGlobalOpacity(FGlobalOpacity) else FBGRA.ApplyGlobalOpacity(100);
end
  else
  begin
    { Set global opacity }
    if Enabled then FBGRA.ApplyGlobalOpacity(FGlobalOpacity) else FBGRA.ApplyGlobalOpacity(100);
{ Drawing text }
    DrawText(bodyn.FFont.Color, bodyn.FFont.Style, bodyn.FFont.Name);
  end;

  { Convert to gray if not enabled }
  if not Enabled then
    ConvertToGrayScale;

  { Finally drawing on canvas }
  FBGRA.Draw(Self.Canvas, 0, 0, False);
end;



but when I try to compile I get the following errors:

Code: [Select]
Unit1.pas(2543,16)
Unit1.pas(2581,20) Error: Identifier not found "FMouseStage"
Unit1.pas(2582,14) Error: Identifier not found "msClicked"
Unit1.pas(2582,14) Error: Constant Expression expected
Unit1.pas(2582,37) Error: Identifier not found "FBodyClicked"
Unit1.pas(2583,12) Error: Identifier not found "msHover"
Unit1.pas(2583,12) Error: Constant Expression expected
Unit1.pas(2583,12) Error: duplicate case label
Unit1.pas(2583,33) Error: Identifier not found "FBodyHover"
Unit1.pas(2584,13) Error: Identifier not found "msNormal"
Unit1.pas(2584,13) Error: Constant Expression expected
Unit1.pas(2584,13) Error: duplicate case label
Unit1.pas(2584,35) Error: Identifier not found "FBodyNormal"
Unit1.pas(2589,41) Error: Identifier not found "FBorderWidth"
Unit1.pas(2589,3) Error: Incompatible types: got "untyped" expected "LongInt"
Unit1.pas(2590,40) Error: Identifier not found "FBorderWidth"
Unit1.pas(2590,3) Error: Incompatible types: got "untyped" expected "LongInt"
Unit1.pas(2591,42) Error: Identifier not found "FBorderWidth"
Unit1.pas(2591,3) Error: Incompatible types: got "untyped" expected "LongInt"
Unit1.pas(2592,43) Error: Identifier not found "FBorderWidth"
Unit1.pas(2592,3) Error: Incompatible types: got "untyped" expected "LongInt"
Unit1.pas(2595,8) Error: Identifier not found "FBGRA"
Unit1.pas(2595,34) Error: Identifier not found "BGRAPixelTransparent"
Unit1.pas(2598,19) Error: Identifier not found "FActiveButt"
Unit1.pas(2598,54) Error: Identifier not found "FStaticButton"
Unit1.pas(2601,25) Error: Identifier not found "FBodyNormal"
Unit1.pas(2603,16) Error: Identifier not found "DrawBasicBody"
Unit1.pas(2604,11) Error: Identifier not found "ifthen"
Unit1.pas(2604,19) Error: Identifier not found "FStyle"
Unit1.pas(2604,43) Error: Identifier not found "ARR_SPACE"
Unit1.pas(2607,13) Error: Identifier not found "FStyle"
Unit1.pas(2609,21) Error: Identifier not found "FActiveButt"
Unit1.pas(2609,58) Error: Identifier not found "FStaticButton"
Unit1.pas(2612,27) Error: Identifier not found "FBodyNormal"
Unit1.pas(2614,18) Error: Identifier not found "DrawBasicBody"
Unit1.pas(2614,57) Error: Identifier not found "ARR_SPACE"
Unit1.pas(2617,14) Error: Identifier not found "DrawArrow"
Unit1.pas(2620,30) Error: Identifier not found "FTextApplyGlobalOpacity"
Unit1.pas(2623,20) Error: identifier idents no member "FFont"
Unit1.pas(2623,39) Error: identifier idents no member "FFont"
Unit1.pas(2623,58) Error: identifier idents no member "FFont"
Unit1.pas(2625,26) Error: Identifier not found "FBGRA"
Unit1.pas(2625,60) Error: Identifier not found "FGlobalOpacity"
Unit1.pas(2625,72) Error: Identifier not found "FBGRA"
Unit1.pas(2630,26) Error: Identifier not found "FBGRA"
Unit1.pas(2630,60) Error: Identifier not found "FGlobalOpacity"
Unit1.pas(2630,72) Error: Identifier not found "FBGRA"
Unit1.pas(2632,20) Error: identifier idents no member "FFont"
Unit1.pas(2632,39) Error: identifier idents no member "FFont"
Unit1.pas(2632,58) Error: identifier idents no member "FFont"
Unit1.pas(2637,23) Error: Identifier not found "ConvertToGrayScale"
Unit1.pas(2637,23) Fatal: There were 50 errors compiling module, stopping

up

lainz

  • Guest
Re: changing how disabled (tbgra)button are visualized
« Reply #9 on: October 14, 2011, 03:35:17 am »
ConvertToGrayScale; << override that procedure and add this line:
ABGRA.ApplyGlobalOpacity(100);

TCustomBGRAButton = class(TBGRAButton)

and change your buttons to TCustomBGRAButton in each lfm
« Last Edit: October 14, 2011, 03:42:08 am by lainz »

Blue1987

  • Full Member
  • ***
  • Posts: 165
Re: changing how disabled (tbgra)button are visualized
« Reply #10 on: October 17, 2011, 01:56:16 am »
ConvertToGrayScale; << override that procedure and add this line:
ABGRA.ApplyGlobalOpacity(100);

TCustomBGRAButton = class(TBGRAButton)

and change your buttons to TCustomBGRAButton in each lfm

now when I open the project, it tells me "impossible to find the class of the component TCustomBGRAButton" ... and does not allow me to visualize the form...


ehr.. what did I do wrong?

lainz

  • Guest
Re: changing how disabled (tbgra)button are visualized
« Reply #11 on: October 17, 2011, 03:08:07 am »
You must register the component. To be added to your BGRA Controls component tab.

Code: [Select]
type

  { TCustomBGRAButton }

  TCustomBGRAButton = class(TBGRAButton)
    private
    procedure ConvertToGrayscale(ABGRA: TBGRABitmap); override;
  end;

implementation

procedure Register;
begin
  RegisterComponents('BGRA Controls', [TCustomBGRAButton]);
end;

{ TCustomBGRAButton }

procedure TCustomBGRAButton.ConvertToGrayscale(ABGRA: TBGRABitmap);
begin
  ABGRA.ApplyGlobalOpacity(100);
  inherited ConvertToGrayscale(ABGRA);
end;

and add 'virtual' to the procedure in TBGRAButton to allow you to be overriden:

Code: [Select]
procedure ConvertToGrayScale(ABGRA: TBGRABitmap); virtual;   
That works, see image attached, custombgrabutton with alpha 100.
« Last Edit: October 17, 2011, 03:22:38 am by lainz »

Blue1987

  • Full Member
  • ***
  • Posts: 165
Re: changing how disabled (tbgra)button are visualized
« Reply #12 on: October 17, 2011, 10:13:25 am »
You must register the component. To be added to your BGRA Controls component tab.

Code: [Select]
type

  { TCustomBGRAButton }

  TCustomBGRAButton = class(TBGRAButton)
    private
    procedure ConvertToGrayscale(ABGRA: TBGRABitmap); override;
  end;

implementation

procedure Register;
begin
  RegisterComponents('BGRA Controls', [TCustomBGRAButton]);
end;

{ TCustomBGRAButton }

procedure TCustomBGRAButton.ConvertToGrayscale(ABGRA: TBGRABitmap);
begin
  ABGRA.ApplyGlobalOpacity(100);
  inherited ConvertToGrayscale(ABGRA);
end;

and add 'virtual' to the procedure in TBGRAButton to allow you to be overriden:

Code: [Select]
procedure ConvertToGrayScale(ABGRA: TBGRABitmap); virtual;   
That works, see image attached, custombgrabutton with alpha 100.


my aim was NOT to create a new component, but just overridding a procedure...

so that users who wants to edit the code just have to install codetyphon and doubleclick on the project files... and not to install other components...
... I would like to simplify the life of people who want to edit my code!

lainz

  • Guest
Re: changing how disabled (tbgra)button are visualized
« Reply #13 on: October 17, 2011, 03:30:45 pm »
ok do it in your way.

Blue1987

  • Full Member
  • ***
  • Posts: 165
Re: changing how disabled (tbgra)button are visualized
« Reply #14 on: October 17, 2011, 05:44:44 pm »
ok do it in your way.

I would like to do it :) but it tells me << Unit1.pas(2581,20) Error: Identifier not found "FMouseStage" >>

 :-[ :-[

 

TinyPortal © 2005-2018