Skip to content

Commit

Permalink
IDE tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
ollydev committed Aug 26, 2023
1 parent a8d7676 commit e879a8f
Show file tree
Hide file tree
Showing 16 changed files with 2,071 additions and 2,159 deletions.
Binary file added Images/icon.ico
Binary file not shown.
Binary file removed Images/simba.ico
Binary file not shown.
Binary file modified Images/simba.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Images/simba_150.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Images/simba_200.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Images/simba_300.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed Images/simba_400.png
Binary file not shown.
Binary file added Images/simba_raw.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Source/Simba.ico
Binary file not shown.
2 changes: 2 additions & 0 deletions Source/Simba.lpi
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
<UseXPManifest Value="True"/>
<XPManifest>
<DpiAware Value="True/PM_V2"/>
<TextName Value="Simba"/>
<TextDesc Value=""/>
</XPManifest>
<Icon Value="0"/>
<Resources Count="9">
Expand Down
Binary file modified Source/Simba.res
Binary file not shown.
30 changes: 21 additions & 9 deletions Source/components/simba.component_tabcontrol.pas
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ TSimbaTabControl = class(TCustomControl)
implementation

uses
simba.main, simba.mufasatypes, simba.theme;
simba.main, simba.mufasatypes, simba.theme, simba.fonthelpers, simba.ide_utils;

function TSimbaTab.GetImageIndex: TImageIndex;
begin
Expand Down Expand Up @@ -274,16 +274,25 @@ procedure TSimbaTabControl.SetOnMouseMove(Value: TMouseMoveEvent);
end;

function TSimbaTabControl.GetTabHeight: Integer;
var
FontHeight, ImageHeight: Integer;
begin
with TBitmap.Create() do
try
Canvas.Font := Self.Font;
Canvas.Font.Size := Round(Abs(GetFontData(Canvas.Font.Handle).Height) * 72 / Canvas.Font.PixelsPerInch) + 4; // Measure on larger font size - Font size can be 0
Canvas.Font.Size := Round(Abs(GetFontData(Canvas.Font.Handle).Height) * 72 / Canvas.Font.PixelsPerInch);

Result := Canvas.TextHeight('Tay');
FontHeight := Canvas.TextHeight('Tay');
finally
Free();
end;

if SimbaSettings.General.CustomImageSize.IsDefault() then
ImageHeight := ImageWidthForDPI(Canvas.Font.PixelsPerInch)
else
ImageHeight := SimbaSettings.General.CustomImageSize.Value;

Result := Max(FontHeight, ImageHeight) + Scale96ToScreen(8);
end;

procedure TSimbaTabControl.ShowControl(AControl: TControl);
Expand Down Expand Up @@ -328,6 +337,9 @@ procedure TSimbaTabControl.CallTabChanged(Data: PtrInt);

procedure TSimbaTabControl.DoSettingChanged_ImageSize(Setting: TSimbaSetting);
begin
FTabs.Height := GetTabHeight();
FTabs.OptTabHeight := FTabs.Height;

Invalidate();
end;

Expand Down Expand Up @@ -430,15 +442,15 @@ constructor TSimbaTabControl.Create(AOwner: TComponent; TabClass: TSimbaTabClass
FTabs.Images := SimbaForm.Images;
FTabs.BorderSpacing.Bottom := 5;

FTabs.OptSpaceBeforeText := 10;
FTabs.OptSpaceAfterText := 10;
FTabs.OptSpaceBeforeText := 12;
FTabs.OptSpaceAfterText := 12;
FTabs.OptSpaceBetweenIconCaption := 2;
FTabs.OptShowPlusTab := False;
FTabs.OptVarWidth := True;
FTabs.OptShowScrollMark := False;
FTabs.OptSpacer := 0;
FTabs.OptMouseDoubleClickPlus := True;
FTabs.OptActiveVisibleOnResize := False;
FTabs.OptSpaceBetweenIconCaption := 2;
FTabs.OptTabHeight := FTabs.Height;
FTabs.OptShowFlat := True;

Expand All @@ -451,6 +463,9 @@ constructor TSimbaTabControl.Create(AOwner: TComponent; TabClass: TSimbaTabClass
FTabs.ColorTabActive := SimbaTheme.ColorActive;
FTabs.ColorActiveMark := SimbaTheme.ColorActive;
FTabs.ColorCloseBgOver := clNone;

with SimbaSettings do
RegisterChangeHandler(Self, General.CustomImageSize, @DoSettingChanged_ImageSize);
end;

destructor TSimbaTabControl.Destroy;
Expand Down Expand Up @@ -482,9 +497,6 @@ function TSimbaTabControl.AddTab(Title: String): TSimbaTab;

if NeedChangeEvent and Assigned(FTabChangeEvent) then
FTabChangeEvent(Self, Result);

with SimbaSettings do
RegisterChangeHandler(Self, General.CustomImageSize, @DoSettingChanged_ImageSize);
end;

procedure TSimbaTabControl.MoveTab(AFrom, ATo: Integer);
Expand Down
4,115 changes: 2,031 additions & 2,084 deletions Source/forms/simba.main.lfm

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions Source/forms/simba.main.pas
Original file line number Diff line number Diff line change
Expand Up @@ -610,10 +610,10 @@ procedure TSimbaForm.SetDefaultDocking(IsResetting: Boolean);
end;
end;

DockMaster.ManualDockPanel(DockMaster.GetAnchorSite(SimbaScriptTabsForm), DockPanel, alClient);
DockMaster.ManualDockPanel(DockMaster.GetAnchorSite(SimbaOutputForm), DockPanel, alBottom);
DockMaster.ManualDockPanel(DockMaster.GetAnchorSite(SimbaFunctionListForm), DockPanel, alLeft);
DockMaster.ManualDockPanel(DockMaster.GetAnchorSite(SimbaFileBrowserForm), DockPanel, alRight);
DockMaster.ManualDock(DockMaster.GetAnchorSite(SimbaScriptTabsForm), DockPanel, alClient);
DockMaster.ManualDock(DockMaster.GetAnchorSite(SimbaOutputForm), DockPanel, alBottom);
DockMaster.ManualDock(DockMaster.GetAnchorSite(SimbaFunctionListForm), DockPanel, alLeft);
DockMaster.ManualDock(DockMaster.GetAnchorSite(SimbaFileBrowserForm), DockPanel, alRight);

DockMaster.MakeVisible(SimbaScriptTabsForm, False);
DockMaster.MakeVisible(SimbaOutputForm, False);
Expand Down
66 changes: 7 additions & 59 deletions Source/simba.dockinghelpers.pas
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
interface

uses
classes, sysutils, controls, menus, forms, graphics,
anchordocking, anchordockpanel;
Classes, SysUtils, Controls, Menus, Forms, Graphics, AnchorDocking;

type
TSimbaAnchorDockHeader = class(TAnchorDockHeader)
Expand All @@ -25,7 +24,7 @@ TSimbaAnchorDockHeader = class(TAnchorDockHeader)
procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
procedure MouseMove(Shift: TShiftState; X,Y: Integer); override;
procedure MouseLeave; override;
procedure MouseLeave; override;

constructor Create(AOwner: TComponent); override;
end;
Expand Down Expand Up @@ -63,7 +62,6 @@ TAnchorDockMasterHelper = class helper for TAnchorDockMaster
procedure OnFormClose(Sender: TObject; var CloseAction: TCloseAction);
public
procedure MakeDockable(Form: TCustomForm; MenuItem: TMenuItem);
procedure ManualDockPanel(SrcSite: TAnchorDockHostSite; TargetPanel: TAnchorDockPanel; Align: TAlign; TargetControl: TControl = nil);

function SaveLayout: String;
function LoadLayout(Layout: String): Boolean;
Expand All @@ -72,7 +70,7 @@ TAnchorDockMasterHelper = class helper for TAnchorDockMaster
implementation

uses
anchordockstorage, xmlpropstorage, lazconfigstorage,
XMLPropStorage, LazConfigStorage,
simba.theme, simba.fonthelpers;

procedure TSimbaAnchorDockHeader.ParentFontChanged;
Expand Down Expand Up @@ -164,6 +162,7 @@ procedure TSimbaAnchorDockHostSite.DoMenuItemClicked(Sender: TObject);

if Visible then
begin
Writeln(FNeedDefaultPosition);
if FNeedDefaultPosition then
begin
with Application.MainForm.Monitor.WorkareaRect.CenterPoint do
Expand Down Expand Up @@ -243,55 +242,6 @@ procedure TAnchorDockMasterHelper.MakeDockable(Form: TCustomForm; MenuItem: TMen
end;
end;

procedure TAnchorDockMasterHelper.ManualDockPanel(SrcSite: TAnchorDockHostSite; TargetPanel: TAnchorDockPanel; Align: TAlign; TargetControl: TControl);
var
Site: TSimbaAnchorDockHostSite;
aManager: TAnchorDockManager;
DockObject: TDragDockObject;
begin
{$IFDEF VerboseAnchorDocking}
debugln(['TAnchorDockMaster.ManualDock SrcSite=',DbgSName(SrcSite),' TargetPanel=',DbgSName(TargetPanel),' Align=',dbgs(Align),' TargetControl=',DbgSName(TargetControl)]);
{$ENDIF}
if SrcSite.IsParentOf(TargetPanel) then
raise Exception.Create('TAnchorDockMaster.ManualDock SrcSite.IsParentOf(TargetSite)');
if TargetPanel.IsParentOf(SrcSite) then
raise Exception.Create('TAnchorDockMaster.ManualDock TargetSite.IsParentOf(SrcSite)');


aManager:=TAnchorDockManager(TargetPanel.DockManager);
Site:=aManager.GetChildSite as TSimbaAnchorDockHostSite;
if Site=nil then begin
// dock as first site into AnchorDockPanel
{$IFDEF VerboseAnchorDocking}
debugln(['TAnchorDockMaster.ManualDock dock as first site into AnchorDockPanel: SrcSite=',DbgSName(SrcSite),' TargetPanel=',DbgSName(TargetPanel),' Align=',dbgs(Align)]);
{$ENDIF}
BeginUpdate;
try
DockObject := TDragDockObject.Create(SrcSite);
try
DockObject.DropAlign:=alClient;
DockObject.DockRect:=SrcSite.BoundsRect;
DockObject.Control.Dock(TargetPanel, SrcSite.BoundsRect);
aManager.InsertControl(DockObject);
finally
DockObject.Free;
end;
finally
EndUpdate;
end;
Exit;
end;

if AutoFreedIfControlIsRemoved(Site,SrcSite) then
raise Exception.Create('TAnchorDockMaster.ManualDock TargetPanel depends on SrcSite');
BeginUpdate;
try
Site.ExecuteDock(SrcSite,TargetControl,Align);
finally
EndUpdate;
end;
end;

function TAnchorDockMasterHelper.SaveLayout: String;
var
Config: TXMLConfigStorage;
Expand All @@ -305,10 +255,9 @@ function TAnchorDockMasterHelper.SaveLayout: String;

try
RestoreLayouts.Clear();
for I := 0 to Screen.CustomFormCount-1 do
if (Screen.CustomForms[I].HostDockSite is TSimbaAnchorDockHostSite) then
if TSimbaAnchorDockHostSite(Screen.CustomForms[I].HostDockSite).Floating then
RestoreLayouts.Add(CreateRestoreLayout(Screen.CustomForms[I].HostDockSite), True);
for I := 0 to Screen.CustomFormCount - 1 do
if Screen.CustomForms[I].Showing and (Screen.CustomForms[I].HostDockSite is TSimbaAnchorDockHostSite) and TSimbaAnchorDockHostSite(Screen.CustomForms[I].HostDockSite).Floating then
RestoreLayouts.Add(CreateRestoreLayout(Screen.CustomForms[I].HostDockSite), True);

SaveLayoutToConfig(Config);

Expand Down Expand Up @@ -388,7 +337,6 @@ function TAnchorDockMasterHelper.LoadLayout(Layout: String): Boolean;

Stream := TStringStream.Create(Layout);
Config := TXMLConfigStorage.Create(Stream);

try
LoadRestoredBounds(Config);

Expand Down
9 changes: 6 additions & 3 deletions Source/simba.ide_utils.pas
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,15 @@ function ImageWidthForDPI(DPI: Integer): Integer;
end;

if (DPI <= 96) then
Result := 16 // no scaling
Result := 16 // 100%, no scaling
else
if (DPI <= 120) then
Result := 16 // 125%
else
if (DPI <= 168) then
Result := 24 // 125%-175% (120-168 DPI): 150% scaling
Result := 24 // 150%
else
Result := 32; // 200, 300, 400, ...
Result := 32; // 200% +
end;

procedure MenuItemHeight(Item: TMenuItem; Canvas: TCanvas; var Height: Integer);
Expand Down

0 comments on commit e879a8f

Please sign in to comment.