Skip to content

Commit

Permalink
Improve customization of scrollbar & toolbar.
Browse files Browse the repository at this point in the history
  • Loading branch information
ollydev committed Jun 7, 2023
1 parent 751c4e0 commit e94cbd3
Show file tree
Hide file tree
Showing 21 changed files with 623 additions and 294 deletions.
6 changes: 5 additions & 1 deletion Source/Simba.lpi
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@
<PackageName Value="LCL"/>
</Item4>
</RequiredPackages>
<Units Count="171">
<Units Count="172">
<Unit0>
<Filename Value="Simba.lpr"/>
<IsPartOfProject Value="True"/>
Expand Down Expand Up @@ -1068,6 +1068,10 @@
<Filename Value="components/simba.component_button.pas"/>
<IsPartOfProject Value="True"/>
</Unit170>
<Unit171>
<Filename Value="components/simba.component_scrollbar.pas"/>
<IsPartOfProject Value="True"/>
</Unit171>
</Units>
</ProjectOptions>
<CompilerOptions>
Expand Down
3 changes: 2 additions & 1 deletion Source/components/simba.component_menubar.pas
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ procedure TSimbaMainMenuBar.Paint;
Style.Alignment := taCenter;
Style.Layout := tlCenter;

Canvas.Font.Color := SimbaTheme.ColorFont;
Canvas.Brush.Color := SimbaTheme.ColorFrame;
Canvas.FillRect(ClientRect);

Expand Down Expand Up @@ -164,8 +165,8 @@ constructor TSimbaMainMenuBar.Create(AOwner: TComponent);
begin
inherited Create(AOwner);

ParentFont := True;
ControlStyle := ControlStyle + [csOpaque];
Font.Color := SimbaTheme.ColorFont;

CalculateSizes();
end;
Expand Down
48 changes: 48 additions & 0 deletions Source/components/simba.component_scrollbar.pas
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
unit simba.component_scrollbar;

{$i simba.inc}

interface

uses
Classes, SysUtils,
ATScrollBar, simba.settings;

type
TSimbaScrollBar = class(TATScrollBar)
protected
procedure DoSettingChange_ScrollBarSize(Setting: TSimbaSetting);
procedure DoSettingChange_ScrollBarArrowSize(Setting: TSimbaSetting);
public
constructor Create(AOwner: TComponent); override;
end;

implementation

uses
simba.mufasatypes;

procedure TSimbaScrollBar.DoSettingChange_ScrollBarSize(Setting: TSimbaSetting);
begin
Theme^.InitialSize := Scale96ToScreen(Setting.Value);

Update();
end;

procedure TSimbaScrollBar.DoSettingChange_ScrollBarArrowSize(Setting: TSimbaSetting);
begin
Theme^.ArrowSize := Setting.Value;

Update();
end;

constructor TSimbaScrollBar.Create(AOwner: TComponent);
begin
inherited Create(AOwner);

SimbaSettings.RegisterChangeHandler(Self, SimbaSettings.General.ScrollBarSize, @DoSettingChange_ScrollBarSize, True);
SimbaSettings.RegisterChangeHandler(Self, SimbaSettings.General.ScrollBarArrowSize, @DoSettingChange_ScrollBarArrowSize, True);
end;

end.

10 changes: 5 additions & 5 deletions Source/components/simba.component_synedit.pas
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ interface
Classes, SysUtils, Controls, Forms, StdCtrls, Graphics,
SynEdit, SynEditTypes, SynEditFoldedView, SynEditTextBuffer, SynEditMarkupSelection,
LazSynEditText,
ATScrollBar;
simba.component_scrollbar;

type
TSimbaSynEdit = class(TSynEdit)
protected
FScrollbarVert: TATScrollbar;
FScrollbarHorz: TATScrollbar;
FScrollbarVert: TSimbaScrollBar;
FScrollbarHorz: TSimbaScrollBar;

procedure DoVertScrollBarChange(Sender: TObject);
procedure DoHorzScrollBarChange(Sender: TObject);
Expand Down Expand Up @@ -114,11 +114,11 @@ constructor TSimbaSynEdit.Create(AOwner: TComponent);
begin
inherited Create(AOwner);

FScrollbarVert := TATScrollbar.Create(Self);
FScrollbarVert := TSimbaScrollBar.Create(Self);
FScrollbarVert.Kind := sbVertical;
FScrollbarVert.OnChange := @DoVertScrollBarChange;

FScrollbarHorz := TATScrollbar.Create(Self);
FScrollbarHorz := TSimbaScrollBar.Create(Self);
FScrollbarHorz.Kind := sbHorizontal;
FScrollbarHorz.OnChange := @DoHorzScrollBarChange;

Expand Down
52 changes: 20 additions & 32 deletions Source/components/simba.component_treeview.pas
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,16 @@ interface

uses
Classes, SysUtils, Controls, Forms, Graphics, StdCtrls, ComCtrls, LMessages, LCLType, ImgList,
ATScrollBar,
simba.component_edit, simba.component_treeviewhint;
simba.component_edit, simba.component_treeviewhint, simba.component_scrollbar;

type
TSimbaTreeView = class;

TSimbaInternalTreeView = class(TTreeView)
protected
FLoading: Boolean;
FScrollbarVert: TATScrollbar;
FScrollbarHorz: TATScrollbar;
FScrollbarVert: TSimbaScrollBar;
FScrollbarHorz: TSimbaScrollBar;

procedure UpdateScrollBars;
procedure DoSelectionChanged; override;
Expand All @@ -49,12 +48,14 @@ TSimbaTreeView = class(TCustomControl)
FFilterEdit: TSimbaEdit;
FHint: TSimbaTreeViewHint;
FTree: TSimbaInternalTreeView;
FScrollbarVert: TATScrollbar;
FScrollbarHorz: TATScrollbar;
FScrollbarVert: TSimbaScrollBar;
FScrollbarHorz: TSimbaScrollBar;
FOnGetNodeHint: TNodeHintEvent;
FNodeClass: TTreeNodeClass;
FOnAfterFilter: TNotifyEvent;

procedure FontChanged(Sender: TObject); override;

procedure UpdateFilter;

function GetImages: TCustomImageList;
Expand Down Expand Up @@ -128,19 +129,17 @@ constructor TSimbaTreeView.Create(AOwner: TComponent; NodeClass: TTreeNodeClass)

FNodeClass := NodeClass;

FScrollbarVert := TATScrollbar.Create(Self);
FScrollbarVert := TSimbaScrollBar.Create(Self);
FScrollbarVert.Parent := Self;
FScrollbarVert.Kind := sbVertical;
FScrollbarVert.Align := alRight;
FScrollbarVert.Width := ATScrollbarTheme.InitialSize;
FScrollbarVert.OnChange := @ScrollVertChange;
FScrollbarVert.Visible := True;

FScrollbarHorz := TATScrollbar.Create(Self);
FScrollbarHorz := TSimbaScrollBar.Create(Self);
FScrollbarHorz.Parent := Self;
FScrollbarHorz.Kind := sbHorizontal;
FScrollbarHorz.Align := alBottom;
FScrollbarHorz.Height := ATScrollbarTheme.InitialSize;
FScrollbarHorz.IndentCorner := 100;
FScrollbarHorz.OnChange := @ScrollHorzChange;
FScrollbarHorz.Visible := True;
Expand All @@ -156,13 +155,13 @@ constructor TSimbaTreeView.Create(AOwner: TComponent; NodeClass: TTreeNodeClass)
FTree.ExpandSignType := tvestArrow;
FTree.ExpandSignColor := clWhite;
FTree.TreeLinePenStyle := psClear;
FTree.Font.Color := SimbaTheme.ColorFont;
FTree.BackgroundColor := SimbaTheme.ColorBackground;
FTree.SelectionColor := SimbaTheme.ColorActive;
FTree.OnCreateNodeClass := @DoCreateNodeClass;
FTree.OnMouseMove := @DoMouseMove;
FTree.DragMode := dmAutomatic;
FTree.TabStop := False;
FTree.BackgroundColor := SimbaTheme.ColorBackground;
FTree.SelectionColor := SimbaTheme.ColorActive;
FTree.Font.Color := SimbaTheme.ColorFont;

FHint := TSimbaTreeViewHint.Create(FTree);

Expand All @@ -177,25 +176,6 @@ constructor TSimbaTreeView.Create(AOwner: TComponent; NodeClass: TTreeNodeClass)
FFilterEdit.Font.Color := SimbaTheme.ColorFont;
FFilterEdit.HintTextColor := clLtGray;
FFilterEdit.HintText := '(search)';

with ATScrollbarTheme do
begin
InitialSize := Scale96ToScreen(16);
ThumbMinSize := Scale96ToScreen(24);
ThumbRoundedRect := False;
DirectJumpOnClickPageUpDown := True;

ColorCorner := SimbaTheme.ColorFrame;
ColorBG := SimbaTheme.ColorScrollBarInActive;
ColorThumbBorder := SimbaTheme.ColorScrollBarActive;
ColorThumbFill := SimbaTheme.ColorScrollBarActive;
ColorThumbFillOver := SimbaTheme.ColorScrollBarActive;
ColorThumbFillPressed := SimbaTheme.ColorScrollBarActive;
ColorThumbDecor := SimbaTheme.ColorScrollBarActive;
ColorArrowFill := SimbaTheme.ColorScrollBarActive;
ColorArrowBorder := SimbaTheme.ColorScrollBarActive;
ColorArrowSign := SimbaTheme.ColorLine;
end;
end;

procedure TSimbaTreeView.FullCollapse;
Expand Down Expand Up @@ -294,6 +274,14 @@ function TSimbaTreeView.GetTopLevelCount: Integer;
Result := FTree.Items.TopLvlCount;
end;

procedure TSimbaTreeView.FontChanged(Sender: TObject);
begin
inherited FontChanged(Sender);

FTree.Font := Self.Font;
FTree.Font.Color := SimbaTheme.ColorFont;
end;

procedure TSimbaTreeView.UpdateFilter;
var
Node, NodeParent: TTreeNode;
Expand Down
24 changes: 0 additions & 24 deletions Source/editor/simba.editor.pas
Original file line number Diff line number Diff line change
Expand Up @@ -321,29 +321,6 @@ procedure TSimbaEditor.SimbaSettingChanged(Setting: TSimbaSetting);
else
Options := Options - [eoTrimTrailingSpaces, eoScrollPastEol];
end;

'General.MacOSKeystrokes':
begin
if Setting.Value then
begin
for I := 0 to Keystrokes.Count - 1 do
if (ssCtrl in Keystrokes[i].Shift) then
Keystrokes[I].Shift := Keystrokes[I].Shift - [ssCtrl] + [ssMeta];

for I := 0 to MouseActions.Count - 1 do
if (ssCtrl in MouseActions[i].Shift) then
MouseActions[I].Shift := MouseActions[I].Shift - [ssCtrl] + [ssMeta];
end else
begin
for I := 0 to Keystrokes.Count - 1 do
if (ssMeta in Keystrokes[i].Shift) then
Keystrokes[I].Shift := Keystrokes[I].Shift - [ssMeta] + [ssCtrl];

for I := 0 to MouseActions.Count - 1 do
if (ssMeta in MouseActions[i].Shift) then
MouseActions[I].Shift := MouseActions[I].Shift - [ssMeta] + [ssCtrl];
end;
end;
end;
end;

Expand Down Expand Up @@ -508,7 +485,6 @@ constructor TSimbaEditor.Create(AOwner: TComponent);
SimbaSettingChanged(SimbaSettings.Editor.AntiAliased);
SimbaSettingChanged(SimbaSettings.Editor.FontSize);
SimbaSettingChanged(SimbaSettings.Editor.FontName);
SimbaSettingChanged(SimbaSettings.General.MacOSKeystrokes);

SimbaSettings.RegisterChangeHandler(@SimbaSettingChanged);

Expand Down
2 changes: 2 additions & 0 deletions Source/forms/simba.functionlistform.pas
Original file line number Diff line number Diff line change
Expand Up @@ -677,6 +677,8 @@ destructor TSimbaFunctionListForm.Destroy;

FCodeinsight.Free();

FSavedStates.Free();

inherited Destroy();
end;

Expand Down
4 changes: 2 additions & 2 deletions Source/forms/simba.main.lfm
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
object SimbaForm: TSimbaForm
Left = 3939
Left = 3579
Height = 578
Top = 740
Top = 702
Width = 910
Caption = 'Simba'
ClientHeight = 578
Expand Down
Loading

0 comments on commit e94cbd3

Please sign in to comment.