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

Added View Whitespace for string viewer

This commit is contained in:
Brian Fiete 2020-03-02 06:24:21 -08:00
parent e508b8ded7
commit 76cb117e1f
7 changed files with 109 additions and 15 deletions

View file

@ -300,6 +300,17 @@ namespace Beefy
}
}
public BFWindow FocusedWindow
{
get
{
for (var window in mWindows)
if (window.mHasFocus)
return window;
return null;
}
}
public static void Startup(String[] args, Action startupCallback)
{
/*string[] newArgs = new string[args.Length + 1];

View file

@ -462,6 +462,18 @@ namespace Beefy
BFWindow_SetNonExclusiveMouseCapture(mNativeWindow);
}
public bool HasParent(BFWindow widgetWindow)
{
var checkParent = mParent;
while (checkParent != null)
{
if (checkParent == widgetWindow)
return true;
checkParent = checkParent.mParent;
}
return false;
}
public virtual void Closed()
{
if (mHasClosed)

View file

@ -108,7 +108,7 @@ namespace Beefy.theme.dark
{
float spaceWidth = mFont.GetWidth((char32)' ');
if (mTabSize == 0)
return startX + spaceWidth;
return startX + spaceWidth*4;
return (float)Math.Truncate((startX + spaceWidth) / mTabSize + 0.999f) * mTabSize;
}
@ -299,15 +299,17 @@ namespace Beefy.theme.dark
mFont = font;
if (isMonospace)
{
mCharWidth = mFont.GetWidth((char32)' ');
//Debug.Assert(mFont.GetWidth((char32)'W') == mCharWidth);
mCharWidth = mFont.GetWidth(' ');
if (mTabSize == 0)
mTabSize = mTabLength * mCharWidth;
else
mTabSize = (float)Math.Round(mTabSize / mCharWidth) * mCharWidth;
}
else
{
mCharWidth = -1;
mTabSize = mTabLength * mFont.GetWidth('W');
}
if (virtualCursor)
Debug.Assert(isMonospace);
mAllowVirtualCursor = virtualCursor;

View file

@ -38,6 +38,18 @@ namespace Beefy.theme.dark
if (tabButton.mCloseClickedEvent.HasListeners)
tabButton.mCloseClickedEvent();
}
public override void MouseMove(float x, float y)
{
base.MouseMove(x, y);
MarkDirty();
}
public override void MouseLeave()
{
base.MouseLeave();
MarkDirty();
}
}
public class DarkTabButton : TabbedView.TabButton

View file

@ -35,6 +35,7 @@ namespace Beefy.theme.dark
public Insets mRelWidgetMouseInsets ~ delete _;
public bool mAllowMouseInsideSelf;
public bool mAllowMouseOutside;
public int mAutoCloseDelay;
public const float cShadowSize = 8;
@ -199,7 +200,8 @@ namespace Beefy.theme.dark
WidgetWindow widgetWindow = (WidgetWindow)evt.mSender;
if (widgetWindow == mWidgetWindow)
return;
if (widgetWindow.HasParent(mWidgetWindow))
return;
Close();
}
@ -208,6 +210,8 @@ namespace Beefy.theme.dark
WidgetWindow widgetWindow = (WidgetWindow)evt.mSender;
if (widgetWindow == mWidgetWindow)
return;
if (widgetWindow.HasParent(mWidgetWindow))
return;
//if ((!(widgetWindow.mRootWidget is HoverWatch)) && (!(widgetWindow.mRootWidget is MenuWidget)))
Close();
}
@ -221,6 +225,12 @@ namespace Beefy.theme.dark
{
base.Update();
if (mAutoCloseDelay > 0)
{
mAutoCloseDelay--;
return;
}
if (mWidgetWindow == null)
return;
@ -243,9 +253,18 @@ namespace Beefy.theme.dark
if ((mWidgetWindow.mHasMouseInside) && (mAllowMouseInsideSelf))
return;
var checkWindow = BFApp.sApp.FocusedWindow;
if ((checkWindow != null) && (checkWindow.HasParent(mWidgetWindow)))
return;
Close();
}
public void ExpandAllowedRegion()
{
}
protected override void RemovedFromWindow()
{
base.RemovedFromWindow();

View file

@ -83,17 +83,21 @@ namespace IDE.ui
if (var editWidget = gApp.GetActiveWindow().mFocusWidget as EditWidget)
{
var content = editWidget.mEditWidgetContent;
int selStart = content.mSelection.Value.MinPos;
int selEnd = content.mSelection.Value.MaxPos;
bool isMultiline = false;
for (int i = selStart; i < selEnd; i++)
var content = editWidget.mEditWidgetContent;
if (content.mSelection.HasValue)
{
if (content.mData.mText[i].mChar == '\n')
{
isMultiline = true;
break;
}
int selStart = content.mSelection.Value.MinPos;
int selEnd = content.mSelection.Value.MaxPos;
for (int i = selStart; i < selEnd; i++)
{
if (content.mData.mText[i].mChar == '\n')
{
isMultiline = true;
break;
}
}
}
if (!isMultiline)

View file

@ -572,6 +572,8 @@ namespace IDE.ui
public int mMaxShowSize = cMoreBlockSize;
public DarkButton mMoreButton;
public QuickFind mQuickFind;
public DarkTabbedView.DarkTabMenuButton mMenuButton;
public bool mViewWhiteSpace;
public this(String text, String evalStr)
{
@ -614,6 +616,36 @@ namespace IDE.ui
if (evalStr != null)
mEvalString.Set(evalStr);
mMenuButton = new DarkTabbedView.DarkTabMenuButton();
AddWidget(mMenuButton);
mMenuButton.mOnMouseDown.Add(new (evt) =>
{
float x = mMenuButton.mX + GS!(14);
float y = mMenuButton.mY + GS!(6);
Menu menu = new Menu();
var menuItem = menu.AddItem("Show Whitespace");
if (mViewWhiteSpace)
menuItem.mIconImage = DarkTheme.sDarkTheme.GetImage(.Check);
menuItem.mOnMenuItemSelected.Add(new (menu) =>
{
mViewWhiteSpace = !mViewWhiteSpace;
var darkEditWidgetContent = (DarkEditWidgetContent)mEditWidget.Content;
darkEditWidgetContent.mViewWhiteSpaceColor = mViewWhiteSpace ? SourceEditWidgetContent.sTextColors[(int)SourceElementType.VisibleWhiteSpace] : 0;
});
MenuWidget menuWidget = DarkTheme.sDarkTheme.CreateMenuWidget(menu);
menuWidget.Init(this, x, y, true);
menu.mOnMenuClosed.Add(new (menu, itemSelected) =>
{
if (DarkTooltipManager.sTooltip != null)
DarkTooltipManager.sTooltip.mAutoCloseDelay = 90;
});
//menuWidget.mWidgetWindow.mOnWindowClosed.Add(new => MenuClosed);
});
}
public void ShowQuickFind(bool isReplace)
@ -750,8 +782,8 @@ namespace IDE.ui
}
g.DrawString(textPosString, 16, textY, .Left, mWidth - GS!(140), .Ellipsis);
g.DrawString(StackStringFormat!("Ln {0}", line + 1), mWidth - GS!(120), textY);
g.DrawString(StackStringFormat!("Col {0}", col + 1), mWidth - GS!(60), textY);
g.DrawString(StackStringFormat!("Ln {0}", line + 1), mWidth - GS!(130), textY);
g.DrawString(StackStringFormat!("Col {0}", col + 1), mWidth - GS!(70), textY);
//using (g.PushColor(0xD0FFFFFF))
base.DrawAll(g);
@ -764,6 +796,8 @@ namespace IDE.ui
mEditWidget.Resize(0, 0, width, height - GS!(16));
if (mQuickFind != null)
mQuickFind.ResizeSelf();
mMenuButton.Resize(width - GS!(26), height - GS!(12), GS!(16), GS!(16));
}
public float GetWantHeight(float wantWidth)