mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-13 05:44:11 +02:00
Keep bookmark folders open
This commit is contained in:
parent
bc286885dc
commit
f96a1e4ea8
2 changed files with 72 additions and 31 deletions
|
@ -86,12 +86,12 @@ namespace IDE
|
||||||
for (var bookmark in mBookmarkList)
|
for (var bookmark in mBookmarkList)
|
||||||
bookmark.mIsDisabled = value;
|
bookmark.mIsDisabled = value;
|
||||||
|
|
||||||
gApp.mBookmarksPanel.mBookmarksDirty = true;
|
gApp.mBookmarkManager.mBookmarksChangedDelegate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Adds the given bookmark to this folder. If needed, removes it from its old folder.
|
/// Adds the given bookmark to this folder. If needed, removes it from its old folder.
|
||||||
public void AddBookmark(Bookmark bookmark)
|
internal void AddBookmark(Bookmark bookmark)
|
||||||
{
|
{
|
||||||
if (bookmark.mFolder != null)
|
if (bookmark.mFolder != null)
|
||||||
{
|
{
|
||||||
|
@ -99,8 +99,6 @@ namespace IDE
|
||||||
}
|
}
|
||||||
mBookmarkList.Add(bookmark);
|
mBookmarkList.Add(bookmark);
|
||||||
bookmark.mFolder = this;
|
bookmark.mFolder = this;
|
||||||
|
|
||||||
//gApp.mBookmarksPanel.mBookmarksDirty = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,6 +107,8 @@ namespace IDE
|
||||||
public BookmarkFolder mRootFolder = new .();
|
public BookmarkFolder mRootFolder = new .();
|
||||||
public List<BookmarkFolder> mBookmarkFolders = new .() {mRootFolder} ~ DeleteContainerAndItems!(_);
|
public List<BookmarkFolder> mBookmarkFolders = new .() {mRootFolder} ~ DeleteContainerAndItems!(_);
|
||||||
|
|
||||||
|
public Event<Action> mBookmarksChangedDelegate ~ _.Dispose();
|
||||||
|
|
||||||
private int mBookmarkCount;
|
private int mBookmarkCount;
|
||||||
|
|
||||||
/// Index of the folder that was navigated to last
|
/// Index of the folder that was navigated to last
|
||||||
|
@ -141,7 +141,7 @@ namespace IDE
|
||||||
folder.IsDisabled = value;
|
folder.IsDisabled = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
gApp.mBookmarksPanel.mBookmarksDirty = true;
|
mBookmarksChangedDelegate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -163,7 +163,7 @@ namespace IDE
|
||||||
|
|
||||||
mBookmarkFolders.Add(folder);
|
mBookmarkFolders.Add(folder);
|
||||||
|
|
||||||
gApp.mBookmarksPanel.mBookmarksDirty = true;
|
mBookmarksChangedDelegate();
|
||||||
|
|
||||||
return folder;
|
return folder;
|
||||||
}
|
}
|
||||||
|
@ -187,7 +187,7 @@ namespace IDE
|
||||||
if (mBookmarkIdx >= mBookmarkFolders[mFolderIdx].mBookmarkList.Count)
|
if (mBookmarkIdx >= mBookmarkFolders[mFolderIdx].mBookmarkList.Count)
|
||||||
mBookmarkIdx = (int32)mBookmarkFolders[mFolderIdx].mBookmarkList.Count - 1;
|
mBookmarkIdx = (int32)mBookmarkFolders[mFolderIdx].mBookmarkList.Count - 1;
|
||||||
|
|
||||||
gApp.mBookmarksPanel.mBookmarksDirty = true;
|
mBookmarksChangedDelegate();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Bookmark CreateBookmark(String fileName, int wantLineNum, int wantColumn, bool isDisabled = false, String title = null, BookmarkFolder folder = null)
|
public Bookmark CreateBookmark(String fileName, int wantLineNum, int wantColumn, bool isDisabled = false, String title = null, BookmarkFolder folder = null)
|
||||||
|
@ -212,11 +212,11 @@ namespace IDE
|
||||||
|
|
||||||
bookmark.mIsDisabled = isDisabled;
|
bookmark.mIsDisabled = isDisabled;
|
||||||
|
|
||||||
folder.AddBookmark(bookmark);
|
folder.[Friend]AddBookmark(bookmark);
|
||||||
|
|
||||||
gApp.mDebugger.mBreakpointsChangedDelegate();
|
gApp.mDebugger.mBreakpointsChangedDelegate();
|
||||||
|
|
||||||
gApp.mBookmarksPanel.mBookmarksDirty = true;
|
mBookmarksChangedDelegate();
|
||||||
|
|
||||||
mBookmarkCount++;
|
mBookmarkCount++;
|
||||||
|
|
||||||
|
@ -250,7 +250,7 @@ namespace IDE
|
||||||
|
|
||||||
FixupIndices();
|
FixupIndices();
|
||||||
|
|
||||||
gApp.mBookmarksPanel.mBookmarksDirty = true;
|
mBookmarksChangedDelegate();
|
||||||
}
|
}
|
||||||
|
|
||||||
enum Placement
|
enum Placement
|
||||||
|
@ -283,7 +283,7 @@ namespace IDE
|
||||||
|
|
||||||
FixupIndices();
|
FixupIndices();
|
||||||
|
|
||||||
gApp.mBookmarksPanel.mBookmarksDirty = true;
|
mBookmarksChangedDelegate();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Make sure that the bookmark and folder indices are valid.
|
/// Make sure that the bookmark and folder indices are valid.
|
||||||
|
@ -310,7 +310,7 @@ namespace IDE
|
||||||
gApp.mDebugger.mBreakpointsChangedDelegate();
|
gApp.mDebugger.mBreakpointsChangedDelegate();
|
||||||
bookmark.Kill();
|
bookmark.Kill();
|
||||||
|
|
||||||
gApp.mBookmarksPanel.mBookmarksDirty = true;
|
mBookmarksChangedDelegate();
|
||||||
|
|
||||||
mBookmarkCount--;
|
mBookmarkCount--;
|
||||||
}
|
}
|
||||||
|
@ -332,7 +332,7 @@ namespace IDE
|
||||||
mBookmarkIdx = 0;
|
mBookmarkIdx = 0;
|
||||||
gApp.mDebugger.mBreakpointsChangedDelegate();
|
gApp.mDebugger.mBreakpointsChangedDelegate();
|
||||||
|
|
||||||
gApp.mBookmarksPanel.mBookmarksDirty = true;
|
mBookmarksChangedDelegate();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void PrevBookmark(bool currentFolderOnly = false)
|
public void PrevBookmark(bool currentFolderOnly = false)
|
||||||
|
|
|
@ -136,6 +136,8 @@ namespace IDE.ui
|
||||||
mBookmarksListView.mOnKeyDown.Add(new => BookmarksLV_OnKeyDown);
|
mBookmarksListView.mOnKeyDown.Add(new => BookmarksLV_OnKeyDown);
|
||||||
|
|
||||||
AddWidget(mBookmarksListView);
|
AddWidget(mBookmarksListView);
|
||||||
|
|
||||||
|
gApp.mBookmarkManager.mBookmarksChangedDelegate.Add(new => BookmarksChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void BookmarksLV_OnKeyDown(KeyDownEvent event)
|
private void BookmarksLV_OnKeyDown(KeyDownEvent event)
|
||||||
|
@ -384,7 +386,13 @@ namespace IDE.ui
|
||||||
mBookmarksListView.Resize(0, buttonHeight, width, Math.Max(mHeight - buttonHeight, 0));
|
mBookmarksListView.Resize(0, buttonHeight, width, Math.Max(mHeight - buttonHeight, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool mBookmarksDirty;
|
private bool mBookmarksDirty;
|
||||||
|
|
||||||
|
/// Marks the bookmarks list view as dirty so that it will be rebuild in the next update.
|
||||||
|
private void BookmarksChanged()
|
||||||
|
{
|
||||||
|
mBookmarksDirty = true;
|
||||||
|
}
|
||||||
|
|
||||||
public override void Update()
|
public override void Update()
|
||||||
{
|
{
|
||||||
|
@ -400,27 +408,44 @@ namespace IDE.ui
|
||||||
base.Update();
|
base.Update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Clears the Panel (does NOT clear the actual bookmarks).
|
||||||
public void Clear()
|
public void Clear()
|
||||||
{
|
{
|
||||||
var root = mBookmarksListView.GetRoot();
|
mBookmarksListView.GetRoot().Clear();
|
||||||
|
|
||||||
root.Clear();
|
|
||||||
|
|
||||||
mBookmarksDirty = true;
|
mBookmarksDirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Shows a tooltip with the given text for the specified widget if the widget is hovered.
|
||||||
private void ShowTooltip(Widget widget, String text)
|
private void ShowTooltip(Widget widget, String text)
|
||||||
{
|
{
|
||||||
Point mousePoint;
|
if (DarkTooltipManager.CheckMouseover(widget, 20, let mousePoint))
|
||||||
if (DarkTooltipManager.CheckMouseover(widget, 20, out mousePoint))
|
|
||||||
{
|
{
|
||||||
DarkTooltipManager.ShowTooltip(text, widget, mousePoint.x, mousePoint.y);
|
DarkTooltipManager.ShowTooltip(text, widget, mousePoint.x, mousePoint.y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Rebuilds the list view.
|
||||||
private void UpdateBookmarks()
|
private void UpdateBookmarks()
|
||||||
{
|
{
|
||||||
var root = mBookmarksListView.GetRoot();
|
var root = (BookmarksListViewItem)mBookmarksListView.GetRoot();
|
||||||
|
|
||||||
|
var openFolders = scope List<BookmarkFolder>();
|
||||||
|
|
||||||
|
if (root.mChildItems != null)
|
||||||
|
{
|
||||||
|
// Find all open Folders so that we can open them again after rebuilding the list view
|
||||||
|
for (var child in root.mChildItems)
|
||||||
|
{
|
||||||
|
if (!child.IsOpen)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (var bookmarkFolder = ((BookmarksListViewItem)child).RefObject as BookmarkFolder)
|
||||||
|
{
|
||||||
|
openFolders.Add(bookmarkFolder);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
root.Clear();
|
root.Clear();
|
||||||
|
|
||||||
|
@ -432,9 +457,7 @@ namespace IDE.ui
|
||||||
|
|
||||||
if (!isRoot)
|
if (!isRoot)
|
||||||
{
|
{
|
||||||
FolderItem = (BookmarksListViewItem)root.CreateChildItem();
|
FolderItem = AddFolderToListView(root, folder);
|
||||||
|
|
||||||
SetupListViewItemFolder(FolderItem, folder);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -443,19 +466,31 @@ namespace IDE.ui
|
||||||
|
|
||||||
for (Bookmark bookmark in folder.mBookmarkList)
|
for (Bookmark bookmark in folder.mBookmarkList)
|
||||||
{
|
{
|
||||||
var listViewItem = (BookmarksListViewItem)(FolderItem.CreateChildItem());
|
AddBookmarkToListView(FolderItem, bookmark);
|
||||||
SetupListViewItem(listViewItem, bookmark);
|
}
|
||||||
|
|
||||||
|
if (!isRoot)
|
||||||
|
{
|
||||||
|
// Open folder if it was open before recreating the list view.
|
||||||
|
int idx = openFolders.IndexOf(folder);
|
||||||
|
if (idx >= 0)
|
||||||
|
{
|
||||||
|
openFolders.RemoveAtFast(idx);
|
||||||
|
FolderItem.Open(true, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mBookmarksDirty = false;
|
mBookmarksDirty = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetupListViewItemFolder(BookmarksListViewItem listViewItem, BookmarkFolder folder)
|
/// Creates a new ListViewItem for the given folder.
|
||||||
|
private BookmarksListViewItem AddFolderToListView(BookmarksListViewItem parent, BookmarkFolder folder)
|
||||||
{
|
{
|
||||||
listViewItem.AllowDragging = true;
|
var listViewItem = (BookmarksListViewItem)parent.CreateChildItem();
|
||||||
|
|
||||||
listViewItem.RefObject = folder;
|
listViewItem.RefObject = folder;
|
||||||
|
listViewItem.AllowDragging = true;
|
||||||
|
|
||||||
var subViewItem = (DarkListViewItem)listViewItem.GetOrCreateSubItem(0);
|
var subViewItem = (DarkListViewItem)listViewItem.GetOrCreateSubItem(0);
|
||||||
|
|
||||||
|
@ -470,13 +505,17 @@ namespace IDE.ui
|
||||||
|
|
||||||
subViewItem.Label = folder.mTitle;
|
subViewItem.Label = folder.mTitle;
|
||||||
subViewItem.Resize(GS!(22), 0, 0, 0);
|
subViewItem.Resize(GS!(22), 0, 0, 0);
|
||||||
|
|
||||||
|
return listViewItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetupListViewItem(BookmarksListViewItem listViewItem, Bookmark bookmark)
|
/// Creates a new ListViewItem for the given bookmark.
|
||||||
|
private BookmarksListViewItem AddBookmarkToListView(BookmarksListViewItem parent, Bookmark bookmark)
|
||||||
{
|
{
|
||||||
listViewItem.AllowDragging = true;
|
var listViewItem = (BookmarksListViewItem)(parent.CreateChildItem());
|
||||||
|
|
||||||
listViewItem.RefObject = bookmark;
|
listViewItem.RefObject = bookmark;
|
||||||
|
listViewItem.AllowDragging = true;
|
||||||
|
|
||||||
var subViewItem = (DarkListViewItem)listViewItem.GetOrCreateSubItem(0);
|
var subViewItem = (DarkListViewItem)listViewItem.GetOrCreateSubItem(0);
|
||||||
|
|
||||||
|
@ -500,6 +539,8 @@ namespace IDE.ui
|
||||||
|
|
||||||
subViewItem = (DarkListViewItem)listViewItem.GetOrCreateSubItem(2);
|
subViewItem = (DarkListViewItem)listViewItem.GetOrCreateSubItem(2);
|
||||||
subViewItem.Label = listViewItem.BookmarkLine;
|
subViewItem.Label = listViewItem.BookmarkLine;
|
||||||
|
|
||||||
|
return listViewItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void KeyDown(KeyCode keyCode, bool isRepeat)
|
public override void KeyDown(KeyCode keyCode, bool isRepeat)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue