1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-10 20:42:21 +02:00

Added an origX/origY to MouseClick

This commit is contained in:
Brian Fiete 2020-03-21 07:09:21 -07:00
parent 5f949c177d
commit a51fa2b657
14 changed files with 76 additions and 34 deletions

View file

@ -35,7 +35,7 @@ namespace Beefy.theme.dark
if (DarkTheme.CheckUnderlineKeyCode(mLabel, keyCode))
{
mDrawDownPct = 1.0f;
MouseClicked(0, 0, 3);
MouseClicked(0, 0, 0, 0, 3);
return true;
}
return false;

View file

@ -30,9 +30,9 @@ namespace Beefy.theme.dark
g.Draw(DarkTheme.sDarkTheme.GetImage(DarkTheme.ImageIdx.Close), GS!(-4), GS!(-4));
}
public override void MouseClicked(float x, float y, int32 btn)
public override void MouseClicked(float x, float y, float origX, float origY, int32 btn)
{
base.MouseClicked(x, y, btn);
base.MouseClicked(x, y, origX, origY, btn);
var tabButton = (DarkTabButton)mParent;
if (tabButton.mCloseClickedEvent.HasListeners)
@ -312,7 +312,7 @@ namespace Beefy.theme.dark
{
if (mMenuClosedTick != mUpdateCnt)
{
ShowMenu(mMenuButton.mX + GS!(14), mMenuButton.mY + GS!(6));
ShowMenu(mMenuButton.mX + GS!(14), mMenuButton.mY + GS!(14));
}
}

View file

@ -19,7 +19,10 @@ namespace Beefy.widgets
base.KeyDown(keyCode, isRepeat);
if ((keyCode == KeyCode.Return) || (keyCode == KeyCode.Space))
{
MouseDown(0, 0, 3, 1);
MouseClicked(0, 0, 0, 0, 3);
}
else
mParent.KeyDown(keyCode, isRepeat);
}

View file

@ -184,7 +184,7 @@ namespace Beefy.widgets
protected void EditCancelHandler(EditEvent theEvent)
{
if (mEscButton != null)
mEscButton.MouseClicked(0, 0, 3);
mEscButton.MouseClicked(0, 0, 0, 0, 3);
}
public virtual void AddCloseButton(DialogEventHandler closeHandler, int32 theDefault = -1)
@ -310,13 +310,13 @@ namespace Beefy.widgets
public virtual void Escape()
{
mEscButton.MouseClicked(0, 0, 3);
mEscButton.MouseClicked(0, 0, 0, 0, 3);
}
public virtual void Submit()
{
if ((mDefaultButton != null) && (!mDefaultButton.mDisabled))
mDefaultButton.MouseClicked(0, 0, 3);
mDefaultButton.MouseClicked(0, 0, 0, 0, 3);
}
void WindowKeyDown(KeyDownEvent evt)

View file

@ -637,9 +637,9 @@ namespace Beefy.widgets
}
public override void MouseClicked(float x, float y, int32 btn)
public override void MouseClicked(float x, float y, float origX, float origY, int32 btn)
{
base.MouseClicked(x, y, btn);
base.MouseClicked(x, y, origX, origY, btn);
if (mParentItem != null) // Don't notify for root
mListView.mOnItemMouseClicked(this, x, y, btn);
}

View file

@ -695,7 +695,7 @@ namespace Beefy.widgets
}
}
public virtual void MouseClicked(float x, float y, int32 btn)
public virtual void MouseClicked(float x, float y, float origX, float origY, int32 btn)
{
if (mOnMouseClick.HasListeners)
{
@ -734,9 +734,6 @@ namespace Beefy.widgets
if ((hadPhysMouseDown) && (!hasPhysMouseDown))
ReleaseMouseCapture();
if ((mMouseOver) || (btn == 3))
MouseClicked(x, y, btn);
if (mOnMouseUp.HasListeners)
{
MouseEvent mouseEvent = scope MouseEvent();

View file

@ -52,6 +52,8 @@ namespace Beefy.widgets
public int32 mClientMouseY;
public float mMouseX;
public float mMouseY;
public float mMouseDownX;
public float mMouseDownY;
public bool mIsMouseMoving;
public bool mHasMouseInside;
public bool mHasProxyMouseInside;
@ -623,6 +625,8 @@ namespace Beefy.widgets
public override void MouseDown(int32 inX, int32 inY, int32 btn, int32 btnCount)
{
let oldFlags = mMouseFlags;
mMouseFlags |= (MouseFlag)(1 << btn);
if ((!mHasFocus) && (mParent == null))
{
@ -637,6 +641,12 @@ namespace Beefy.widgets
MouseMove(inX, inY);
if (oldFlags == default)
{
mMouseDownX = mMouseX;
mMouseDownY = mMouseY;
}
if ((mOnMouseDown.HasListeners) || (sOnMouseDown.HasListeners))
{
MouseEvent anEvent = scope MouseEvent();
@ -672,11 +682,22 @@ namespace Beefy.widgets
Widget aWidget = mCaptureWidget ?? mOverWidget;
if (aWidget != null)
{
float origX;
float origY;
aWidget.RootToSelfTranslate(mMouseDownX, mMouseDownY, out origX, out origY);
aWidget.MouseUp(origX, origY, btn);
float childX;
float childY;
aWidget.RootToSelfTranslate(mMouseX, mMouseY, out childX, out childY);
aWidget.MouseUp(childX, childY, btn);
if (aWidget.mMouseOver)
{
aWidget.MouseClicked(childX, childY, origX, origY, btn);
}
}
}
public void ReleaseMouseCaptures()

View file

@ -1396,7 +1396,7 @@ namespace IDE
{
if (button.Label == buttonName)
{
button.MouseClicked(0, 0, 0);
button.MouseClicked(0, 0, 0, 0, 0);
return;
}
}

View file

@ -23,9 +23,9 @@ namespace IDE.ui
public float mJmpIconY;
public int mJmpState = -1;
public override void MouseClicked(float x, float y, int32 btn)
public override void MouseClicked(float x, float y, float origX, float origY, int32 btn)
{
base.MouseClicked(x, y, btn);
base.MouseClicked(x, y, origX, origY, btn);
if (btn == 1)
{

View file

@ -1217,9 +1217,9 @@ namespace IDE.ui
base.DrawAll(g);
}
public override void MouseClicked(float x, float y, int32 btn)
public override void MouseClicked(float x, float y, float origX, float origY, int32 btn)
{
base.MouseClicked(x, y, btn);
base.MouseClicked(x, y, origX, origY, btn);
if (btn == 1) //
{

View file

@ -195,9 +195,9 @@ namespace IDE.ui
return false;
}
public override void MouseClicked(float x, float y, int32 btn)
public override void MouseClicked(float x, float y, float origX, float origY, int32 btn)
{
base.MouseClicked(x, y, btn);
base.MouseClicked(x, y, origX, origY, btn);
if (btn == 1)
{
@ -241,7 +241,7 @@ namespace IDE.ui
if (keyCode == .Apps)
{
GetTextCoordAtCursor(var x, var y);
MouseClicked(x, y, 1);
MouseClicked(x, y, x, y, 1);
}
}
}

View file

@ -2762,7 +2762,7 @@ namespace IDE.ui
if (keyCode == KeyCode.Apps)
{
GetTextCoordAtCursor(var x, var y);
MouseClicked(x, y, 1);
MouseClicked(x, y, x, y, 1);
return;
}
@ -2957,14 +2957,14 @@ namespace IDE.ui
IDEUtils.ClampMenuCoords(ref x, ref y, mEditWidget, scope .(0, 0, GetLineHeight(0), GS!(32)));
}
public override void MouseClicked(float x, float y, int32 btn)
public override void MouseClicked(float x, float y, float origX, float origY, int32 btn)
{
base.MouseClicked(x, y, btn);
base.MouseClicked(x, y, origX, origY, btn);
var useX = x;
var useY = y;
if ((btn == 0) && (mWidgetWindow.IsKeyDown(.Control)))
if ((btn == 0) && (mWidgetWindow.IsKeyDown(.Control)) && (x == origX) && (y == origY))
{
gApp.GoToDefinition();
return;

View file

@ -6175,9 +6175,9 @@ namespace IDE.ui
return true;
}
public override void MouseClicked(float x, float y, int32 btn)
public override void MouseClicked(float x, float y, float origX, float origY, int32 btn)
{
base.MouseClicked(x, y, btn);
base.MouseClicked(x, y, origX, origY, btn);
if (btn == 0)
{
@ -6277,5 +6277,26 @@ namespace IDE.ui
idx++;
}
}
public bool HasTextAtCursor()
{
let ewc = mEditWidget.mEditWidgetContent;
int textPos = mEditWidget.mEditWidgetContent.CursorTextPos;
if (textPos >= ewc.mData.mTextLength)
return false;
for (int offset = -1; offset <= 0; offset++)
{
int checkPos = textPos + offset;
if (checkPos < 0)
continue;
let c = ewc.mData.mText[checkPos].mChar;
if ((c.IsLetterOrDigit) || (c == '_') || (c == '@'))
return true;
}
return false;
}
}
}

View file

@ -36,9 +36,9 @@ namespace IDE.ui
gApp.SetCursor(.Pointer);
}
public override void MouseClicked(float x, float y, int32 btn)
public override void MouseClicked(float x, float y, float origX, float origY, int32 btn)
{
base.MouseClicked(x, y, btn);
base.MouseClicked(x, y, origX, origY, btn);
gApp.[Friend]mDeferredOpen = .Workspace;
String.NewOrSet!(gApp.[Friend]mDeferredOpenFileName, mPath);