From df4773f6ce85f84548bd2980e51f55d30633bdeb Mon Sep 17 00:00:00 2001 From: Basile Burg Date: Sun, 13 Sep 2020 00:19:10 +0200 Subject: [PATCH] projinspect, move list of configs to a combo box --- CHANGELOG.md | 4 ++ src/u_projinspect.lfm | 25 ++++++++--- src/u_projinspect.pas | 99 +++++++++++++++---------------------------- 3 files changed, 59 insertions(+), 69 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 30f6b42e..d4ad707b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ - Project inspector: moved the list of configuration to a combo box over the file tree. +## Bugs fixed + +- GDB commander, editor: bad expression returned when using mouse motion to get value of an expression within square brackets. + # v3.9.7 ## Enhancements diff --git a/src/u_projinspect.lfm b/src/u_projinspect.lfm index 928c9269..7ed3cd5d 100644 --- a/src/u_projinspect.lfm +++ b/src/u_projinspect.lfm @@ -23,8 +23,8 @@ inherited ProjectInspectWidget: TProjectInspectWidget PopupMenu = nil object Tree: TTreeView[0] Left = 2 - Height = 218 - Top = 2 + Height = 184 + Top = 36 Width = 420 Align = alClient AutoExpand = True @@ -43,11 +43,26 @@ inherited ProjectInspectWidget: TProjectInspectWidget OnSelectionChanged = TreeSelectionChanged Options = [tvoAutoExpand, tvoAutoItemHeight, tvoKeepCollapsedNodes, tvoReadOnly, tvoRightClickSelect, tvoShowButtons, tvoShowLines, tvoThemedDraw] Items.Data = { - F9FFFFFF020002000000000000000000000000000000FFFFFFFF000000000000 - 0000000C000000536F757263652066696C6573010000000100000001000000FF - FFFFFF0000000000000000000E000000436F6E66696775726174696F6E73 + F9FFFFFF020001000000000000000000000000000000FFFFFFFF000000000000 + 0000000C000000536F757263652066696C6573 } end + object selConf: TComboBox[1] + Left = 4 + Height = 30 + Hint = 'select the active configuaration' + Top = 2 + Width = 416 + Align = alTop + BorderSpacing.Left = 4 + BorderSpacing.Top = 2 + BorderSpacing.Right = 4 + BorderSpacing.Bottom = 4 + ItemHeight = 0 + OnChange = selConfChange + Style = csDropDownList + TabOrder = 1 + end end inherited toolbar: TDexedToolBar Width = 416 diff --git a/src/u_projinspect.pas b/src/u_projinspect.pas index c37fbd7f..fe2be60e 100644 --- a/src/u_projinspect.pas +++ b/src/u_projinspect.pas @@ -6,9 +6,9 @@ interface uses Classes, SysUtils, TreeFilterEdit, Forms, Controls, Graphics, actnlist, - Dialogs, ExtCtrls, ComCtrls, Menus, Buttons, lcltype, u_ceproject, u_interfaces, - u_common, u_widget, u_observer, u_dialogs, u_sharedres, u_dsgncontrols, - u_dubproject, u_synmemo, u_stringrange, u_writableComponent; + Dialogs, ExtCtrls, ComCtrls, Menus, Buttons, lcltype, StdCtrls, u_ceproject, + u_interfaces, u_common, u_widget, u_observer, u_dialogs, u_sharedres, + u_dsgncontrols, u_dubproject, u_synmemo, u_stringrange, u_writableComponent; type @@ -28,6 +28,7 @@ type btnRemFile: TDexedToolButton; btnRemFold: TDexedToolButton; btnTree: TDexedToolButton; + selConf: TComboBox; Tree: TTreeView; TreeFilterEdit1: TTreeFilterEdit; procedure btnAddFileClick(Sender: TObject); @@ -37,6 +38,7 @@ type procedure btnTreeClick(Sender: TObject); procedure btnReloadClick(Sender: TObject); procedure FormDropFiles(Sender: TObject; const fnames: array of String); + procedure selConfChange(Sender: TObject); procedure toolbarResize(Sender: TObject); procedure TreeClick(Sender: TObject); procedure TreeDeletion(Sender: TObject; Node: TTreeNode); @@ -49,10 +51,9 @@ type procedure setToolBarFlat(value: boolean); override; private fActOpenFile: TAction; - fActSelConf: TAction; fActBuildConf: TAction; fProj: ICommonProject; - fFileNode, fConfNode: TTreeNode; + fFileNode: TTreeNode; fLastFileOrFolder: string; fSymStringExpander: ISymStringExpander; fImages: TImageList; @@ -100,12 +101,8 @@ begin fSymStringExpander:= getSymStringExpander; fActOpenFile := TAction.Create(self); - fActOpenFile.Caption := 'Open file in editor'; + fActOpenFile.Caption := 'Open file(s) in editor'; fActOpenFile.OnExecute := @actOpenFileExecute; - fActSelConf := TAction.Create(self); - fActSelConf.Caption := 'Select configuration'; - fActSelConf.OnExecute := @actOpenFileExecute; - fActSelConf.OnUpdate := @actUpdate; fActBuildConf:= TAction.Create(self); fActBuildConf.Caption := 'Build configuration'; fActBuildConf.OnExecute := @actBuildExecute; @@ -158,7 +155,6 @@ begin Tree.OnDblClick := @TreeDblClick; fFileNode := Tree.Items[0]; - fConfNode := Tree.Items[1]; Tree.Images := fImages; Tree.PopupMenu := contextMenu; @@ -218,15 +214,14 @@ end; function TProjectInspectWidget.contextActionCount: integer; begin - exit(3); + exit(2); end; function TProjectInspectWidget.contextAction(index: integer): TAction; begin case index of 0: exit(fActOpenFile); - 1: exit(fActSelConf); - 2: exit(fActBuildConf); + 1: exit(fActBuildConf); else exit(nil); end; end; @@ -362,6 +357,8 @@ begin if Tree.Selected.isAssigned then begin Tree.MultiSelect := Tree.Selected.Parent = fFileNode; + if Tree.Selected.isNotAssigned() then + exit; if not (Tree.Selected.Parent = fFileNode) then begin Tree.MultiSelect := false; @@ -396,43 +393,32 @@ end; procedure TProjectInspectWidget.TreeDblClick(sender: TObject); var - fname: string; + f: string; i: integer; begin if fProj.isNotAssigned or Tree.Selected.isNotAssigned then exit; - - if Tree.Selected.Parent <> fConfNode then + for i := 0 to Tree.SelectionCount - 1 do + if Tree.Selections[i].Data.isAssigned() then begin - if Tree.Selected.Data.isAssigned then - begin - fname := PString(Tree.Selected.Data)^; - if isEditable(fname.extractFileExt) and fname.fileExists then - getMultiDocHandler.openDocument(fname); - end; - end - else - begin - i := Tree.Selected.Index; - fProj.setActiveConfigurationIndex(i); - beginDelayedUpdate; + f := PString(Tree.Selections[i].Data)^; + if isEditable(f.extractFileExt) and f.fileExists then + getMultiDocHandler.openDocument(f); end; + Tree.Selected := nil; end; procedure TProjectInspectWidget.actUpdate(sender: TObject); begin - fActSelConf.Enabled := false; fActOpenFile.Enabled := false; fActBuildConf.Enabled:= false; if Tree.Selected.isNotAssigned then exit; - fActSelConf.Enabled := Tree.Selected.Parent = fConfNode; - fActBuildConf.Enabled := Tree.Selected.Parent = fConfNode; + fActBuildConf.Enabled := true; fActOpenFile.Enabled := Tree.Selected.ImageIndex = 2; end; -procedure TProjectInspectWidget.DetectNewDubSources(const document: TDexedMemo - ); +procedure TProjectInspectWidget.DetectNewDubSources(const document: TDexedMemo); begin if fProj.isNotAssigned or (fProj.getFormat <> pfDUB) then exit; @@ -634,6 +620,13 @@ begin end; end; +procedure TProjectInspectWidget.selConfChange(Sender: TObject); +begin + if fProj.isNotAssigned or selConf.ItemIndex.equals(-1) or selConf.Items.Count.equals(0) then + exit; + fProj.setActiveConfigurationIndex(selConf.ItemIndex); +end; + procedure TProjectInspectWidget.toolbarResize(Sender: TObject); begin TreeFilterEdit1.Width := toolbar.Width - TreeFilterEdit1.Left - TreeFilterEdit1.BorderSpacing.Around; @@ -656,7 +649,6 @@ var begin if Tree.Selected.isAssigned then sel := Tree.Selected.GetTextPath; - fConfNode.DeleteChildren; fFileNode.DeleteChildren; if fProj.isNotAssigned then @@ -705,36 +697,15 @@ begin end; end; end; - - - j := fProj.getActiveConfigurationIndex; - for i := 0 to fProj.configurationCount-1 do - begin - conf := fProj.configurationName(i); - if i = j then - conf += ' (active)'; - itm := Tree.Items.AddChild(fConfNode, conf); - if i = j then - begin - itm.ImageIndex := 4; - itm.SelectedIndex:= 4; - end - else - begin - itm.ImageIndex := 3; - itm.SelectedIndex:= 3; - end; - end; - if sel.isNotEmpty then - begin - itm := Tree.Items.FindNodeWithTextPath(sel); - if itm.isAssigned then - begin - itm.Selected := true; - itm.MakeVisible; - end; - end; Tree.EndUpdate; + + selConf.Items.BeginUpdate(); + j := fProj.getActiveConfigurationIndex; + selConf.Items.Clear; + for i := 0 to fProj.configurationCount-1 do + selConf.Items.Add(fProj.configurationName(i)); + selConf.ItemIndex := j; + selConf.Items.EndUpdate(); end; {$ENDREGION --------------------------------------------------------------------}