1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-11 04:52:21 +02:00

Improved ListView cursor key handling, removed debug NOPs

This commit is contained in:
Brian Fiete 2019-09-28 12:15:36 -07:00
parent 959da9884c
commit 987adaec5c
26 changed files with 87 additions and 211 deletions

View file

@ -166,6 +166,14 @@ namespace Beefy.theme.dark
}
}
public override bool IsOpen
{
get
{
return (mOpenButton != null) && (mOpenButton.mIsOpen);
}
}
public this()
{

View file

@ -40,7 +40,7 @@ namespace Beefy.widgets
virtual public StringView Label
{
get { return (mLabel != null) ? mLabel : default; }
set { String.NewOrSet!(mLabel, value);}
set { String.NewOrSet!(mLabel, value); }
}
virtual public IDrawable IconImage { get { return mIconImage; } set { mIconImage = value; } }
virtual public uint32 IconImageColor { get { return mIconImageColor; } set { mIconImageColor = value; } }
@ -103,6 +103,14 @@ namespace Beefy.widgets
}
}
public virtual bool IsOpen
{
get
{
return (mChildItems != null) && (mChildItems.Count > 0) && (mChildAreaHeight > 0);
}
}
public virtual float LabelX { get { return 0; } }
public virtual float LabelWidth { get { return mWidth; } }
@ -141,17 +149,20 @@ namespace Beefy.widgets
}
}
public void WithSelectedItems(Action<ListViewItem> func, bool skipSelectedChildrenOnSelectedItems = false)
public void WithSelectedItems(Action<ListViewItem> func, bool skipSelectedChildrenOnSelectedItems = false, bool skipClosed = false)
{
bool selfSelected = Selected;
if (selfSelected)
func(this);
if ((mChildItems != null) && ((!skipSelectedChildrenOnSelectedItems) || (!selfSelected)))
{
if ((!skipClosed) || (mParentItem == null) || (IsOpen))
{
for (ListViewItem child in mChildItems)
{
child.WithSelectedItems(func, skipSelectedChildrenOnSelectedItems);
child.WithSelectedItems(func, skipSelectedChildrenOnSelectedItems, skipClosed);
}
}
}
}
@ -243,8 +254,8 @@ namespace Beefy.widgets
{
defer { prevItem = checkItem; }
if (selectEndElement != null)
return;
/*if (selectEndElement != null)
return;*/
if (checkItem == focusedItem)
{
@ -263,15 +274,20 @@ namespace Beefy.widgets
if (!checkItem.Selected)
{
if (spanStart == focusedItem)
{
selectEndElement = prevItem;
}
spanStart = null;
}
}
else if (spanStart == null)
{
if (checkItem.Selected)
{
spanStart = checkItem;
}
}
});
focusedItem.Focused = false;
@ -757,16 +773,22 @@ namespace Beefy.widgets
mListSizeDirty = true;
}
public void EnsureItemVisible(ListViewItem item, bool centerView)
public enum VisibleKind
{
WasVisible,
Scrolled
}
public VisibleKind EnsureItemVisible(ListViewItem item, bool centerView)
{
if (mVertScrollbar == null)
return;
return .WasVisible;
if (mListSizeDirty)
UpdateListSize();
if (mScrollContentContainer.mHeight <= 0)
return;
return .WasVisible;
float aX;
float aY;
@ -784,6 +806,7 @@ namespace Beefy.widgets
scrollPos = (float)Math.Round(scrollPos / lineHeight) * lineHeight;
}
VertScrollTo(scrollPos);
return .Scrolled;
}
else if (aY + lineHeight + mBottomInset >= mVertPos.mDest + mScrollContentContainer.mHeight)
{
@ -795,7 +818,9 @@ namespace Beefy.widgets
scrollPos = (float)Math.Round(scrollPos / lineHeight) * lineHeight;
}
VertScrollTo(scrollPos);
return .Scrolled;
}
return .WasVisible;
}
ListViewItem FindClosestItemAtYPosition(ListViewItem parentItem, float y, bool addHeight)
@ -855,6 +880,8 @@ namespace Beefy.widgets
newSelection = newSelection.mChildItems[newSelection.mChildItems.Count - 1];
}
case KeyCode.PageUp:
selectedItem.SelfToOtherTranslate(mScrollContent, 0, 0, var absX, var absY);
int32 numIterations = (int32)(mScrollContentContainer.mHeight / selectedItem.mSelfHeight);
for (int32 i = 0; i < numIterations; i++)
KeyDown(KeyCode.Up, false);
@ -876,7 +903,7 @@ namespace Beefy.widgets
}
triedMove = true;
case KeyCode.Down:
if ((selectedItem.mChildItems != null) && (selectedItem.mChildItems.Count > 0) && (selectedItem.mChildAreaHeight > 0))
if (selectedItem.IsOpen)
newSelection = selectedItem.mChildItems[0];
else
{
@ -920,7 +947,8 @@ namespace Beefy.widgets
if (newSelection != null)
{
mRoot.SelectItem(newSelection, isDoingSpanSelection);
EnsureItemVisible(newSelection, false);
if (EnsureItemVisible(newSelection, false) == .Scrolled)
newSelection.mParent.UpdateAll(); // Update virtual list
}
else if ((triedMove) && (!isDoingSpanSelection) && (firstSelectedItem != null))
mRoot.SelectItemExclusively(firstSelectedItem);

View file

@ -23,15 +23,8 @@ namespace Beefy.widgets
public delegate void RemovedFromParentHandler(Widget widget, Widget prevParent, WidgetWindow widgetWindow);
public delegate void AddedToParentHandler(Widget widget);
public class Widget : ILeakIdentifiable
public class Widget
{
static int32 sIdx;
public int32 mIdx = sIdx++;
public void ToLeakString(String str)
{
str.AppendF("Idx:{0}", mIdx);
}
public class TransformData
{
public float a;

View file

@ -719,19 +719,6 @@ namespace Beefy.widgets
public override void MouseLeave()
{
/*if (mTitle == "Tooltip")
{
NOP!();
}
Debug.WriteLine("MouseLeave {0}", this);*/
// This line breaks the ability to drag a tab outside the window. Why did we have it?
/*if (sMouseInsideWindow == this)
return;*/
//Debug.WriteLine("MouseLeave {0}", this);
if (sMouseInsideWindow == this)
{
sMouseInsideWindow = null;

View file

@ -166,11 +166,6 @@ namespace System.Reflection
/*if (type.IsStruct)
return &value;*/
if (type.IsStruct)
{
NOP!();
}
if (type.IsBoxed)
return ((uint8*)(void*)value) + type.mMemberDataOffset;
return ((uint8*)(void*)value);

View file

@ -115,11 +115,6 @@ namespace System {
// there is a chance that the internal ConvertTime calls will throw since 'source' won't be reference equal to the new TimeZoneInfo.Local.
//
public ~this()
{
NOP!();
}
#pragma warning disable 0420
class CachedData
{

View file

@ -21,11 +21,6 @@ namespace IDE
{
Debug.Assert(Thread.CurrentThread == IDEApp.sApp.mMainThread);
/*if (gApp.mMainWindow.IsKeyDown(.Control))
{
NOP!();
}*/
Debug.Assert(mOnThreadDone == null);
//mBfSystem.PerfZoneStart("BfCompiler.ThreadStart");

View file

@ -179,11 +179,6 @@ namespace IDE.Compiler
{
BfCompiler_Delete(mNativeBfCompiler);
mNativeBfCompiler = null;
if (mCommandQueue.Count > 0)
{
NOP!();
}
}
public bool Compile(BfPassInstance passInstance, String outputDirectory)
@ -556,10 +551,6 @@ namespace IDE.Compiler
{
if ([Friend]mThreadWorker.mThreadRunning)
{
/*if (gApp.mMainWindow.IsKeyDown(.Control))
{
NOP!();
}*/
if (mNativeBfCompiler != null)
BfCompiler_Cancel(mNativeBfCompiler);
}

View file

@ -89,11 +89,6 @@ namespace IDE.Compiler
mIsDisposed = true;
BfPassInstance_Delete(mNativeBfPassInstance);
mNativeBfPassInstance = null;
if (mFailed)
{
NOP!();
}
}
public bool PopOutString(String outStr)

View file

@ -52,11 +52,6 @@ namespace IDE.Compiler
public void QueueDeferredResolveAll()
{
/*if (gApp.mMainWindow.IsKeyDown(.Control))
{
NOP!();
}*/
mResolveAllWait = 2;
}
@ -134,11 +129,6 @@ namespace IDE.Compiler
public void QueueResolveCommand()
{
/*if (gApp.mMainWindow.IsKeyDown(.Control))
{
NOP!();
}*/
ResolveAllCommand command = new ResolveAllCommand();
QueueCommand(command);
}

View file

@ -480,10 +480,6 @@ namespace IDE.Debugger
{
str.Append(mSymbol);
}
else
{
NOP!();
}
}
public void ToString_HitCount(String str)

View file

@ -361,7 +361,6 @@ namespace IDE
public ~this()
{
NOP!();
}
}
@ -5380,10 +5379,6 @@ namespace IDE
if (createEditData)
{
editData = new FileEditData();
if (filePath.EndsWith("main.cs"))
{
NOP!();
}
editData.mFilePath = new String(filePath);
mFileEditData.Add(new String(fixedFilePath), editData);
}
@ -10179,11 +10174,6 @@ namespace IDE
delete pendingHandler;
}
if (expressionFlags != .None)
{
NOP!();
}
mIsImmediateDebugExprEval = false;
String evalStr = scope String();

View file

@ -75,11 +75,6 @@ namespace IDE
Windows.DisconnectNamedPipe();
}*/
if (lastError != 536)
{
NOP!();
}
if ((lastError != Windows.ERROR_PIPE_CONNECTED) && (lastError != Windows.ERROR_NO_DATA))
return;
}

View file

@ -1072,10 +1072,6 @@ namespace IDE
public ~this()
{
if ((int)(void*)this & 0xFFFF == (int)0x6180UL)
{
NOP!();
}
}
}

View file

@ -283,7 +283,6 @@ namespace IDE
public this()
{
NOP!();
}
public void Deref()
@ -294,7 +293,6 @@ namespace IDE
public ~this()
{
NOP!();
}
}

View file

@ -409,11 +409,6 @@ namespace IDE.ui
let dispWidth = g.mFont.GetWidth(selectedEntry.mEntryDisplay) + GS!(24);
float width = mWidth - GS!(16) - mAutoCompleteListWidget.mRightBoxAdjust;
if (gApp.mMainWindow.IsKeyDown(.Alt))
{
NOP!();
}
if (mAutoCompleteListWidget.mVertScrollbar != null)
width -= GS!(18);
width = Math.Max(dispWidth, width);
@ -1651,11 +1646,6 @@ namespace IDE.ui
gApp.mAutoCompletePanel.FinishBind();
SetIgnoreMove(false);
if (changedAfterInfo)
{
NOP!();
}
if ((mAutoCompleteListWidget != null) && (!mAutoCompleteListWidget.mIsInitted))
mAutoCompleteListWidget.Init();
if ((mInvokeWidget != null) && (!mInvokeWidget.mIsInitted))

View file

@ -28,7 +28,6 @@ namespace IDE.ui
public ~this()
{
NOP!();
}
}

View file

@ -534,11 +534,6 @@ namespace IDE.ui
{
checkIdx++;
if (checkIdx == 0x82)
{
NOP!();
}
line.Reference(lineStrView);
if (line.Length == 0)
break;

View file

@ -25,12 +25,7 @@ namespace IDE.ui
public ~this()
{
//Debug.Assert((mWatchSeriesInfo == null) || (mWatchSeriesInfo.mMoreButton == null));
if (mWatchSeriesInfo != null)
{
NOP!();
}
}
}
@ -47,18 +42,10 @@ namespace IDE.ui
public this(IWatchOwner watchOwner, HoverListView listView) : base(watchOwner, listView)
{
if (mHLVItemId == 8)
{
NOP!();
}
}
public ~this()
{
if (mHLVItemId == 8)
{
NOP!();
}
}
public override WatchListViewItem GetWatchListViewItemParent()
@ -204,11 +191,6 @@ namespace IDE.ui
public override void Resize(float x, float y, float width, float height)
{
if (width < mWidth)
{
NOP!();
}
base.Resize(x, y, width, height);
}
}
@ -293,17 +275,6 @@ namespace IDE.ui
public ~this()
{
//Debug.WriteLine("HoverWatch.~this {0}", this);
if (!String.IsNullOrEmpty(mOrigEvalString))
{
NOP!();
}
if (mListView != null)
{
NOP!();
}
Clear();
}
@ -948,11 +919,6 @@ namespace IDE.ui
//var font = DarkTheme.sDarkTheme.mSmallFont;
var listView = new HoverListView(this);
if (mListView != null)
{
NOP!();
}
//Debug.WriteLine("HoverWatch.CreateListView {0}", listView);
listView.mHoverWatch = this;

View file

@ -1407,6 +1407,12 @@ namespace IDE.ui
clickedItem = (DarkListViewItem)clickedItem.GetSubItem(0);
}
if (theEvent.mBtn != 0)
{
if (clickedItem.Selected)
return;
}
SelectItem(clickedItem, true);
if ((!clickedItem.IsParent) && (theEvent.mBtnCount > 1))

View file

@ -340,11 +340,6 @@ namespace IDE.ui
}
else
{
if (type.IsEnum)
{
NOP!();
}
if (mApplyAction != null)
{
mApplyAction();

View file

@ -933,11 +933,6 @@ namespace IDE.ui
public bool Classify(ResolveType resolveType, ResolveParams resolveParams = null)
{
if (resolveType == .GetFixits)
{
NOP!();
}
// Don't allow other classify calls interrupt a symbol rename
if ((IDEApp.sApp.mSymbolReferenceHelper != null) && (IDEApp.sApp.mSymbolReferenceHelper.HasStarted) && (IDEApp.sApp.mSymbolReferenceHelper.mKind == SymbolReferenceHelper.Kind.Rename))
return false;
@ -1812,10 +1807,6 @@ namespace IDE.ui
var sw = scope Stopwatch(true);
sw.Start();
bfSystem.Lock(1);
if (sw.ElapsedMicroseconds > 100)
{
NOP!();
}
bfSystem.PerfZoneEnd();
}
else
@ -1865,11 +1856,6 @@ namespace IDE.ui
parser.ClassifySource(char8Data, !mIsBeefSource);
}
if (resolveType == .Autocomplete)
{
NOP!();
}
if (!isBackground)
{
String autocompleteInfo = scope String();
@ -5225,10 +5211,7 @@ namespace IDE.ui
{
for (int i < mProcessResolveCharData.Count)
{
if (mProcessResolveCharData[i].mDisplayFlags == 1)
{
NOP!();
}
}
MarkDirty();

View file

@ -87,11 +87,6 @@ namespace IDE.ui
{
if (mHoverWatch != null)
{
if (mHoverWatch.mCloseCountdown == 1)
{
NOP!();
}
bool hasActiveHoverWatch = false;
if (mHoverWatch.mEditWidget != null)

View file

@ -24,11 +24,6 @@ namespace IDE.ui
{
if (mIsSelected != value)
{
if (!value)
{
NOP!();
}
var threadListView = (ThreadListView)mListView;
if (threadListView.mThreadPanel.mCallstackPopup != null)
threadListView.mThreadPanel.mCallstackPopup.Close();

View file

@ -50,11 +50,6 @@ namespace IDE.ui
else
isValid = gApp.mBfResolveCompiler.VerifyTypeName(editText, cursorPos);
if (isValid)
{
NOP!();
}
for (int ofs < editText.Length)
{
mEditWidgetContent.mData.mText[editOffset + ofs].mDisplayTypeId = isValid ? 0 : 1;

View file

@ -445,11 +445,6 @@ namespace IDE.ui
public DarkButton mLessButton;
public static int32 sIdx;
public int32 mSeriesId = ++sIdx;
public ~this()
{
NOP!();
}
}
public class WatchRefreshButton : ButtonWidget
@ -815,8 +810,8 @@ namespace IDE.ui
set
{
if (value)
mParent.UpdateAll();
/*if (value)
mParent.UpdateAll();*/
base.Selected = value;
}
}
@ -831,11 +826,6 @@ namespace IDE.ui
public this(IWatchOwner watchOwner, IDEListView listView)
{
if (mIdx == 670)
{
NOP!();
}
mWatchOwner = watchOwner;
}
@ -1357,7 +1347,7 @@ namespace IDE.ui
}
if ((forceDelete) ||
((wantsDelete) && (idx != 0) && (curWatchListViewItem != null) && (curWatchListViewItem.mChildAreaHeight == 0)))
((wantsDelete) && (idx != 0) && (curWatchListViewItem != null) && (curWatchListViewItem.mChildAreaHeight == 0) && (!curWatchListViewItem.mIsSelected)))
{
curMemberIdx--;
mParentItem.RemoveChildItem(curWatchListViewItem);
@ -1822,6 +1812,23 @@ namespace IDE.ui
SetupListViewItem(listViewItem, name, evalStr);
if ((parentItem != null) && (parentItem.Selected))
{
// If the parentItem is selected and the next item after the parentItem is selected then we may have a selection span
// so we want to expand that selection to the newly-created item
int parentIdx = parentItem.mParentItem.GetIndexOfChild(parentItem);
if (parentIdx + 1 < parentItem.mParentItem.mChildItems.Count)
{
let nextItem = parentItem.mParentItem.mChildItems[parentIdx + 1];
if (nextItem.Selected)
{
if ((parentItem.mChildItems.Count == 1) || (parentItem.mChildItems[parentItem.mChildItems.Count - 2].Selected))
listViewItem.Selected = true;
}
}
}
return listViewItem;
}
@ -2126,8 +2133,11 @@ namespace IDE.ui
if (btnNum == 0)
ListViewItemMouseDown(clickedItem, btnCount);
else
{
if (!clickedItem.GetSubItem(0).Selected)
ListViewItemMouseDown(clickedItem, 1);
}
}
void ClearWatchValues(ListViewItem parentListViewItem)
{
@ -2563,11 +2573,6 @@ namespace IDE.ui
while (curIdx < mListView.GetRoot().GetChildCount())
parentItem.RemoveChildItemAt(curIdx);
if (parentItem.GetChildCount() == 0)
{
NOP!();
}
}
}
}
@ -2755,7 +2760,7 @@ namespace IDE.ui
void WithSelected(Action<ListViewItem> func)
{
var root = listView.GetRoot();
root.WithSelectedItems(func);
root.WithSelectedItems(func, false, true);
if (clickedHoverItem != null)
func(clickedHoverItem);