Skip to content

Commit

Permalink
Merge pull request #124 from bgrabitmap/dev-bgracontrols
Browse files Browse the repository at this point in the history
Dev bgracontrols
  • Loading branch information
lainz authored Mar 12, 2022
2 parents 967da69 + 244d3b3 commit 90d86dd
Show file tree
Hide file tree
Showing 22 changed files with 751 additions and 35 deletions.
4 changes: 2 additions & 2 deletions bcbutton.pas
Original file line number Diff line number Diff line change
Expand Up @@ -844,7 +844,7 @@ procedure TCustomBCButton.Render(ABGRA: TBGRABitmapEx; AState: TBCButtonState);
if FTextApplyGlobalOpacity then
begin
{ Drawing text }
RenderText(r, scaledState.FontEx, actualCaption, ABGRA);
RenderText(r, scaledState.FontEx, actualCaption, ABGRA, Enabled);
RenderGlyph(r_g, g);
{ Set global opacity }
ABGRA.ApplyGlobalOpacity(FGlobalOpacity);
Expand All @@ -854,7 +854,7 @@ procedure TCustomBCButton.Render(ABGRA: TBGRABitmapEx; AState: TBCButtonState);
{ Set global opacity }
ABGRA.ApplyGlobalOpacity(FGlobalOpacity);
{ Drawing text }
RenderText(r, scaledState.FontEx, actualCaption, ABGRA);
RenderText(r, scaledState.FontEx, actualCaption, ABGRA, Enabled);
RenderGlyph(r_g, g);
end;
if g <> FGlyph then g.Free;
Expand Down
5 changes: 3 additions & 2 deletions bcbuttonfocus.pas
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,7 @@ TBCButtonFocus = class(TCustomBCButtonFocus)
{ The unique name of the control in the form. }
property Name;
{ TabStop }
property TabOrder;
property TabStop;
property ThemeManager: TBCThemeManager read FBCThemeManager write SetFBCThemeManager;
property OnPaintButton;
Expand Down Expand Up @@ -775,7 +776,7 @@ procedure TCustomBCButtonFocus.Render(ABGRA: TBGRABitmapEx; AState: TBCButtonFoc
if FTextApplyGlobalOpacity then
begin
{ Drawing text }
RenderText(r, AState.FontEx, actualCaption, ABGRA);
RenderText(r, AState.FontEx, actualCaption, ABGRA, Enabled);
RenderGlyph(r_g, g);
{ Set global opacity }
ABGRA.ApplyGlobalOpacity(FGlobalOpacity);
Expand All @@ -785,7 +786,7 @@ procedure TCustomBCButtonFocus.Render(ABGRA: TBGRABitmapEx; AState: TBCButtonFoc
{ Set global opacity }
ABGRA.ApplyGlobalOpacity(FGlobalOpacity);
{ Drawing text }
RenderText(r, AState.FontEx, actualCaption, ABGRA);
RenderText(r, AState.FontEx, actualCaption, ABGRA, Enabled);
RenderGlyph(r_g, g);
end;
if g <> FGlyph then g.Free;
Expand Down
10 changes: 3 additions & 7 deletions bcgamegrid.pas
Original file line number Diff line number Diff line change
Expand Up @@ -182,14 +182,10 @@ procedure TBCCustomGrid.Click;
(pos.y <= r.Bottom) then
begin
//DebugLn(['TControl.Click ',DbgSName(Self)]);
if Assigned(FOnClickControl) and (Action <> nil) and
(not CompareMethods(TMethod(Action.OnExecute), TMethod(FOnClickControl))) then
// the OnClick is set and differs from the Action => call the OnClick
FOnClickControl(Self, n, x, y)
else if (not (csDesigning in ComponentState)) and (ActionLink <> nil) then
ActionLink.Execute(Self)
else if Assigned(FOnClickControl) then
if Assigned(FOnClickControl) then
FOnClickControl(Self, n, x, y);
if (not (csDesigning in ComponentState)) and (ActionLink <> nil) then
ActionLink.Execute(Self)
end;

Inc(n);
Expand Down
2 changes: 1 addition & 1 deletion bclabel.pas
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ procedure TCustomBCLabel.Render;
CalculateBorderRect(FBorder,r);

RenderBackgroundAndBorder(FBGRA.ClipRect, FBackground, TBGRABitmap(FBGRA), FRounding, FBorder, FInnerMargin);
RenderText(FBGRA.ClipRect, FFontEx, Caption, TBGRABitmap(FBGRA));
RenderText(FBGRA.ClipRect, FFontEx, Caption, TBGRABitmap(FBGRA), Enabled);

{$IFDEF INDEBUG}
FRenderCount := FRenderCount +1;
Expand Down
128 changes: 128 additions & 0 deletions bcmaterialedit.pas
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
unit BCMaterialEdit;

{$mode objfpc}{$H+}

interface

uses
Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, ExtCtrls,
StdCtrls;

type

{ TBCMaterialEdit }

TBCMaterialEdit = class(TCustomPanel)
private
FAccentColor: TColor;
FDisabledColor: TColor;
Flbl: TLabel;
Fedt: TEdit;
Ffocused: boolean;
FOnChange: TNotifyEvent;
FTexto: string;
procedure ChangeEdit(Sender: TObject);
procedure EnterEdit(Sender: TObject);
procedure ExitEdit(Sender: TObject);
procedure SetTexto(AValue: string);
protected
procedure Paint; override;
public
constructor Create(AOwner: TComponent); override;
published
property Color;
property Text: string read FTexto write SetTexto;
property Edit: TEdit read Fedt;
property Title: TLabel read Flbl;
property DisabledColor: TColor read FDisabledColor write FDisabledColor;
property AccentColor: TColor read FAccentColor write FAccentColor;
property OnChange: TNotifyEvent read FOnChange write FOnChange;
end;

procedure Register;

implementation

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

{ TBCMaterialEdit }

procedure TBCMaterialEdit.EnterEdit(Sender: TObject);
begin
Ffocused := True;
Invalidate;
Flbl.Font.Color := accentColor;
end;

procedure TBCMaterialEdit.ChangeEdit(Sender: TObject);
begin
if Assigned(FOnChange) then
FOnChange(Self);
end;

procedure TBCMaterialEdit.ExitEdit(Sender: TObject);
begin
Ffocused := False;
Invalidate;
Flbl.Font.Color := DisabledColor;
end;

procedure TBCMaterialEdit.SetTexto(AValue: string);
begin
if FTexto = AValue then
Exit;
FTexto := AValue;
Flbl.Caption := FTexto;
//Fedt.TextHint := FTexto;
end;

procedure TBCMaterialEdit.Paint;
begin
inherited Paint;
Canvas.Brush.Color := Color;
Canvas.Pen.Color := Color;
Canvas.Rectangle(0, 0, Width, Height);
if (fFocused) then
begin
Canvas.Pen.Color := AccentColor;
Canvas.Line(0, Height - 2, Width, Height - 2);
Canvas.Line(0, Height - 1, Width, Height - 1);
end
else
begin
Canvas.Pen.Color := DisabledColor;
Canvas.Line(0, Height - 1, Width, Height - 1);
end;
end;

constructor TBCMaterialEdit.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
Self.BevelOuter := bvNone;
Self.Color := clWhite;
AccentColor := clHighlight;
DisabledColor := $00B8AFA8;
Flbl := TLabel.Create(Self);
Flbl.Align := alTop;
Flbl.Caption := 'Buscar';
Flbl.BorderSpacing.Around := 4;
Flbl.Font.Style := [fsBold];
Flbl.Font.Color := $00B8AFA8;
Flbl.Parent := Self;
Fedt := TEdit.Create(Self);
Fedt.Color := Color;
Fedt.Font.Color := clBlack;
Fedt.OnEnter := @EnterEdit;
Fedt.OnExit := @ExitEdit;
Fedt.OnChange:=@ChangeEdit;
Fedt.Align := alClient;
Fedt.BorderStyle := bsNone;
//Fedt.TextHint := 'Buscar';
Fedt.BorderSpacing.Around := 4;
Fedt.Parent := Self;
end;

end.
130 changes: 130 additions & 0 deletions bcmaterialfloatspinedit.pas
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
unit BCMaterialFloatSpinEdit;

{$mode objfpc}{$H+}

interface

uses
Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, ExtCtrls,
StdCtrls, Spin;

type

{ TBCMaterialFloatSpinEdit }

TBCMaterialFloatSpinEdit = class(TCustomPanel)
private
FAccentColor: TColor;
FDisabledColor: TColor;
Flbl: TLabel;
Fedt: TFloatSpinEdit;
Ffocused: boolean;
FOnChange: TNotifyEvent;
FTexto: string;
procedure ChangeEdit(Sender: TObject);
procedure EnterEdit(Sender: TObject);
procedure ExitEdit(Sender: TObject);
procedure SetTexto(AValue: string);
protected
procedure Paint; override;
public
constructor Create(AOwner: TComponent); override;
published
property Color;
property Text: string read FTexto write SetTexto;
property Edit: TFloatSpinEdit read Fedt;
property Title: TLabel read Flbl;
property DisabledColor: TColor read FDisabledColor write FDisabledColor;
property AccentColor: TColor read FAccentColor write FAccentColor;
property OnChange: TNotifyEvent read FOnChange write FOnChange;
end;

procedure Register;

implementation

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

{ TBCMaterialFloatSpinEdit }

procedure TBCMaterialFloatSpinEdit.EnterEdit(Sender: TObject);
begin
Ffocused := True;
Invalidate;
Flbl.Font.Color := AccentColor;
end;

procedure TBCMaterialFloatSpinEdit.ChangeEdit(Sender: TObject);
begin
if Assigned(FOnChange) then
FOnChange(Self);
end;

procedure TBCMaterialFloatSpinEdit.ExitEdit(Sender: TObject);
begin
Ffocused := False;
Invalidate;
Flbl.Font.Color := DisabledColor;
end;

procedure TBCMaterialFloatSpinEdit.SetTexto(AValue: string);
begin
if FTexto = AValue then
Exit;
FTexto := AValue;
Flbl.Caption := FTexto;
//Fedt.TextHint := FTexto;
end;

procedure TBCMaterialFloatSpinEdit.Paint;
begin
inherited Paint;
Canvas.Brush.Color := Color;
Canvas.Pen.Color := Color;
Canvas.Rectangle(0, 0, Width, Height);
if (fFocused) then
begin
Canvas.Pen.Color := AccentColor;
Canvas.Line(0, Height - 2, Width, Height - 2);
Canvas.Line(0, Height - 1, Width, Height - 1);
end
else
begin
Canvas.Pen.Color := DisabledColor;
Canvas.Line(0, Height - 1, Width, Height - 1);
end;
end;

constructor TBCMaterialFloatSpinEdit.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
Self.BevelOuter := bvNone;
Self.Color := clWhite;
AccentColor := clHighlight;
DisabledColor := $00B8AFA8;
Flbl := TLabel.Create(Self);
Flbl.Align := alTop;
Flbl.Caption := 'Buscar';
Flbl.BorderSpacing.Around := 4;
Flbl.Font.Style := [fsBold];
Flbl.Font.Color := $00B8AFA8;
Flbl.Parent := Self;
Fedt := TFloatSpinEdit.Create(Self);
Fedt.Color := Color;
Fedt.Font.Color := clBlack;
Fedt.OnEnter := @EnterEdit;
Fedt.OnExit := @ExitEdit;
Fedt.OnChange:=@ChangeEdit;
Fedt.Align := alClient;
Fedt.BorderStyle := bsNone;
//Fedt.TextHint := 'Buscar';
Fedt.BorderSpacing.Around := 4;
Fedt.Parent := Self;
Fedt.MinValue := 0;
Fedt.MaxValue := MaxInt;
end;

end.
Loading

0 comments on commit 90d86dd

Please sign in to comment.