diff --git a/components/ideintf/componentreg.pas b/components/ideintf/componentreg.pas index 2a8e27980f..dd617703d9 100644 --- a/components/ideintf/componentreg.pas +++ b/components/ideintf/componentreg.pas @@ -83,6 +83,7 @@ type private // Pages removed or renamed. They must be hidden in the palette. FHiddenPageNames: TStringList; + FVisible: boolean; public constructor Create; destructor Destroy; override; @@ -93,6 +94,7 @@ type procedure Save(XMLConfig: TXMLConfig; Path: String); public property HiddenPageNames: TStringList read FHiddenPageNames; + property Visible: boolean read FVisible write FVisible; end; { TCompPaletteUserOrder } @@ -404,6 +406,7 @@ constructor TCompPaletteOptions.Create; begin inherited Create; FHiddenPageNames := TStringList.Create; + FVisible := True; end; destructor TCompPaletteOptions.Destroy; @@ -422,6 +425,7 @@ procedure TCompPaletteOptions.Assign(Source: TCompPaletteOptions); begin inherited Assign(Source); FHiddenPageNames.Assign(Source.FHiddenPageNames); + FVisible := Source.FVisible; end; function TCompPaletteOptions.IsDefault: Boolean; @@ -441,6 +445,9 @@ var begin Path := Path + BasePath; try + FVisible:=XMLConfig.GetValue(Path+'Visible/Value',true); + + // Pages FPageNames.Clear; SubPath:=Path+'Pages/'; PageCount:=XMLConfig.GetValue(SubPath+'Count', 0); @@ -450,6 +457,7 @@ begin FPageNames.Add(PageName); end; + // HiddenPages FHiddenPageNames.Clear; SubPath:=Path+'HiddenPages/'; PageCount:=XMLConfig.GetValue(SubPath+'Count', 0); @@ -459,6 +467,7 @@ begin FHiddenPageNames.Add(PageName); end; + // ComponentPages FComponentPages.Clear; SubPath:=Path+'ComponentPages/'; PageCount:=XMLConfig.GetValue(SubPath+'Count', 0); @@ -489,6 +498,8 @@ var begin try Path := Path + BasePath; + XMLConfig.SetDeleteValue(Path+'Visible/Value', FVisible,true); + SubPath:=Path+'Pages/'; XMLConfig.DeletePath(SubPath); XMLConfig.SetDeleteValue(SubPath+'Count', FPageNames.Count, 0); diff --git a/ide/environmentopts.pp b/ide/environmentopts.pp index ff56fdf476..76196ae3c5 100644 --- a/ide/environmentopts.pp +++ b/ide/environmentopts.pp @@ -263,7 +263,6 @@ type FIDEDialogLayoutList: TIDEDialogLayoutList; FSingleTaskBarButton: boolean; FHideIDEOnRun: boolean; - FComponentPaletteVisible: boolean; FAutoAdjustIDEHeight: boolean; FAutoAdjustIDEHeightFullCompPal: boolean; // window menu @@ -296,8 +295,6 @@ type property IDEDialogLayoutList: TIDEDialogLayoutList read FIDEDialogLayoutList; property SingleTaskBarButton: boolean read FSingleTaskBarButton write FSingleTaskBarButton; property HideIDEOnRun: boolean read FHideIDEOnRun write FHideIDEOnRun; - property ComponentPaletteVisible: boolean read FComponentPaletteVisible - write FComponentPaletteVisible; property AutoAdjustIDEHeight: Boolean read FAutoAdjustIDEHeight write FAutoAdjustIDEHeight; property AutoAdjustIDEHeightFullCompPal: Boolean read FAutoAdjustIDEHeightFullCompPal write FAutoAdjustIDEHeightFullCompPal; @@ -937,7 +934,6 @@ begin inherited Create; FSingleTaskBarButton:=false; FHideIDEOnRun:=false; - FComponentPaletteVisible:=true; FAutoAdjustIDEHeight:=true; FAutoAdjustIDEHeightFullCompPal := true; // window menu @@ -990,7 +986,6 @@ begin FIDEDialogLayoutList.Assign(Source.FIDEDialogLayoutList); FSingleTaskBarButton := Source.FSingleTaskBarButton; FHideIDEOnRun := Source.FHideIDEOnRun; - FComponentPaletteVisible := Source.FComponentPaletteVisible; FAutoAdjustIDEHeight := Source.FAutoAdjustIDEHeight; FAutoAdjustIDEHeightFullCompPal := Source.FAutoAdjustIDEHeightFullCompPal; // window menu @@ -1019,7 +1014,6 @@ begin FSingleTaskBarButton:=FXMLCfg.GetValue(Path+'SingleTaskBarButton/Value', False); FHideIDEOnRun:=FXMLCfg.GetValue(Path+'HideIDEOnRun/Value',false); - FComponentPaletteVisible:=FXMLCfg.GetValue(Path+'ComponentPaletteVisible/Value',true); FAutoAdjustIDEHeight:=FXMLCfg.GetValue(Path+'AutoAdjustIDEHeight/Value',true); FAutoAdjustIDEHeightFullCompPal:=FXMLCfg.GetValue(Path+'AutoAdjustIDEHeightFullComponentPalette/Value',true); // Window menu @@ -1051,7 +1045,6 @@ begin FXMLCfg.SetDeleteValue(Path+'SingleTaskBarButton/Value',FSingleTaskBarButton, False); FXMLCfg.SetDeleteValue(Path+'HideIDEOnRun/Value',FHideIDEOnRun,false); - FXMLCfg.SetDeleteValue(Path+'ComponentPaletteVisible/Value',FComponentPaletteVisible,true); FXMLCfg.SetDeleteValue(Path+'AutoAdjustIDEHeight/Value',FAutoAdjustIDEHeight,true); FXMLCfg.SetDeleteValue(Path+'AutoAdjustIDEHeightFullComponentPalette/Value', FAutoAdjustIDEHeightFullCompPal,true); diff --git a/ide/frames/componentpalette_options.lfm b/ide/frames/componentpalette_options.lfm index 03d6c7aff6..6f532df696 100644 --- a/ide/frames/componentpalette_options.lfm +++ b/ide/frames/componentpalette_options.lfm @@ -1,25 +1,32 @@ object CompPaletteOptionsFrame: TCompPaletteOptionsFrame Left = 0 - Height = 411 + Height = 468 Top = 0 - Width = 511 - ClientHeight = 411 - ClientWidth = 511 + Width = 589 + ClientHeight = 468 + ClientWidth = 589 TabOrder = 0 Visible = False DesignLeft = 494 DesignTop = 307 object PagesGroupBox: TGroupBox + AnchorSideLeft.Control = Owner + AnchorSideTop.Control = cbPaletteVisible + AnchorSideTop.Side = asrBottom + AnchorSideRight.Control = Splitter1 AnchorSideRight.Side = asrBottom + AnchorSideBottom.Control = Owner + AnchorSideBottom.Side = asrBottom Left = 0 - Height = 411 - Top = 0 - Width = 227 - Align = alLeft - Anchors = [] + Height = 440 + Top = 28 + Width = 195 + Anchors = [akTop, akLeft, akRight, akBottom] + BorderSpacing.Top = 6 Caption = 'PagesGroupBox' - ClientHeight = 393 - ClientWidth = 223 + ClientHeight = 419 + ClientWidth = 191 + Constraints.MinWidth = 100 TabOrder = 0 object PagesListBox: TListBox AnchorSideLeft.Control = PagesGroupBox @@ -27,9 +34,9 @@ object CompPaletteOptionsFrame: TCompPaletteOptionsFrame AnchorSideRight.Control = PageMoveUpBtn AnchorSideBottom.Control = AddPageButton Left = 1 - Height = 284 + Height = 323 Top = 0 - Width = 188 + Width = 156 Anchors = [akTop, akLeft, akRight, akBottom] BorderSpacing.Left = 1 BorderSpacing.Right = 6 @@ -47,9 +54,9 @@ object CompPaletteOptionsFrame: TCompPaletteOptionsFrame AnchorSideTop.Side = asrBottom AnchorSideBottom.Control = ImportDividerBevel Left = 1 - Height = 23 - Top = 290 - Width = 60 + Height = 29 + Top = 329 + Width = 49 Anchors = [akLeft, akBottom] AutoSize = True BorderSpacing.Top = 6 @@ -63,9 +70,9 @@ object CompPaletteOptionsFrame: TCompPaletteOptionsFrame AnchorSideLeft.Side = asrBottom AnchorSideTop.Control = AddPageButton AnchorSideBottom.Side = asrBottom - Left = 70 - Height = 23 - Top = 290 + Left = 59 + Height = 29 + Top = 329 Width = 101 AutoSize = True BorderSpacing.Left = 9 @@ -78,7 +85,7 @@ object CompPaletteOptionsFrame: TCompPaletteOptionsFrame AnchorSideLeft.Control = PageMoveUpBtn AnchorSideTop.Control = PageMoveUpBtn AnchorSideTop.Side = asrBottom - Left = 195 + Left = 163 Height = 26 Top = 135 Width = 22 @@ -93,7 +100,7 @@ object CompPaletteOptionsFrame: TCompPaletteOptionsFrame AnchorSideTop.Side = asrBottom AnchorSideRight.Control = PagesGroupBox AnchorSideRight.Side = asrBottom - Left = 195 + Left = 163 Height = 26 Top = 102 Width = 22 @@ -111,91 +118,68 @@ object CompPaletteOptionsFrame: TCompPaletteOptionsFrame AnchorSideRight.Side = asrBottom AnchorSideBottom.Control = ImportButton Left = 1 - Height = 13 - Top = 319 - Width = 222 + Height = 17 + Top = 364 + Width = 190 Caption = 'Import / Export' Anchors = [akLeft, akRight, akBottom] Font.Style = [fsBold] ParentFont = False end - object RecentButton: TButton - AnchorSideLeft.Control = RecentLabel - AnchorSideLeft.Side = asrBottom - AnchorSideTop.Control = RecentLabel - AnchorSideTop.Side = asrCenter - Left = 128 - Height = 25 - Hint = 'Recent files' - Top = 334 - Width = 35 - BorderSpacing.Around = 6 - Caption = '>>' - ParentShowHint = False - ShowHint = True - TabOrder = 3 - Visible = False - end - object RecentLabel: TLabel - AnchorSideLeft.Control = ImportButton - AnchorSideLeft.Side = asrBottom - AnchorSideTop.Control = ImportButton - AnchorSideTop.Side = asrCenter - Left = 88 - Height = 13 - Top = 340 - Width = 34 - BorderSpacing.Left = 14 - Caption = 'Recent' - ParentColor = False - Visible = False - end object ImportButton: TBitBtn - AnchorSideLeft.Control = ExportButton + AnchorSideLeft.Control = PagesListBox AnchorSideTop.Side = asrBottom - AnchorSideBottom.Control = ExportButton + AnchorSideBottom.Control = PagesGroupBox + AnchorSideBottom.Side = asrBottom Left = 1 - Height = 23 - Top = 335 - Width = 73 + Height = 29 + Top = 384 + Width = 65 Anchors = [akLeft, akBottom] AutoSize = True BorderSpacing.Top = 3 BorderSpacing.Bottom = 6 Caption = 'Import ...' OnClick = ImportButtonClick - TabOrder = 4 + TabOrder = 3 end object ExportButton: TBitBtn - AnchorSideLeft.Control = PagesGroupBox - AnchorSideTop.Side = asrBottom + AnchorSideLeft.Control = ImportButton + AnchorSideLeft.Side = asrBottom + AnchorSideTop.Control = ImportButton + AnchorSideTop.Side = asrCenter AnchorSideRight.Side = asrBottom AnchorSideBottom.Control = PagesGroupBox AnchorSideBottom.Side = asrBottom - Left = 1 - Height = 23 - Top = 364 - Width = 73 - Anchors = [akLeft, akBottom] + Left = 78 + Height = 29 + Top = 384 + Width = 63 AutoSize = True - BorderSpacing.Left = 1 + BorderSpacing.Left = 12 BorderSpacing.Top = 6 BorderSpacing.Bottom = 6 Caption = 'Export ...' OnClick = ExportButtonClick - TabOrder = 5 + TabOrder = 4 end end object ComponentsGroupBox: TGroupBox - Left = 232 - Height = 411 + AnchorSideLeft.Control = Splitter1 + AnchorSideLeft.Side = asrBottom + AnchorSideRight.Control = Owner + AnchorSideRight.Side = asrBottom + AnchorSideBottom.Control = PagesGroupBox + AnchorSideBottom.Side = asrBottom + Left = 201 + Height = 468 Top = 0 - Width = 279 - Align = alClient - Anchors = [] + Width = 388 + Anchors = [akTop, akLeft, akRight, akBottom] + BorderSpacing.Left = 6 Caption = 'ComponentsGroupBox' - ClientHeight = 393 - ClientWidth = 275 + ClientHeight = 447 + ClientWidth = 384 TabOrder = 1 object ComponentsListView: TListView AnchorSideLeft.Control = ComponentsGroupBox @@ -204,9 +188,9 @@ object CompPaletteOptionsFrame: TCompPaletteOptionsFrame AnchorSideBottom.Control = ComponentsGroupBox AnchorSideBottom.Side = asrBottom Left = 1 - Height = 391 + Height = 445 Top = 1 - Width = 240 + Width = 349 Anchors = [akTop, akLeft, akRight, akBottom] BorderSpacing.Right = 5 BorderSpacing.Around = 1 @@ -254,7 +238,7 @@ object CompPaletteOptionsFrame: TCompPaletteOptionsFrame AnchorSideTop.Side = asrBottom AnchorSideRight.Control = ComponentsGroupBox AnchorSideRight.Side = asrBottom - Left = 247 + Left = 356 Height = 26 Top = 102 Width = 22 @@ -269,7 +253,7 @@ object CompPaletteOptionsFrame: TCompPaletteOptionsFrame AnchorSideLeft.Control = CompMoveUpBtn AnchorSideTop.Control = CompMoveUpBtn AnchorSideTop.Side = asrBottom - Left = 247 + Left = 356 Height = 26 Top = 135 Width = 22 @@ -281,24 +265,37 @@ object CompPaletteOptionsFrame: TCompPaletteOptionsFrame end end object Splitter1: TSplitter - Left = 227 - Height = 411 + AnchorSideLeft.Control = PagesGroupBox + AnchorSideLeft.Side = asrBottom + Left = 190 + Height = 468 Top = 0 Width = 5 - Anchors = [akLeft] + Align = alNone + Anchors = [] + end + object cbPaletteVisible: TCheckBox + AnchorSideTop.Side = asrBottom + Left = 1 + Height = 22 + Top = 0 + Width = 115 + BorderSpacing.Top = 6 + Caption = 'Palette is visible' + TabOrder = 3 end object ImportDialog: TOpenDialog - left = 152 - top = 376 + left = 168 + top = 432 end object ExportDialog: TSaveDialog - left = 192 - top = 376 + left = 200 + top = 432 end object PagesPopupMenu: TPopupMenu OnPopup = PagesPopupMenuPopup - left = 192 - top = 40 + left = 160 + top = 8 object RenameMenuItem: TMenuItem Caption = 'Rename' OnClick = RenameMenuItemClick diff --git a/ide/frames/componentpalette_options.pas b/ide/frames/componentpalette_options.pas index e28ef4dc93..9e43f26891 100644 --- a/ide/frames/componentpalette_options.pas +++ b/ide/frames/componentpalette_options.pas @@ -36,16 +36,15 @@ type TCompPaletteOptionsFrame = class(TAbstractIDEOptionsEditor) AddPageButton: TBitBtn; + cbPaletteVisible: TCheckBox; ImportButton: TBitBtn; ComponentsListView: TListView; CompMoveDownBtn: TSpeedButton; DeleteMenuItem: TMenuItem; RenameMenuItem: TMenuItem; PagesPopupMenu: TPopupMenu; - RecentLabel: TLabel; ExportButton: TBitBtn; ImportDividerBevel: TDividerBevel; - RecentButton: TButton; ImportDialog: TOpenDialog; PageMoveDownBtn: TSpeedButton; CompMoveUpBtn: TSpeedButton; @@ -117,6 +116,8 @@ type implementation +uses MainBar; + {$R *.lfm} { TCompPaletteOptionsFrame } @@ -147,6 +148,7 @@ end; procedure TCompPaletteOptionsFrame.Setup(ADialog: TAbstractOptionsEditorDialog); begin fDialog := ADialog; + cbPaletteVisible.Caption := lisCmpPaletteVisible; // Component pages PagesGroupBox.Caption := lisCmpPages; AddPageButton.Caption := lisBtnDlgAdd; @@ -185,9 +187,13 @@ begin end; procedure TCompPaletteOptionsFrame.ReadSettings(AOptions: TAbstractIDEOptions); +var + Opts: TCompPaletteOptions; begin - fLocalOptions.Assign((AOptions as TEnvironmentOptions).Desktop.ComponentPaletteOptions); - fLocalUserOrder.Options:=fLocalOptions; + Opts := (AOptions as TEnvironmentOptions).Desktop.ComponentPaletteOptions; + fLocalOptions.Assign(Opts); + fLocalUserOrder.Options := fLocalOptions; + cbPaletteVisible.Checked := Opts.Visible; ActualReadSettings; end; @@ -202,9 +208,15 @@ begin end; procedure TCompPaletteOptionsFrame.WriteSettings(AOptions: TAbstractIDEOptions); +var + Opts: TCompPaletteOptions; begin + Opts := (AOptions as TEnvironmentOptions).Desktop.ComponentPaletteOptions; + Opts.Visible := cbPaletteVisible.Checked; + MainIDEBar.DoSetViewComponentPalette(cbPaletteVisible.Checked); if not fConfigChanged then Exit; - ActualWriteSettings((AOptions as TEnvironmentOptions).Desktop.ComponentPaletteOptions); + ActualWriteSettings(Opts); + IDEComponentPalette.Update(True); IDEComponentPalette.IncChangeStamp; end; diff --git a/ide/lazarusidestrconsts.pas b/ide/lazarusidestrconsts.pas index 09be1a9671..815f57c701 100644 --- a/ide/lazarusidestrconsts.pas +++ b/ide/lazarusidestrconsts.pas @@ -4592,12 +4592,13 @@ resourcestring // components palette settings and list form lisCmpPages = 'Pages'; - lisCmpRestoreDefaults = '&Restore defaults'; - lisImportExport = 'Import / Export'; lisCmpLstComponents = 'Components'; + lisCmpPaletteVisible = 'Palette is &visible'; + lisCmpRestoreDefaults = '&Restore defaults'; lisCmpLstList = 'List'; lisCmpLstPalette = 'Palette'; lisCmpLstInheritance = 'Inheritance'; + lisImportExport = 'Import / Export'; lisSuccessfullyImported = 'Successfully imported from "%s".'; lisSuccessfullyExported = 'Successfully exported to "%s".'; diff --git a/ide/main.pp b/ide/main.pp index c7c1b5edff..91cf811299 100644 --- a/ide/main.pp +++ b/ide/main.pp @@ -4611,7 +4611,6 @@ procedure TMainIDE.DoOpenIDEOptions(AEditor: TAbstractIDEOptionsEditorClass; var IDEOptionsDialog: TIDEOptionsDialog; OptionsFilter: TIDEOptionsEditorFilter; - PaletteOpt: TCompPaletteOptionsFrame; i: Integer; begin IDEOptionsDialog := TIDEOptionsDialog.Create(nil); @@ -4641,10 +4640,6 @@ begin if IDEOptionsDialog.ShowModal = mrOk then begin IDEOptionsDialog.WriteAll(false); DebugLn(['TMainIDE.DoOpenIDEOptions: Options saved, updating Palette and TaskBar.']); - // Update component palette only when needed. - PaletteOpt := TCompPaletteOptionsFrame(IDEOptionsDialog.FindEditor(TCompPaletteOptionsFrame)); - if Assigned(PaletteOpt) and PaletteOpt.ConfigChanged then - IDEComponentPalette.Update(True); // Update TaskBarBehavior immediately. if EnvironmentOptions.Desktop.SingleTaskBarButton then Application.TaskBarBehavior := tbSingleButton diff --git a/ide/mainbar.pas b/ide/mainbar.pas index c3611e5f44..2f59632058 100644 --- a/ide/mainbar.pas +++ b/ide/mainbar.pas @@ -394,6 +394,7 @@ type procedure RefreshCoolbar; procedure SetMainIDEHeight; procedure DoSetMainIDEHeight(const AIDEIsMaximized: Boolean; ANewHeight: Integer = 0); + procedure DoSetViewComponentPalette(aVisible: Boolean); procedure DoToggleViewComponentPalette; procedure DoToggleViewIDESpeedButtons; procedure AllowCompilation(aAllow: Boolean); @@ -658,7 +659,7 @@ begin CoolBar := TCoolBar.Create(TheOwner); CoolBar.Parent := Self; - if EnvironmentOptions.Desktop.ComponentPaletteVisible then + if EnvironmentOptions.Desktop.ComponentPaletteOptions.Visible then begin CoolBar.Align := alLeft; CoolBar.Width := EnvironmentOptions.Desktop.IDECoolBarOptions.IDECoolBarWidth; @@ -680,7 +681,7 @@ begin ComponentPageControl := TPageControl.Create(TheOwner); ComponentPageControl.Name := 'ComponentPageControl'; ComponentPageControl.Align := alClient; - ComponentPageControl.Visible:=EnvironmentOptions.Desktop.ComponentPaletteVisible; + ComponentPageControl.Visible:=EnvironmentOptions.Desktop.ComponentPaletteOptions.Visible; ComponentPageControl.Parent := Self; end; @@ -759,7 +760,8 @@ begin end; end; - if EnvironmentOptions.Desktop.ComponentPaletteVisible and Assigned(ComponentPageControl.ActivePage) then + if EnvironmentOptions.Desktop.ComponentPaletteOptions.Visible + and Assigned(ComponentPageControl.ActivePage) then begin ComponentScrollBox := nil; for I := 0 to ComponentPageControl.ActivePage.ControlCount-1 do @@ -811,15 +813,13 @@ begin DoSetMainIDEHeight(WindowState = wsMaximized); end; -procedure TMainIDEBar.DoToggleViewComponentPalette; -var - ComponentPaletteVisible: Boolean; +procedure TMainIDEBar.DoSetViewComponentPalette(aVisible: Boolean); begin - ComponentPaletteVisible:=not ComponentPageControl.Visible; - itmViewComponentPalette.Checked:=ComponentPaletteVisible; - ComponentPageControl.Visible:=ComponentPaletteVisible; - EnvironmentOptions.Desktop.ComponentPaletteVisible:=ComponentPaletteVisible; - if ComponentPaletteVisible then + if aVisible = ComponentPageControl.Visible then Exit; + ComponentPageControl.Visible := aVisible; + itmViewComponentPalette.Checked := aVisible; + EnvironmentOptions.Desktop.ComponentPaletteOptions.Visible := aVisible; + if aVisible then begin if CoolBar.Align = alClient then begin @@ -832,13 +832,18 @@ begin end else CoolBar.Align := alClient; - MainSplitter.Visible := Coolbar.Visible and ComponentPageControl.Visible; + MainSplitter.Visible := Coolbar.Visible and aVisible; - if ComponentPaletteVisible then//when showing component palette, it must be visible to calculate it correctly + if aVisible then//when showing component palette, it must be visible to calculate it correctly DoSetMainIDEHeight(WindowState = wsMaximized, 55);//it will cause the IDE to flicker, but it's better than to have wrongly calculated IDE height SetMainIDEHeight; end; +procedure TMainIDEBar.DoToggleViewComponentPalette; +begin + DoSetViewComponentPalette(not ComponentPageControl.Visible); +end; + procedure TMainIDEBar.DoToggleViewIDESpeedButtons; var SpeedButtonsVisible: boolean; diff --git a/ide/mainbase.pas b/ide/mainbase.pas index f4879a283a..7635de0d0a 100644 --- a/ide/mainbase.pas +++ b/ide/mainbase.pas @@ -783,7 +783,7 @@ begin {$ENDIF} end; CreateMenuItem(ParentMI,itmViewComponentPalette,'itmViewComponentPalette',lisMenuViewComponentPalette, '', - true, EnvironmentOptions.Desktop.ComponentPaletteVisible); + true, EnvironmentOptions.Desktop.ComponentPaletteOptions.Visible); CreateMenuItem(ParentMI,itmViewIDESpeedButtons,'itmViewIDESpeedButtons',lisMenuViewIDESpeedButtons, '', true, EnvironmentOptions.Desktop.IDECoolBarOptions.IDECoolBarVisible); end;