From f8f51fb6363e80cdc881a56e3ece978fbd9103b1 Mon Sep 17 00:00:00 2001 From: Olly Date: Sat, 10 Jun 2023 21:00:49 +0100 Subject: [PATCH] Tweaks --- .../codetools/simba.ide_codetools_insight.pas | 49 +++++------- .../codetools/simba.ide_codetools_parser.pas | 8 +- Source/components/simba.component_button.pas | 76 +++++++++++++------ Source/components/simba.component_edit.pas | 19 ++++- .../components/simba.component_treeview.pas | 14 +--- Source/editor/simba.editor_autocomplete.pas | 11 +-- Source/forms/simba.main.pas | 8 +- Source/forms/simba.scripttabsform.lfm | 41 +++++----- Source/forms/simba.scripttabsform.pas | 28 ++++--- Source/simba.bitmap.pas | 51 ++++++++----- Source/simba.bitmap_utils.pas | 2 +- Source/simba.dockinghelpers.pas | 9 ++- Source/simba.scripttab.pas | 2 +- 13 files changed, 184 insertions(+), 134 deletions(-) diff --git a/Source/codetools/simba.ide_codetools_insight.pas b/Source/codetools/simba.ide_codetools_insight.pas index 8ba69967c..40bbf530c 100644 --- a/Source/codetools/simba.ide_codetools_insight.pas +++ b/Source/codetools/simba.ide_codetools_insight.pas @@ -23,7 +23,10 @@ interface type {$SCOPEDENUMS ON} - EParseExpressionFlag = (WantVarType, WantMethodResult); + EParseExpressionFlag = ( + WantVarType, // if found decl is a variable, return the variables type + WantMethodResult // if found decl is a function, return the result type + ); EParseExpressionFlags = set of EParseExpressionFlag; {$SCOPEDENUMS OFF} @@ -350,6 +353,7 @@ function TCodeinsight.GetMembersOfType(Decl: TDeclaration): TDeclarationArray; begin Result := nil; + Decl := EnsureTypeDeclaration(Decl); if (Decl is TDeclaration_TypeEnum) then begin Result := TDeclaration_TypeEnum(Decl).Elements; @@ -427,36 +431,15 @@ function TCodeinsight.ParseExpression(Expr: TExpressionItems; Flags: EParseExpre if Decl.IsName(Expr.Text) then begin if (Decl is TDeclaration_Var) and (TDeclaration_Var(Decl).VarType <> nil) then - begin - Result := EnsureTypeDeclaration(TDeclaration_Var(Decl).VarType); - Exit; - end; - - if (Decl is TDeclaration_Method) then - begin - if Expr.IsLastItem then - begin - case (EParseExpressionFlag.WantMethodResult in Flags) of - True: - if (TDeclaration_Method(Decl).ResultType <> nil) then - begin - Result := EnsureTypeDeclaration(TDeclaration_Method(Decl).ResultType); - Exit; - end; - False: - begin - Result := Decl; - Exit; - end; - end; - end; - - if (TDeclaration_Method(Decl).ResultType <> nil) then - begin - Result := EnsureTypeDeclaration(TDeclaration_Method(Decl).ResultType); - Exit; - end; - end; + Result := EnsureTypeDeclaration(TDeclaration_Var(Decl).VarType) + else + if Expr.IsLastItem then + Result := Decl + else + if (Decl is TDeclaration_Method) and Assigned(TDeclaration_Method(Decl).ResultType) then + Result := EnsureTypeDeclaration(TDeclaration_Method(Decl).ResultType); + + Exit; end; end; @@ -527,6 +510,10 @@ function TCodeinsight.ParseExpression(Expr: TExpressionItems; Flags: EParseExpre end; Result := Decl; + + if (EParseExpressionFlag.WantMethodResult in Flags) then + if (Result is TDeclaration_Method) and Assigned(TDeclaration_Method(Result).ResultType) then + Result := EnsureTypeDeclaration(TDeclaration_Method(Result).ResultType); end; function TCodeinsight.ParseExpression(Expr: String; Flags: EParseExpressionFlags): TDeclaration; diff --git a/Source/codetools/simba.ide_codetools_parser.pas b/Source/codetools/simba.ide_codetools_parser.pas index fe4442f6f..8268819eb 100644 --- a/Source/codetools/simba.ide_codetools_parser.pas +++ b/Source/codetools/simba.ide_codetools_parser.pas @@ -1184,7 +1184,7 @@ procedure TCodeParser.FindLocals; procedure CheckMethod(Decl: TDeclaration); var - SelfDecl, ResultDecl: TDeclaration; + SelfDecl, ResultDecl, ParamListDecl: TDeclaration; begin if (Decl = nil) then Exit; @@ -1212,8 +1212,10 @@ procedure TCodeParser.FindLocals; FLocals.Extend(Decl.Items.GetByClass(TDeclaration_Const, True)); FLocals.Extend(Decl.Items.GetByClass(TDeclaration_Type)); FLocals.Extend(Decl.Items.GetByClass(TDeclaration_EnumElement)); - if (FItems.GetByClassEx(TDeclaration_ParamList) <> nil) then - FLocals.Extend(FItems.GetByClassEx(TDeclaration_ParamList).Items.GetByClass(TDeclaration_Parameter, False, True)); + + ParamListDecl := FItems.GetByClassEx(TDeclaration_ParamList, True, True); + if Assigned(ParamListDecl) then + FLocals.Extend(ParamListDecl.Items.GetByClass(TDeclaration_Parameter, False, True)); Decl := Decl.GetOwnerByClass(TDeclaration_Method); end; diff --git a/Source/components/simba.component_button.pas b/Source/components/simba.component_button.pas index 7ebd1a396..a2d34d39c 100644 --- a/Source/components/simba.component_button.pas +++ b/Source/components/simba.component_button.pas @@ -19,57 +19,85 @@ TSimbaButton = class(TSpeedButton) procedure PaintBackground(var PaintRect: TRect); override; public VertPadding: Integer; - Olly: Boolean; - constructor Create(AOwner: TComponent; LCLGlyphName: String); overload; + constructor Create(AOwner: TComponent); override; + + procedure SetCloseGlyph; + procedure SetClearFilterGlyph; end; TSimbaToggleButton = class(TSimbaButton) + public + constructor Create(AOwner: TComponent); override; + end; + + TSimbaTransparentButton = class(TSimbaButton) + protected + procedure PaintBackground(var PaintRect: TRect); override; + public constructor Create(AOwner: TComponent); override; end; implementation uses - simba.theme; + simba.theme, + ATCanvasPrimitives; -procedure TSimbaButton.CalculatePreferredSize(var PreferredWidth, PreferredHeight: integer; WithThemeSpace: Boolean); +procedure TSimbaTransparentButton.PaintBackground(var PaintRect: TRect); begin - inherited CalculatePreferredSize(PreferredWidth, PreferredHeight, WithThemeSpace); + if Down or MouseInClient then + Canvas.Brush.Color := SimbaTheme.ColorActive + else + Canvas.Brush.Color := Color; - PreferredWidth += VertPadding*2; + Canvas.FillRect(PaintRect); + if Down or MouseInClient then + CanvasPaintRoundedCorners(Canvas, PaintRect, [acckLeftTop, acckRightTop, acckLeftBottom, acckRightBottom], Color, Canvas.Brush.Color, Canvas.Brush.Color); end; -procedure TSimbaButton.PaintBackground(var PaintRect: TRect); +constructor TSimbaTransparentButton.Create(AOwner: TComponent); begin - if Olly then - begin - if Down or MouseInClient then - Canvas.Brush.Color := SimbaTheme.ColorActive - else - Canvas.Brush.Color := SimbaTheme.ColorBackground; + inherited Create(AOwner); - Canvas.FillRect(PaintRect); + ParentColor := True; +end; - Exit; - end; +procedure TSimbaButton.CalculatePreferredSize(var PreferredWidth, PreferredHeight: integer; WithThemeSpace: Boolean); +begin + inherited CalculatePreferredSize(PreferredWidth, PreferredHeight, WithThemeSpace); - Canvas.FillRect(PaintRect); - Canvas.Pen.Color := SimbaTheme.ColorFrame; + PreferredWidth += VertPadding * 2; +end; + +procedure TSimbaButton.PaintBackground(var PaintRect: TRect); +begin if Down or MouseInClient then Canvas.Brush.Color := SimbaTheme.ColorActive else Canvas.Brush.Color := SimbaTheme.ColorScrollBarActive; - Canvas.Brush.Color := SimbaTheme.ColorBackground; - Canvas.RoundRect(PaintRect, Width div 5, Width div 5); + Canvas.FillRect(PaintRect); + CanvasPaintRoundedCorners(Canvas, PaintRect, [acckLeftTop, acckRightTop, acckLeftBottom, acckRightBottom], SimbaTheme.ColorFrame, Canvas.Brush.Color, Canvas.Brush.Color); end; -constructor TSimbaButton.Create(AOwner: TComponent; LCLGlyphName: String); +constructor TSimbaButton.Create(AOwner: TComponent); begin - inherited Create(Owner); + inherited Create(AOwner); + + AutoSize := True; + + VertPadding := 5; +end; - ButtonGlyph.LCLGlyphName := LCLGlyphName; +procedure TSimbaButton.SetCloseGlyph; +begin + ButtonGlyph.LCLGlyphName := 'btn_cancel'; +end; + +procedure TSimbaButton.SetClearFilterGlyph; +begin + ButtonGlyph.LCLGlyphName := 'btnfiltercancel'; end; constructor TSimbaToggleButton.Create(AOwner: TComponent); @@ -77,7 +105,7 @@ constructor TSimbaToggleButton.Create(AOwner: TComponent); inherited Create(AOwner); AllowAllUp := True; - GroupIndex := 1+AOwner.ComponentCount; + GroupIndex := 1 + AOwner.ComponentCount; Font.Color := SimbaTheme.ColorFont; end; diff --git a/Source/components/simba.component_edit.pas b/Source/components/simba.component_edit.pas index fb4d0ff6f..d99ace1f7 100644 --- a/Source/components/simba.component_edit.pas +++ b/Source/components/simba.component_edit.pas @@ -76,6 +76,8 @@ TSimbaEdit = class(TCustomControl) procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override; procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override; + procedure ParentFontChanged; override; + procedure FontChanged(Sender: TObject); override; procedure TextChanged; override; procedure Paint; override; @@ -368,6 +370,19 @@ procedure TSimbaEdit.MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Int FSelectingEndX := CharIndexAtXY(X, Y); end; +procedure TSimbaEdit.ParentFontChanged; +begin + inherited ParentFontChanged; + + if Assigned(Parent) then + begin + Font.BeginUpdate(); + Font := Parent.Font; + Font.Color := SimbaTheme.ColorFont; + Font.EndUpdate(); + end; +end; + procedure TSimbaEdit.SetCaretPos(Pos: Integer); begin if (Pos < 0) then @@ -387,8 +402,6 @@ procedure TSimbaEdit.FontChanged(Sender: TObject); begin inherited FontChanged(Sender); - Font.Color := SimbaTheme.ColorFont; - NewHeight := CalculateHeight(); Constraints.MinHeight := NewHeight; @@ -644,8 +657,6 @@ constructor TSimbaEdit.Create(AOwner: TComponent); HintTextStyle := [fsItalic]; HintTextColor := cl3DDkShadow; - Font.Color := SimbaTheme.ColorFont; - Color := SimbaTheme.ColorBackground; ColorSelection := SimbaTheme.ColorActive; ColorBorder := SimbaTheme.ColorFrame; diff --git a/Source/components/simba.component_treeview.pas b/Source/components/simba.component_treeview.pas index e54596118..81071491a 100644 --- a/Source/components/simba.component_treeview.pas +++ b/Source/components/simba.component_treeview.pas @@ -88,7 +88,6 @@ TSimbaTreeView = class(TCustomControl) procedure ScrollHorzChange(Sender: TObject); procedure ScrollVertChange(Sender: TObject); - procedure DoScrollBarVertResize(Sender: TObject); public constructor Create(AOwner: TComponent; NodeClass: TTreeNodeClass = nil); reintroduce; @@ -123,7 +122,7 @@ TSimbaTreeView = class(TCustomControl) implementation uses - Math, EditBtn, simba.theme; + Math, simba.theme; constructor TSimbaTreeView.Create(AOwner: TComponent; NodeClass: TTreeNodeClass); var @@ -145,7 +144,6 @@ constructor TSimbaTreeView.Create(AOwner: TComponent; NodeClass: TTreeNodeClass) FScrollbarVert.Align := alRight; FScrollbarVert.OnChange := @ScrollVertChange; FScrollbarVert.Visible := True; - FScrollbarVert.OnResize := @DoScrollBarVertResize; FScrollbarHorz := TSimbaScrollBar.Create(Self); FScrollbarHorz.Parent := test; @@ -196,15 +194,14 @@ constructor TSimbaTreeView.Create(AOwner: TComponent; NodeClass: TTreeNodeClass) FFilterEdit.HintTextColor := clLtGray; FFilterEdit.HintText := '(search)'; - FFilterClearButton := TSimbaButton.Create(Self, ResBtnListFilter); + FFilterClearButton := TSimbaTransparentButton.Create(Self); FFilterClearButton.Parent := FFilterPanel; FFilterClearButton.Align := alRight; FFilterClearButton.AutoSize := True; - FFilterClearButton.VertPadding := 4; - FFilterClearButton.Olly := True; FFilterClearButton.OnClick := @DoClearFilterClick; FFilterClearButton.Hint := 'Clear Filter'; FFilterClearButton.ShowHint := True; + FFilterClearButton.SetClearFilterGlyph(); end; procedure TSimbaTreeView.FullCollapse; @@ -456,11 +453,6 @@ procedure TSimbaTreeView.ScrollVertChange(Sender: TObject); FTree.ScrolledTop := FScrollbarVert.Position; end; -procedure TSimbaTreeView.DoScrollBarVertResize(Sender: TObject); -begin - FFilterClearButton.BorderSpacing.Right := FScrollbarVert.Width; -end; - procedure TSimbaTreeView.ScrollHorzChange(Sender: TObject); begin FTree.ScrolledLeft := FScrollbarHorz.Position; diff --git a/Source/editor/simba.editor_autocomplete.pas b/Source/editor/simba.editor_autocomplete.pas index e605fb941..f3f75f092 100644 --- a/Source/editor/simba.editor_autocomplete.pas +++ b/Source/editor/simba.editor_autocomplete.pas @@ -12,9 +12,10 @@ interface uses - Classes, SysUtils, Graphics, StdCtrls, Controls, Forms, LCLType, Types, ATScrollBar, + Classes, SysUtils, Graphics, StdCtrls, Controls, Forms, LCLType, Types, SynEdit, SynEditTypes, SynCompletion, SynEditKeyCmds, SynEditHighlighter, - simba.mufasatypes, simba.ide_codetools_parser, simba.ide_codetools_insight; + simba.mufasatypes, simba.ide_codetools_parser, simba.ide_codetools_insight, + simba.component_scrollbar; type TSimbaAutoCompleteSizeDrag = class(TSynBaseCompletionFormSizeDrag) @@ -24,7 +25,7 @@ TSimbaAutoCompleteSizeDrag = class(TSynBaseCompletionFormSizeDrag) TSimbaAutoComplete = class; TSimbaAutoComplete_Form = class(TSynCompletionForm) protected - RealScroll: TATScrollbar; + RealScroll: TSimbaScrollBar; procedure DoPaintSizeDrag(Sender: TObject); procedure DoScrollChange(Sender: TObject); @@ -286,12 +287,12 @@ constructor TSimbaAutoComplete_Form.Create(AOwner: TComponent); Scroll.Width := 0; - RealScroll := TATScrollbar.Create(Self); + RealScroll := TSimbaScrollBar.Create(Self); RealScroll.Parent := Self; RealScroll.Kind := sbVertical; RealScroll.OnEnter := @ScrollGetFocus; RealScroll.OnChange := @DoScrollChange; - RealScroll.Anchors := [akTop,akRight, akBottom]; + RealScroll.Anchors := [akTop, akRight, akBottom]; RealScroll.AnchorSide[akTop].Side := asrTop; RealScroll.AnchorSide[akTop].Control := self; RealScroll.AnchorSide[akRight].Side := asrBottom; diff --git a/Source/forms/simba.main.pas b/Source/forms/simba.main.pas index 9b9035adb..f4736dad3 100644 --- a/Source/forms/simba.main.pas +++ b/Source/forms/simba.main.pas @@ -635,6 +635,11 @@ procedure TSimbaForm.Setup(Data: PtrInt); SimbaSettingChanged(SimbaSettings.General.LockLayout); SimbaSettingChanged(SimbaSettings.General.TrayIconVisible); SimbaSettingChanged(SimbaSettings.General.ConsoleVisible); + + // Finally, give the editor focus as default. + if Assigned(SimbaScriptTabsForm.CurrentEditor) then + if SimbaScriptTabsForm.CurrentEditor.CanSetFocus() then + SimbaScriptTabsForm.CurrentEditor.SetFocus(); end; procedure TSimbaForm.FormCreate(Sender: TObject); @@ -684,7 +689,8 @@ procedure TSimbaForm.FormShortCut(var Msg: TLMKey; var Handled: Boolean); begin Handled := MainMenuFile.IsShortcut(Msg) or MainMenuView.IsShortcut(Msg) or MainMenuEdit.IsShortcut(Msg) or MainMenuScript.IsShortcut(Msg) or - MainMenuTools.IsShortcut(Msg) or MainMenuHelp.IsShortcut(Msg); + MainMenuTools.IsShortcut(Msg) or MainMenuHelp.IsShortcut(Msg) or + (KeyDataToShiftState(Msg.KeyData) = [ssAlt]); // Suppress windows freaking out end; procedure TSimbaForm.MenuItemDocumentationClick(Sender: TObject); diff --git a/Source/forms/simba.scripttabsform.lfm b/Source/forms/simba.scripttabsform.lfm index c042795fd..37b1ee6ad 100644 --- a/Source/forms/simba.scripttabsform.lfm +++ b/Source/forms/simba.scripttabsform.lfm @@ -1,7 +1,7 @@ object SimbaScriptTabsForm: TSimbaScriptTabsForm - Left = 3840 + Left = 2780 Height = 206 - Top = 25 + Top = 1080 Width = 816 AllowDropFiles = True Caption = 'Editor' @@ -17,52 +17,47 @@ object SimbaScriptTabsForm: TSimbaScriptTabsForm LCLVersion = '2.2.4.0' object FindPanel: TPanel Left = 0 - Height = 34 - Top = 172 + Height = 0 + Top = 206 Width = 816 Align = alBottom AutoSize = True BevelOuter = bvNone - ClientHeight = 34 + ClientHeight = 0 ClientWidth = 816 ParentColor = False TabOrder = 0 Visible = False OnResize = FindPanelResize object FindEditPanel: TPanel + AnchorSideLeft.Control = FindPanel + AnchorSideTop.Control = FindPanel + AnchorSideBottom.Control = FindPanel + AnchorSideBottom.Side = asrBottom Left = 0 - Height = 34 + Height = 0 Top = 0 Width = 0 - Align = alLeft + Anchors = [akTop, akLeft, akBottom] AutoSize = True BevelOuter = bvNone TabOrder = 0 end object FindButtonPanel: TPanel + AnchorSideLeft.Control = FindEditPanel + AnchorSideLeft.Side = asrBottom + AnchorSideTop.Control = FindPanel + AnchorSideBottom.Control = FindPanel + AnchorSideBottom.Side = asrBottom Left = 0 - Height = 34 + Height = 0 Top = 0 Width = 0 - Align = alLeft + Anchors = [akTop, akLeft, akBottom] AutoSize = True BevelOuter = bvNone TabOrder = 1 end - object FindButtonClose: TSpeedButton - Left = 779 - Height = 24 - Top = 5 - Width = 27 - Align = alRight - BorderSpacing.Top = 5 - BorderSpacing.Right = 10 - BorderSpacing.Bottom = 5 - Caption = '🗙' - Flat = True - Spacing = 0 - OnClick = FindButtonClick - end end object TabPopupMenu: TPopupMenu Images = SimbaForm.Images diff --git a/Source/forms/simba.scripttabsform.pas b/Source/forms/simba.scripttabsform.pas index cb60e96a4..1606ed8b9 100644 --- a/Source/forms/simba.scripttabsform.pas +++ b/Source/forms/simba.scripttabsform.pas @@ -21,7 +21,6 @@ TSimbaScriptTabsForm = class(TForm) MenuItemCloseTab: TMenuItem; MenuItemCloseOtherTabs: TMenuItem; FindPanel: TPanel; - FindButtonClose: TSpeedButton; FindEditPanel: TPanel; FindButtonPanel: TPanel; TabPopupMenu: TPopupMenu; @@ -49,6 +48,7 @@ TSimbaScriptTabsForm = class(TForm) FFindButtonUp: TSimbaButton; FFindButtonCaseSens: TSimbaToggleButton; FFindButtonWholeWord: TSimbaToggleButton; + FFindButtonClose: TSimbaTransparentButton; FMouseDown: Boolean; FMouseDownX, FMouseDownY: Integer; @@ -144,7 +144,7 @@ procedure TSimbaScriptTabsForm.FindButtonClick(Sender: TObject); if Sender.Equals(FFindButtonDown) then FindNext() else - if Sender.Equals(FindButtonClose) then + if Sender.Equals(FFindButtonClose) then FindPanel.Hide(); end; @@ -336,8 +336,9 @@ constructor TSimbaScriptTabsForm.Create(AOwner: TComponent); FindPanel.AddHandlerOnVisibleChanged(@DoFindPanelVisibleChanged); FFindEdit := TSimbaEdit.Create(Self); - FFindEdit.Parent := FindButtonPanel; - FFindEdit.Align := alLeft; + FFindEdit.Parent := FindEditPanel; + FFindEdit.Align := alClient; + FFindEdit.AnchorVerticalCenterTo(FindEditPanel); FFindEdit.BorderSpacing.Around := 5; FFindEdit.OnChange := @FindEditChange; FFindEdit.OnKeyDown := @FindButtonKeyDown; @@ -345,7 +346,7 @@ constructor TSimbaScriptTabsForm.Create(AOwner: TComponent); FFindButtonWholeWord := TSimbaToggleButton.Create(Self); with FFindButtonWholeWord do begin - Parent := FindEditPanel; + Parent := FindButtonPanel; Caption := 'W'; Font.Bold := True; Align := alLeft; @@ -358,7 +359,7 @@ constructor TSimbaScriptTabsForm.Create(AOwner: TComponent); FFindButtonCaseSens := TSimbaToggleButton.Create(Self); with FFindButtonCaseSens do begin - Parent := FindEditPanel; + Parent := FindButtonPanel; Caption := 'Aa'; Font.Bold := True; Align := alLeft; @@ -372,7 +373,7 @@ constructor TSimbaScriptTabsForm.Create(AOwner: TComponent); with FFindButtonDown do begin Images := SimbaForm.Images; - Parent := FindEditPanel; + Parent := FindButtonPanel; Align := alLeft; ImageINdex := 44; Hint := 'Find Next'; @@ -385,7 +386,7 @@ constructor TSimbaScriptTabsForm.Create(AOwner: TComponent); with FFindButtonUp do begin Images := SimbaForm.Images; - Parent := FindEditPanel; + Parent := FindButtonPanel; Align := alLeft; ImageIndex := 43; Hint := 'Find Previous'; @@ -394,7 +395,16 @@ constructor TSimbaScriptTabsForm.Create(AOwner: TComponent); OnClick := @FindButtonClick; end; - FindButtonClose.Font.Color := SimbaTheme.ColorFont; + FFindButtonClose := TSimbaTransparentButton.Create(Self); + with FFindButtonClose do + begin + Images := SimbaForm.Images; + Parent := FindPanel; + Align := alRight; + BorderSpacing.Around := 5; + SetCloseGlyph(); + OnClick := @FindButtonClick; + end; CalculateFindButtonSizes(); end; diff --git a/Source/simba.bitmap.pas b/Source/simba.bitmap.pas index 09522fcc1..beebe3dfe 100644 --- a/Source/simba.bitmap.pas +++ b/Source/simba.bitmap.pas @@ -2375,37 +2375,52 @@ procedure TMufasaBitmap.ThresholdAdaptive(Alpha, Beta: Byte; AInvert: Boolean; M procedure TMufasaBitmap.ThresholdSauvola(Window: Integer; AInvert: Boolean; K: Single); var - SumTable: TIntegerMatrix; - SumTableSquared: TIntegerMatrix; + SumTable: TDoubleMatrix; + SumTableSquared: TDoubleMatrix; - function CreateSumTable(Matrix: TByteMatrix; Squared: Boolean): TIntegerMatrix; + function CreateSumTable(Matrix: TByteMatrix): TDoubleMatrix; var W, H, X, Y: Integer; begin - Result.SetSize(Matrix.Width, Matrix.Height); + SetLength(Result, Matrix.Height, Matrix.Width); - W := Matrix.Width - 1; - H := Matrix.Height - 1; + W := Result.Width - 1; + H := Result.Height - 1; - for Y := 0 to W do - if Squared then - Result[0, Y] := Sqr(Matrix[0, Y]) - else - Result[0, Y] := Matrix[0, Y]; + for Y := 0 to H do + Result[0, Y] := Matrix[0, Y]; for Y := 1 to H do for X := 0 to W do - if Squared then - Result[Y, X] := Sqr(Matrix[Y, X]) + Result[Y-1, X] - else - Result[Y, X] := Matrix[Y, X] + Result[Y-1, X]; + Result[Y, X] := Matrix[Y,X] + Result[Y-1, X]; + + for Y := 0 to H do + for X := 1 to W do + Result[Y, X] += Result[Y, X-1]; + end; + + function CreateSumTableSquared(Matrix: TByteMatrix): TDoubleMatrix; + var + W, H, X, Y: Integer; + begin + SetLength(Result, Matrix.Height, Matrix.Width); + + W := Result.Width - 1; + H := Result.Height - 1; + + for Y := 0 to H do + Result[0, Y] := Sqr(Matrix[0, Y]); + + for Y := 1 to H do + for X := 0 to W do + Result[Y, X] := Sqr(Matrix[Y,X]) + Result[Y-1, X]; for Y := 0 to H do for X := 1 to W do Result[Y, X] += Result[Y, X-1]; end; - function QuerySumTable(Table: TIntegerMatrix; X1, Y1, X2, Y2: Integer): Integer; + function QuerySumTable(Table: TDoubleMatrix; X1, Y1, X2, Y2: Integer): Double; begin Result := Table[Y2, X2]; @@ -2443,8 +2458,8 @@ procedure TMufasaBitmap.ThresholdSauvola(Window: Integer; AInvert: Boolean; K: S Matrix := ToGreyMatrix(); - SumTable := CreateSumTable(Matrix, False); - SumTableSquared := CreateSumTable(Matrix, True); + SumTable := CreateSumTable(Matrix); + SumTableSquared := CreateSumTableSquared(Matrix); W := FWidth - 1; H := FHeight - 1; diff --git a/Source/simba.bitmap_utils.pas b/Source/simba.bitmap_utils.pas index 9a5f43bdf..e6639d260 100644 --- a/Source/simba.bitmap_utils.pas +++ b/Source/simba.bitmap_utils.pas @@ -479,7 +479,7 @@ class function TRGBSumTableHelper.Create(Bitmap: TMufasaBitmap): TRGBSumTable; H := Bitmap.Height - 1; for Y := 0 to H do - Result[0, Y] := Bitmap.Data[Y*Bitmap.Width]; + Result[Y, 0] := Bitmap.Data[Y*Bitmap.Width]; for Y := 1 to H do for X := 0 to W do diff --git a/Source/simba.dockinghelpers.pas b/Source/simba.dockinghelpers.pas index c161bfb11..92c76c22d 100644 --- a/Source/simba.dockinghelpers.pas +++ b/Source/simba.dockinghelpers.pas @@ -54,9 +54,6 @@ TSimbaAnchorDockHostSite = class(TAnchorDockHostSite) end; TSimbaAnchorDockSplitter = class(TAnchorDockSplitter) - protected - const - GRIPPER_SIZE = 75; protected procedure Paint; override; end; @@ -226,6 +223,12 @@ procedure TSimbaAnchorDockSplitter.Paint; begin Canvas.Brush.Color := SimbaTheme.ColorFrame; Canvas.FillRect(ClientRect); + + if MouseInClient then + begin + Canvas.Brush.Color := SimbaTheme.ColorActive; + Canvas.FillRect(3, 3, Width-3, Height-3); + end; end; procedure TAnchorDockMasterHelper.MakeDockable(Form: TCustomForm; MenuItem: TMenuItem); diff --git a/Source/simba.scripttab.pas b/Source/simba.scripttab.pas index a12586ddb..1eee799c7 100644 --- a/Source/simba.scripttab.pas +++ b/Source/simba.scripttab.pas @@ -361,7 +361,7 @@ constructor TSimbaScriptTab.Create(AOwner: TComponent); FEditor := TSimbaEditor.Create(Self); FEditor.Parent := Self; FEditor.Align := alClient; - FEditor.TabStop := False; + FEditor.TabStop := True; FEditor.Text := SimbaSettings.Editor.DefaultScript.Value; FEditor.MarkTextAsSaved(); FEditor.RegisterStatusChangedHandler(@DoEditorStatusChanges, [scCaretX, scCaretY, scModified]);