From 54b11708ff6516808aaa7df9621346f6d3b23a30 Mon Sep 17 00:00:00 2001 From: juha Date: Tue, 5 May 2015 18:34:52 +0000 Subject: [PATCH] IDE: Resize the main IDE window correctly. Issue #27940, patch from Ondrej Pokorny. git-svn-id: trunk@48937 - --- ide/componentpalette.pas | 1 + ide/environmentopts.pp | 8 + ide/frames/toolbar_options.pas | 1 + ide/frames/window_options.lfm | 283 +++++++++++++++++---------------- ide/frames/window_options.pas | 5 + ide/lazarusidestrconsts.pas | 2 + ide/main.pp | 27 +--- ide/mainbar.pas | 161 +++++++++++++------ 8 files changed, 281 insertions(+), 207 deletions(-) diff --git a/ide/componentpalette.pas b/ide/componentpalette.pas index 90b52e9c96..c858b55665 100644 --- a/ide/componentpalette.pas +++ b/ide/componentpalette.pas @@ -331,6 +331,7 @@ begin AutoScroll:=false; {$ENDIF} VertScrollBar.Increment := ComponentPaletteBtnHeight; + VertScrollBar.Tracking := True; Parent := PageComponent; end; PanelRight := TPanel.Create(PageComponent); diff --git a/ide/environmentopts.pp b/ide/environmentopts.pp index 89b64fe7d2..07b5db7749 100644 --- a/ide/environmentopts.pp +++ b/ide/environmentopts.pp @@ -287,6 +287,8 @@ type FSingleTaskBarButton: boolean; FHideIDEOnRun: boolean; FComponentPaletteVisible: boolean; + FAutoAdjustIDEHeight: boolean; + // CompletionWindow FCompletionWindowWidth: Integer; FCompletionWindowHeight: Integer; @@ -517,6 +519,7 @@ type write FIDEProjectDirectoryInIdeTitle; property ComponentPaletteVisible: boolean read FComponentPaletteVisible write FComponentPaletteVisible; + property AutoAdjustIDEHeight: Boolean read FAutoAdjustIDEHeight write FAutoAdjustIDEHeight; property CompletionWindowWidth: Integer read FCompletionWindowWidth write FCompletionWindowWidth; property CompletionWindowHeight: Integer read FCompletionWindowHeight @@ -878,6 +881,7 @@ begin FIDETitleIncludesBuildMode:=false; FIDEProjectDirectoryInIdeTitle:=false; FComponentPaletteVisible:=true; + FAutoAdjustIDEHeight:=true; // window menu FIDENameForDesignedFormList:=false; @@ -1204,6 +1208,8 @@ begin Path+'Desktop/IDEProjectDirectoryInIdeTitle/Value',false); FComponentPaletteVisible:=XMLConfig.GetValue( Path+'Desktop/ComponentPaletteVisible/Value',true); + FAutoAdjustIDEHeight:=XMLConfig.GetValue( + Path+'Desktop/AutoAdjustIDEHeight/Value',true); FCompletionWindowWidth:=XMLConfig.GetValue( Path+'Desktop/CompletionWindowWidth/Value', 320); FCompletionWindowHeight:=XMLConfig.GetValue( @@ -1593,6 +1599,8 @@ begin FIDEProjectDirectoryInIdeTitle,false); XMLConfig.SetDeleteValue(Path+'Desktop/ComponentPaletteVisible/Value', FComponentPaletteVisible,true); + XMLConfig.SetDeleteValue(Path+'Desktop/AutoAdjustIDEHeight/Value', + FAutoAdjustIDEHeight,true); XMLConfig.SetDeleteValue(Path+'Desktop/CompletionWindowWidth/Value', FCompletionWindowWidth, 320); XMLConfig.SetDeleteValue(Path+'Desktop/CompletionWindowHeight/Value', diff --git a/ide/frames/toolbar_options.pas b/ide/frames/toolbar_options.pas index dcf2de9cf1..36e811088d 100644 --- a/ide/frames/toolbar_options.pas +++ b/ide/frames/toolbar_options.pas @@ -198,6 +198,7 @@ begin Opts.IDECoolBarGrabWidth := spGrabWidth.Value; Opts.IDECoolBarBorderStyle := cbBorderStyle.ItemIndex; MainIDEBar.RefreshCoolbar; + MainIDEBar.SetMainIDEHeight; end; class function TToolbarOptionsFrame.SupportedOptionsClass: TAbstractIDEOptionsClass; diff --git a/ide/frames/window_options.lfm b/ide/frames/window_options.lfm index c45a1f6cd3..443238ddd4 100644 --- a/ide/frames/window_options.lfm +++ b/ide/frames/window_options.lfm @@ -1,22 +1,22 @@ object WindowOptionsFrame: TWindowOptionsFrame Left = 0 - Height = 545 + Height = 582 Top = 0 - Width = 562 - ClientHeight = 545 - ClientWidth = 562 + Width = 573 + ClientHeight = 582 + ClientWidth = 573 TabOrder = 0 - DesignLeft = 407 - DesignTop = 219 + DesignLeft = 349 + DesignTop = 181 object SingleTaskBarButtonCheckBox: TCheckBox AnchorSideLeft.Control = Owner AnchorSideTop.Control = lblShowingWindows AnchorSideTop.Side = asrBottom AnchorSideRight.Side = asrBottom Left = 0 - Height = 24 - Top = 20 - Width = 224 + Height = 17 + Top = 13 + Width = 165 Caption = 'SingleTaskBarButtonCheckBox' ParentShowHint = False ShowHint = True @@ -28,40 +28,36 @@ object WindowOptionsFrame: TWindowOptionsFrame AnchorSideTop.Side = asrBottom AnchorSideRight.Side = asrBottom Left = 0 - Height = 24 - Top = 44 - Width = 187 + Height = 17 + Top = 30 + Width = 138 Caption = 'HideIDEOnRunCheckBox' ParentShowHint = False ShowHint = True TabOrder = 1 end object WindowPositionsPanel: TPanel - AnchorSideLeft.Control = Owner AnchorSideTop.Control = lblWindowPosition AnchorSideTop.Side = asrBottom - AnchorSideRight.Control = Owner - AnchorSideRight.Side = asrBottom - AnchorSideBottom.Control = Owner AnchorSideBottom.Side = asrBottom Left = 0 - Height = 354 - Top = 191 - Width = 562 + Height = 423 + Top = 154 + Width = 570 Anchors = [akTop, akLeft, akRight, akBottom] - BorderSpacing.Top = 1 + BorderSpacing.Top = 3 Caption = 'WindowPositionsPanel' - ClientHeight = 354 - ClientWidth = 562 - TabOrder = 2 + ClientHeight = 423 + ClientWidth = 570 + TabOrder = 7 object LeftLabel: TLabel AnchorSideTop.Control = LeftEdit AnchorSideTop.Side = asrCenter AnchorSideRight.Control = LeftEdit - Left = 281 - Height = 20 - Top = 238 - Width = 61 + Left = 306 + Height = 13 + Top = 231 + Width = 44 Anchors = [akTop, akRight] BorderSpacing.Right = 3 Caption = 'LeftLabel' @@ -71,10 +67,10 @@ object WindowOptionsFrame: TWindowOptionsFrame AnchorSideTop.Control = TopEdit AnchorSideTop.Side = asrCenter AnchorSideRight.Control = TopEdit - Left = 280 - Height = 20 - Top = 272 - Width = 62 + Left = 307 + Height = 13 + Top = 258 + Width = 43 Anchors = [akTop, akRight] BorderSpacing.Right = 3 Caption = 'TopLabel' @@ -84,10 +80,10 @@ object WindowOptionsFrame: TWindowOptionsFrame AnchorSideTop.Control = WidthEdit AnchorSideTop.Side = asrCenter AnchorSideRight.Control = WidthEdit - Left = 401 - Height = 20 - Top = 238 - Width = 76 + Left = 432 + Height = 13 + Top = 231 + Width = 53 Anchors = [akTop, akRight] BorderSpacing.Right = 3 Caption = 'WidthLabel' @@ -97,10 +93,10 @@ object WindowOptionsFrame: TWindowOptionsFrame AnchorSideTop.Control = HeightEdit AnchorSideTop.Side = asrCenter AnchorSideRight.Control = HeightEdit - Left = 396 - Height = 20 - Top = 272 - Width = 81 + Left = 429 + Height = 13 + Top = 258 + Width = 56 Anchors = [akTop, akRight] BorderSpacing.Right = 3 Caption = 'HeightLabel' @@ -114,7 +110,7 @@ object WindowOptionsFrame: TWindowOptionsFrame Left = 7 Height = 120 Top = 3 - Width = 548 + Width = 556 Anchors = [akTop, akLeft, akRight] BorderSpacing.Left = 6 BorderSpacing.Top = 2 @@ -122,7 +118,7 @@ object WindowOptionsFrame: TWindowOptionsFrame ItemHeight = 0 OnSelectionChange = WindowPositionsListBoxSelectionChange ParentShowHint = False - ScrollWidth = 300 + ScrollWidth = 552 ShowHint = True TabOrder = 0 end @@ -131,41 +127,41 @@ object WindowOptionsFrame: TWindowOptionsFrame AnchorSideTop.Control = RestoreWindowGeometryRadioButton AnchorSideTop.Side = asrBottom Left = 7 - Height = 24 - Top = 261 - Width = 288 + Height = 17 + Top = 247 + Width = 206 BorderSpacing.Left = 6 BorderSpacing.Top = 3 Caption = 'LetWindowManagerDecideRadioButton' OnClick = WindowGeometryRadioButtonClick ParentShowHint = False ShowHint = True - TabOrder = 1 + TabOrder = 3 end object FixedDefaultRadioButton: TRadioButton AnchorSideLeft.Control = WindowPositionsPanel AnchorSideTop.Control = LetWindowManagerDecideRadioButton AnchorSideTop.Side = asrBottom Left = 7 - Height = 24 - Top = 288 - Width = 191 + Height = 17 + Top = 267 + Width = 140 BorderSpacing.Left = 6 BorderSpacing.Top = 3 Caption = 'FixedDefaultRadioButton' OnClick = WindowGeometryRadioButtonClick ParentShowHint = False ShowHint = True - TabOrder = 2 + TabOrder = 4 end object RestoreWindowGeometryRadioButton: TRadioButton AnchorSideLeft.Control = WindowPositionsPanel AnchorSideTop.Control = SplitterPanel AnchorSideTop.Side = asrBottom Left = 7 - Height = 24 - Top = 234 - Width = 277 + Height = 17 + Top = 227 + Width = 202 BorderSpacing.Left = 6 BorderSpacing.Top = 4 Caption = 'RestoreWindowGeometryRadioButton' @@ -173,7 +169,7 @@ object WindowOptionsFrame: TWindowOptionsFrame OnClick = CustomGeometryRadioButtonClick ParentShowHint = False ShowHint = True - TabOrder = 3 + TabOrder = 2 TabStop = True end object CustomGeometryRadioButton: TRadioButton @@ -181,23 +177,23 @@ object WindowOptionsFrame: TWindowOptionsFrame AnchorSideTop.Control = FixedDefaultRadioButton AnchorSideTop.Side = asrBottom Left = 7 - Height = 24 - Top = 315 - Width = 222 + Height = 17 + Top = 287 + Width = 162 BorderSpacing.Left = 6 BorderSpacing.Top = 3 Caption = 'CustomGeometryRadioButton' OnClick = CustomGeometryRadioButtonClick ParentShowHint = False ShowHint = True - TabOrder = 4 + TabOrder = 5 end object LeftEdit: TSpinEdit AnchorSideTop.Control = RestoreWindowGeometryRadioButton AnchorSideRight.Control = WidthEdit - Left = 345 - Height = 28 - Top = 234 + Left = 353 + Height = 21 + Top = 227 Width = 75 Anchors = [akTop, akRight] BorderSpacing.Right = 60 @@ -205,48 +201,48 @@ object WindowOptionsFrame: TWindowOptionsFrame MinValue = -5000 ParentShowHint = False ShowHint = True - TabOrder = 5 - end - object TopEdit: TSpinEdit - AnchorSideTop.Control = LeftEdit - AnchorSideTop.Side = asrBottom - AnchorSideRight.Control = HeightEdit - Left = 345 - Height = 28 - Top = 268 - Width = 75 - Anchors = [akTop, akRight] - BorderSpacing.Top = 6 - BorderSpacing.Right = 60 - MaxValue = 4096 - MinValue = -5000 - ParentShowHint = False - ShowHint = True TabOrder = 6 end + object TopEdit: TSpinEdit + AnchorSideTop.Control = LeftEdit + AnchorSideTop.Side = asrBottom + AnchorSideRight.Control = HeightEdit + Left = 353 + Height = 21 + Top = 254 + Width = 75 + Anchors = [akTop, akRight] + BorderSpacing.Top = 6 + BorderSpacing.Right = 60 + MaxValue = 4096 + MinValue = -5000 + ParentShowHint = False + ShowHint = True + TabOrder = 7 + end object WidthEdit: TSpinEdit AnchorSideTop.Control = LeftEdit AnchorSideRight.Control = WindowPositionsPanel AnchorSideRight.Side = asrBottom - Left = 480 - Height = 28 - Top = 234 + Left = 488 + Height = 21 + Top = 227 Width = 75 Anchors = [akTop, akRight] BorderSpacing.Right = 6 MaxValue = 4096 ParentShowHint = False ShowHint = True - TabOrder = 7 + TabOrder = 8 end object HeightEdit: TSpinEdit AnchorSideTop.Control = WidthEdit AnchorSideTop.Side = asrBottom AnchorSideRight.Control = WindowPositionsPanel AnchorSideRight.Side = asrBottom - Left = 480 - Height = 28 - Top = 268 + Left = 488 + Height = 21 + Top = 254 Width = 75 Anchors = [akTop, akRight] BorderSpacing.Top = 6 @@ -254,32 +250,30 @@ object WindowOptionsFrame: TWindowOptionsFrame MaxValue = 4096 ParentShowHint = False ShowHint = True - TabOrder = 8 + TabOrder = 9 end object GetWindowPositionButton: TButton - AnchorSideTop.Control = ApplyButton - AnchorSideRight.Control = ApplyButton - Left = 239 - Height = 30 - Top = 308 - Width = 201 + Left = 322 + Height = 23 + Top = 288 + Width = 150 Anchors = [akTop, akRight] AutoSize = True BorderSpacing.Right = 6 Caption = 'GetWindowPositionButton' Constraints.MinWidth = 75 OnClick = GetWindowPositionButtonClick - TabOrder = 9 + TabOrder = 10 end object ApplyButton: TButton AnchorSideTop.Control = HeightEdit AnchorSideTop.Side = asrBottom AnchorSideRight.Control = WindowPositionsPanel AnchorSideRight.Side = asrBottom - Left = 446 - Height = 30 - Top = 308 - Width = 109 + Left = 478 + Height = 23 + Top = 287 + Width = 85 Anchors = [akTop, akRight] AutoSize = True BorderSpacing.Top = 12 @@ -287,7 +281,7 @@ object WindowOptionsFrame: TWindowOptionsFrame Caption = 'ApplyButton' Constraints.MinWidth = 75 OnClick = ApplyButtonClick - TabOrder = 10 + TabOrder = 11 end object SplitterPanel: TPanel AnchorSideLeft.Control = WindowPositionsPanel @@ -299,8 +293,8 @@ object WindowOptionsFrame: TWindowOptionsFrame AnchorSideBottom.Side = asrBottom Left = 5 Height = 78 - Top = 152 - Width = 556 + Top = 145 + Width = 564 Anchors = [akTop, akLeft, akRight] BorderSpacing.Left = 4 BorderSpacing.Top = 3 @@ -309,8 +303,8 @@ object WindowOptionsFrame: TWindowOptionsFrame BorderStyle = bsSingle Caption = ' ' ClientHeight = 74 - ClientWidth = 552 - TabOrder = 11 + ClientWidth = 560 + TabOrder = 1 Visible = False object SplitterList: TListBox AnchorSideLeft.Control = SplitterPanel @@ -325,7 +319,7 @@ object WindowOptionsFrame: TWindowOptionsFrame ItemHeight = 0 OnSelectionChange = SplitterListSelectionChange ParentShowHint = False - ScrollWidth = 273 + ScrollWidth = 271 ShowHint = True TabOrder = 0 end @@ -333,10 +327,10 @@ object WindowOptionsFrame: TWindowOptionsFrame AnchorSideTop.Control = SplitEdit AnchorSideTop.Side = asrCenter AnchorSideRight.Control = SplitEdit - Left = 407 - Height = 20 - Top = 40 - Width = 66 + Left = 436 + Height = 13 + Top = 47 + Width = 45 Anchors = [akTop, akRight] BorderSpacing.Right = 3 Caption = 'SplitLabel' @@ -347,16 +341,16 @@ object WindowOptionsFrame: TWindowOptionsFrame AnchorSideRight.Side = asrBottom AnchorSideBottom.Control = SplitterPanel AnchorSideBottom.Side = asrBottom - Left = 476 - Height = 28 - Top = 36 + Left = 484 + Height = 21 + Top = 43 Width = 75 Anchors = [akRight, akBottom] BorderSpacing.Bottom = 9 MaxValue = 5000 ParentShowHint = False ShowHint = True - TabOrder = 1 + TabOrder = 2 end object dropSplitterPlacement: TComboBox AnchorSideLeft.Control = SplitterList @@ -365,16 +359,16 @@ object WindowOptionsFrame: TWindowOptionsFrame AnchorSideRight.Control = SplitterPanel AnchorSideRight.Side = asrBottom Left = 282 - Height = 28 + Height = 21 Top = 1 - Width = 269 + Width = 277 Anchors = [akTop, akLeft, akRight] BorderSpacing.Left = 6 - ItemHeight = 20 + ItemHeight = 13 ParentShowHint = False ShowHint = True Style = csDropDownList - TabOrder = 2 + TabOrder = 1 end end object lblWindowCaption: TDividerBevel @@ -384,9 +378,9 @@ object WindowOptionsFrame: TWindowOptionsFrame AnchorSideRight.Control = WindowPositionsPanel AnchorSideRight.Side = asrBottom Left = 1 - Height = 20 + Height = 13 Top = 129 - Width = 560 + Width = 568 Caption = 'lblWindowCaption' Anchors = [akTop, akLeft, akRight] BorderSpacing.Top = 6 @@ -400,52 +394,52 @@ object WindowOptionsFrame: TWindowOptionsFrame AnchorSideTop.Control = HideIDEOnRunCheckBox AnchorSideTop.Side = asrBottom Left = 0 - Height = 24 - Top = 68 - Width = 231 + Height = 17 + Top = 47 + Width = 172 Caption = 'TitleStartsWithProjectCheckBox' ParentShowHint = False ShowHint = True - TabOrder = 3 + TabOrder = 2 end object ProjectDirInIdeTitleCheckBox: TCheckBox AnchorSideLeft.Control = Owner AnchorSideTop.Control = TitleStartsWithProjectCheckBox AnchorSideTop.Side = asrBottom Left = 0 - Height = 24 - Top = 92 - Width = 216 + Height = 17 + Top = 64 + Width = 160 Caption = 'ProjectDirInIdeTitleCheckBox' ParentShowHint = False ShowHint = True - TabOrder = 4 + TabOrder = 3 end object TitleIncludesBuildMode: TCheckBox AnchorSideLeft.Control = Owner AnchorSideTop.Control = ProjectDirInIdeTitleCheckBox AnchorSideTop.Side = asrBottom Left = 0 - Height = 24 - Top = 116 - Width = 180 + Height = 17 + Top = 81 + Width = 128 Caption = 'TitleIncludesBuildMode' ParentShowHint = False ShowHint = True - TabOrder = 5 + TabOrder = 4 end object NameForDesignedFormList: TCheckBox AnchorSideLeft.Control = Owner AnchorSideTop.Control = TitleIncludesBuildMode AnchorSideTop.Side = asrBottom Left = 0 - Height = 24 - Top = 140 - Width = 204 + Height = 17 + Top = 98 + Width = 147 Caption = 'NameForDesignedFormList' ParentShowHint = False ShowHint = True - TabOrder = 6 + TabOrder = 5 end object lblShowingWindows: TDividerBevel AnchorSideLeft.Control = Owner @@ -453,9 +447,9 @@ object WindowOptionsFrame: TWindowOptionsFrame AnchorSideRight.Control = Owner AnchorSideRight.Side = asrBottom Left = 0 - Height = 20 + Height = 13 Top = 0 - Width = 562 + Width = 573 Caption = 'lblShowingWindows' Anchors = [akTop, akLeft, akRight] Font.Style = [fsBold] @@ -463,18 +457,31 @@ object WindowOptionsFrame: TWindowOptionsFrame end object lblWindowPosition: TDividerBevel AnchorSideLeft.Control = Owner - AnchorSideTop.Control = NameForDesignedFormList + AnchorSideTop.Control = AutoAdjustIDEHeightCheckBox AnchorSideTop.Side = asrBottom AnchorSideRight.Control = Owner AnchorSideRight.Side = asrBottom Left = 0 - Height = 20 - Top = 170 - Width = 562 + Height = 13 + Top = 138 + Width = 573 Caption = 'lblWindowPosition' Anchors = [akTop, akLeft, akRight] BorderSpacing.Top = 6 Font.Style = [fsBold] ParentFont = False end + object AutoAdjustIDEHeightCheckBox: TCheckBox + AnchorSideLeft.Control = Owner + AnchorSideTop.Control = NameForDesignedFormList + AnchorSideTop.Side = asrBottom + Left = 0 + Height = 17 + Top = 115 + Width = 169 + Caption = 'AutoAdjustIDEHeightCheckBox' + ParentShowHint = False + ShowHint = True + TabOrder = 6 + end end diff --git a/ide/frames/window_options.pas b/ide/frames/window_options.pas index 6221431f5e..e5ea455952 100644 --- a/ide/frames/window_options.pas +++ b/ide/frames/window_options.pas @@ -39,6 +39,7 @@ type lblShowingWindows: TDividerBevel; lblWindowCaption: TDividerBevel; NameForDesignedFormList: TCheckBox; + AutoAdjustIDEHeightCheckBox: TCheckBox; TitleIncludesBuildMode: TCheckBox; dropSplitterPlacement: TComboBox; CustomGeometryRadioButton: TRadioButton; @@ -122,6 +123,8 @@ begin TitleIncludesBuildMode.Hint:=lisBuildModeInTitleInExample; NameForDesignedFormList.Caption:=lisWindowMenuWithNameForDesignedForm; NameForDesignedFormList.Hint:=lisWindowMenuWithNameForDesignedFormHint; + AutoAdjustIDEHeightCheckBox.Caption:=lisAutoAdjustIDEHeight; + AutoAdjustIDEHeightCheckBox.Hint:=lisAutoAdjustIDEHeightHint; ProjectDirInIdeTitleCheckBox.Caption:=lisIDETitleShowsProjectDir; ProjectDirInIdeTitleCheckBox.Hint:=lisProjectDirectoryIsShowedInIdeTitleBar; end; @@ -139,6 +142,7 @@ begin TitleStartsWithProjectCheckBox.Checked:=IDETitleStartsWithProject; TitleIncludesBuildMode.Checked:=IDETitleIncludesBuildMode; NameForDesignedFormList.Checked:=IDENameForDesignedFormList; + AutoAdjustIDEHeightCheckBox.Checked:=AutoAdjustIDEHeight; ProjectDirInIdeTitleCheckBox.Checked:=IDEProjectDirectoryInIdeTitle; end; @@ -219,6 +223,7 @@ begin IDETitleStartsWithProject:=TitleStartsWithProjectCheckBox.Checked; IDETitleIncludesBuildMode := TitleIncludesBuildMode.Checked; IDENameForDesignedFormList := NameForDesignedFormList.Checked; + AutoAdjustIDEHeight := AutoAdjustIDEHeightCheckBox.Checked; IDEProjectDirectoryInIdeTitle:=ProjectDirInIdeTitleCheckBox.Checked; end; end; diff --git a/ide/lazarusidestrconsts.pas b/ide/lazarusidestrconsts.pas index 3c2e175450..d4c0704de1 100644 --- a/ide/lazarusidestrconsts.pas +++ b/ide/lazarusidestrconsts.pas @@ -1259,6 +1259,8 @@ resourcestring lisIDETitleStartsWithProjectName = 'IDE title starts with project name'; lisIDETitleShowsProjectDir = 'IDE title shows project directory'; lisIDETitleShowsBuildMode = 'IDE title shows selected build mode'; + lisAutoAdjustIDEHeight = 'Automatically adjust IDE main window height'; + lisAutoAdjustIDEHeightHint = 'Applicable only when not maximized and for undocked IDE.'; lisWindowMenuWithNameForDesignedForm = 'Window menu shows designed form''s name instead of caption'; lisWindowMenuWithNameForDesignedFormHint = 'Useful especially if the caption is left empty.'; dlgWinPos = 'Window positions'; diff --git a/ide/main.pp b/ide/main.pp index 441cc511d2..5cc91931ad 100644 --- a/ide/main.pp +++ b/ide/main.pp @@ -1412,7 +1412,6 @@ var FormCreator: TIDEWindowCreator; PkgMngr: TPkgManager; CompPalette: TComponentPalette; - AMenuHeight: Integer; begin {$IFDEF IDE_MEM_CHECK}CheckHeapWrtMemCnt('TMainIDE.Create START');{$ENDIF} inherited Create(TheOwner); @@ -1458,21 +1457,6 @@ begin Application.CreateForm(TMainIDEBar,MainIDEBar); MainIDEBar.OnActive:=@OnMainBarActive; - AMenuHeight := LCLIntf.GetSystemMetrics(SM_CYMENU); - if AMenuHeight > 0 then - begin - // what we know: - // 1. cmd speedbuttons height = 22 - // 2. components palette buttons = 32 - // 3. menu height provided by widgetset (varies , depends on theme) - // so we set 22 + 32 + (borders * 2). - MainIDEBar.NonClientHeight := AMenuHeight + - //22 {cmd speedbtns} + 32 {component buttons} + - LCLIntf.GetSystemMetrics(SM_CYSIZEFRAME) + - (LCLIntf.GetSystemMetrics(SM_CYBORDER) * 2) {borders}; - end else - MainIDEBar.NonClientHeight :=85; - MainIDEBar.Name := NonModalIDEWindowNames[nmiwMainIDEName]; FormCreator:=IDEWindowCreators.Add(MainIDEBar.Name); FormCreator.Right:='100%'; @@ -1543,7 +1527,6 @@ begin // load package configs HelpBoss.LoadHelpOptions; - MainIDEBar.RefreshCoolbar; end; procedure TMainIDE.StartIDE; @@ -2019,15 +2002,13 @@ begin MainIDEBar.MainSplitter.Parent := MainIDEBar; MainIDEBar.MainSplitter.Align := alLeft; MainIDEBar.MainSplitter.MinSize := 50; + MainIDEBar.MainSplitter.Tag := 112; MainIDEBar.MainSplitter.OnMoved := @MainIDEBar.MainSplitterMoved; - MainIDEBar.IDEHeightTimer := TTimer.Create(OwningComponent); - MainIDEBar.IDEHeightTimer.Interval := 100; - MainIDEBar.IDEHeightTimer.Enabled := False; - MainIDEBar.IDEHeightTimer.OnTimer := @MainIDEBar.OnTimer; MainIDEBar.CoolBar := TCoolBar.Create(OwningComponent); MainIDEBar.CoolBar.Parent := MainIDEBar; + MainIDEBar.CoolBar.Tag := 112; if EnvironmentOptions.ComponentPaletteVisible then begin MainIDEBar.CoolBar.Align := alLeft; @@ -2036,6 +2017,7 @@ begin else MainIDEBar.CoolBar.Align := alClient; + MainIDEBar.mnuMainMenu.Tag := 112; // IDE Coolbar object wraps MainIDEBar.CoolBar. IDECoolBar := TIDECoolBar.Create(MainIDEBar.CoolBar); IDECoolBar.IsVisible := EnvironmentOptions.IDECoolBarOptions.IDECoolBarVisible;; @@ -2068,6 +2050,7 @@ begin Align := alClient; Visible:=EnvironmentOptions.ComponentPaletteVisible; Parent := MainIDEBar; + Tag := 112; end; end; @@ -3705,7 +3688,7 @@ end; procedure TMainIDE.DoToggleViewComponentPalette; var - ComponentPaletteVisible: boolean; + ComponentPaletteVisible: Boolean; begin ComponentPaletteVisible:=not MainIDEBar.ComponentPageControl.Visible; MainIDEBar.itmViewComponentPalette.Checked:=ComponentPaletteVisible; diff --git a/ide/mainbar.pas b/ide/mainbar.pas index 1c88221236..dfa5bf1b35 100644 --- a/ide/mainbar.pas +++ b/ide/mainbar.pas @@ -48,12 +48,10 @@ uses type { TMainIDEBar } - TMainIDEBar = class(TForm) //Coolbar and PopUpMenus CoolBar: TCoolBar; OptionsPopupMenu: TPopupMenu; - IDEHeightTimer: TTimer; OptionsMenuItem: TMenuItem; OpenFilePopUpMenu: TPopupMenu; SetBuildModePopupMenu: TPopupMenu; @@ -364,16 +362,21 @@ type const FileNames: array of String); procedure CoolBarOnChange(Sender: TObject); procedure MainSplitterMoved(Sender: TObject); - procedure OnTimer(Sender: TObject); private FOldWindowState: TWindowState; FOnActive: TNotifyEvent; - FNonClientHeight: Integer; procedure NewUnitFormDefaultClick(Sender: TObject); procedure NewUnitFormPopupMenuPopup(Sender: TObject); + function IsDefaultIDE: Boolean; + function CalcMainIDEHeight: Integer; + function CalcNonClientHeight: Integer; protected procedure DoActive; + procedure DoShow; override; procedure WndProc(var Message: TLMessage); override; + + procedure DoSetMainIDEHeight(const AIDEIsMaximized: Boolean); + procedure Resizing(State: TWindowState); override; public constructor Create(TheOwner: TComponent); override; procedure HideIDE; @@ -383,16 +386,16 @@ type procedure UpdateDockCaption({%H-}Exclude: TControl); override; procedure RefreshCoolbar; procedure SetMainIDEHeight; - public - property NonClientHeight: Integer read FNonClientHeight write FNonClientHeight; end; - var MainIDEBar: TMainIDEBar = nil; implementation +uses + LCLIntf, LCLType, InterfaceBase, Math; + { TMainIDEBar } procedure TMainIDEBar.MainIDEBarDropFiles(Sender: TObject; @@ -476,6 +479,54 @@ begin FOnActive(Self); end; +procedure TMainIDEBar.DoSetMainIDEHeight(const AIDEIsMaximized: Boolean); +var + NewHeight: Integer; +begin + if not (Showing and IsDefaultIDE) then + Exit; + + if (AIDEIsMaximized or EnvironmentOptions.AutoAdjustIDEHeight) then + begin + NewHeight := CalcMainIDEHeight + CalcNonClientHeight; + if NewHeight <> Constraints.MaxHeight then + begin + Constraints.MaxHeight := NewHeight; + Constraints.MinHeight := Constraints.MaxHeight; + ClientHeight := Constraints.MaxHeight; + end; + end else + if Constraints.MaxHeight <> 0 then + begin + Constraints.MaxHeight := 0; + Constraints.MinHeight := 0; + end; +end; + +procedure TMainIDEBar.DoShow; +begin + inherited DoShow; + RefreshCoolbar; +end; + +function TMainIDEBar.CalcNonClientHeight: Integer; +var + WindowRect, WindowClientRect: TRect; +begin + if Showing then + begin + LclIntf.GetWindowRect(Handle, WindowRect{%H-}); + LclIntf.GetClientRect(Handle, WindowClientRect{%H-}); + LclIntf.ClientToScreen(Handle, WindowClientRect.TopLeft); + + Result := WindowClientRect.Top - WindowRect.Top; + + if Pos('Win32', WidgetSet.ClassName) > 0 then//TWin32WidgetSet widgetset bug -> the constrained height has to be without SM_CYSIZEFRAME and SM_CYMENU (Gtk2 works fine) + Result := Result - (LCLIntf.GetSystemMetrics(SM_CYSIZEFRAME) + LCLIntf.GetSystemMetrics(SM_CYMENU)); + end else + Result := 0; +end; + procedure TMainIDEBar.WndProc(var Message: TLMessage); begin inherited WndProc(Message); @@ -583,15 +634,61 @@ begin MainSplitter.Align := alLeft; MainSplitter.Visible := MainIDEBar.Coolbar.Visible and MainIDEBar.ComponentPageControl.Visible; - MainIDEBar.SetMainIDEHeight; +end; + +procedure TMainIDEBar.Resizing(State: TWindowState); +begin + case State of + wsMaximized, wsNormal: DoSetMainIDEHeight(State = wsMaximized); + end; + + inherited Resizing(State); end; procedure TMainIDEBar.MainSplitterMoved(Sender: TObject); begin EnvironmentOptions.IDECoolBarOptions.IDECoolBarWidth := CoolBar.Width; - SetMainIDEHeight + SetMainIDEHeight; end; +function TMainIDEBar.CalcMainIDEHeight: Integer; +var + NewHeight: Integer; + I: Integer; + ComponentScrollBox: TScrollBox; + SBControl: TControl; +begin + Result := 0; + if not (Assigned(EnvironmentOptions) and Assigned(CoolBar) and Assigned(ComponentPageControl)) then + Exit; + + if EnvironmentOptions.IDECoolBarOptions.IDECoolBarVisible then + begin + for I := 0 to CoolBar.Bands.Count-1 do + begin + NewHeight := CoolBar.Bands[I].Top + CoolBar.Bands[I].Height; + Result := Max(Result, NewHeight); + end; + end; + + if EnvironmentOptions.ComponentPaletteVisible then + begin + for I := 0 to ComponentPageControl.PageCount-1 do + if (ComponentPageControl.Page[I].ControlCount > 0) and (ComponentPageControl.Page[I].Controls[0] is TScrollBox) then + begin + ComponentScrollBox := TScrollBox(ComponentPageControl.Page[I].Controls[0]); + if ComponentScrollBox.ControlCount > 0 then + begin + SBControl := ComponentScrollBox.Controls[0]; + NewHeight := + SBControl.Top + SBControl.Height + //button height + ComponentPageControl.Height - ComponentScrollBox.ClientHeight; //page control non-client height (tabs, borders). + Result := Max(Result, NewHeight); + Break; //we need only one button (we calculate one line only) + end; + end; + end; +end; procedure TMainIDEBar.CoolBarOnChange(Sender: TObject); var @@ -617,52 +714,22 @@ end; procedure TMainIDEBar.SetMainIDEHeight; begin - if IDEHeightTimer.Enabled then - Exit; - IDEHeightTimer.Enabled := True; + DoSetMainIDEHeight(WindowState = wsMaximized); end; -procedure TMainIDEBar.OnTimer(Sender: TObject); +function TMainIDEBar.IsDefaultIDE: Boolean; var - CoolBarVisible: Boolean; - ComponentsVisible: Boolean; - CoolBarHeigth: Integer; - CoolBarDefHeight: Integer; - NewClientHeight: Integer; + I: Integer; begin - CoolBarVisible := EnvironmentOptions.IDECoolBarOptions.IDECoolBarVisible; - ComponentsVisible := EnvironmentOptions.ComponentPaletteVisible; - CoolBarDefHeight := CoolBar.Bands.Items[0].Height; //there is at least one band - CoolBarHeigth := CoolBar.Bands.Items[CoolBar.Bands.Count - 1].Top + - CoolBar.Bands.Items[CoolBar.Bands.Count - 1].Height; - - if (MainIDEBar.Parent=nil) and (MainIDEBar.DockManager=nil) then + Result := True; + for I := 0 to MainIDEBar.ControlCount - 1 do begin - //only the menu is visible - if (not CoolBarVisible) and (not ComponentsVisible) then - NewClientHeight := 0 - //only the coolbar is visible - else if (CoolBarVisible) and (not ComponentsVisible) then - NewClientHeight := CoolBarHeigth - //only the component palette is visible - else if (not CoolBarVisible) and (ComponentsVisible) then - NewClientHeight := 2*CoolBarDefHeight - //both coolbar and component palette is visible - else if (CoolBarVisible) and (ComponentsVisible) then + if (MainIDEBar.Controls[I] as TControl).Tag <> 112 then begin - if CoolBarHeigth > 2*CoolBarDefHeight then - NewClientHeight := CoolBarHeigth - else - NewClientHeight := 2*CoolBarHeigth; + Result := False; + Break; end; - - MainIDEBar.Constraints.MaxHeight := 0; - MainIDEBar.Constraints.MinHeight := 0; - MainIDEBar.ClientHeight := NewClientHeight; - MainIDEBar.Constraints.MaxHeight := NonClientHeight + NewClientHeight; - // MainIDEBar.Constraints.MinHeight := NonClientHeight + NewClientHeight; end; - IDEHeightTimer.Enabled := False; end;