Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How should MouseEvent work with Margin, Border, and Padding? #2578

Closed
tig opened this issue Apr 27, 2023 · 4 comments
Closed

How should MouseEvent work with Margin, Border, and Padding? #2578

tig opened this issue Apr 27, 2023 · 4 comments
Labels
v2 For discussions, issues, etc... relavant for v2

Comments

@tig
Copy link
Collaborator

tig commented Apr 27, 2023

Right now in v2_develop: The me parameter contains Frame-relative coordinates. As a result, any View that wants to override this must adjust for the frames thickness.

E.g. From an updated ColorPicker:

                public override bool MouseEvent (MouseEvent me)
		{
			if (!me.Flags.HasFlag (MouseFlags.Button1Clicked) || !CanFocus) {
				return false;
			}

			SetFocus ();
			Cursor = new Point ((me.X - GetFramesThickness ().Left) / _boxWidth, (me.Y - GetFramesThickness ().Top) / _boxHeight);

			return true;
		}

I don't think most View developers should need to deal with this; they should get mouse coordinates relative to the Bounds.

I think Application.ProcessMouseEvent should be calling view.GetFramesThickness and using that to cause me.X and me.Y to be Bounds relative.

If a View implementation wants to get mouse events for its Margin, Border, or Padding it can do so by subscribing to the appropriate mouse events.

What do you all think?

@tig tig added v2 For discussions, issues, etc... relavant for v2 and removed enhancement labels Apr 27, 2023
@tznind
Copy link
Collaborator

tznind commented Apr 27, 2023

I think it would be nice if there was an Enum in MouseEvent that told you where the mouse was within the View. For example (padding, margin, border or client area). We could have a direction too for those (Upper, Left, Right, Bottom) or None (for client area).

The x/y coordinates should be relative to the origin (0,0) of the bit that the mouse is operating in e.g. (x=50,y=0) of the Bottom margin would be a click in the middle bottom of the view when margin is 1?

Unless borders and padding are themselves views or have views in them I guess.

An alternative if this is too complicated would be to make this a new event... what is the collective noun for border/margin/padding? so like BorderMarginOrPaddingMouseEvent (only better)

@BDisp
Copy link
Collaborator

BDisp commented Apr 27, 2023

And to complicate even more if we want a 3D effect shadow, it will be a new frame between the Margin and the Border. His frame isn't take in account for the total location and dimensions. The Margin has to allow transparency and the 3D effect will draw the contents around it. Only a thought.

@tig
Copy link
Collaborator Author

tig commented Apr 27, 2023

And to complicate even more if we want a 3D effect shadow, it will be a new frame between the Margin and the Border. His frame isn't take in account for the total location and dimensions. The Margin has to allow transparency and the 3D effect will draw the contents around it. Only a thought.

I don't think a 3deffect Frame is needed. 3d shadows should be rendered by the superview's 'DrawFrames()' after OnRenderFrames is called.

@tig tig moved this to 📋 v2 BETA Backlog in Terminal.Gui V2 Beta Aug 7, 2023
@tig
Copy link
Collaborator Author

tig commented Oct 17, 2023

I'm now working on this....

tig added a commit that referenced this issue Nov 26, 2023
…2920)

* initial commit

* Clarified RootMouseEvent

* Added application mouse coord tests

* ViewToScreen -> BoundsToScreen

* Simplified View.Move

* Simplified View.Move

* Updated API docs; made some functions private

* more ViewLayout cleanup

* more ViewLayout cleanup

* Added View.ScreenToBounds and low-level coord unit tests

* Partial fix

* Refactored Application.OnMouseEvent... Tests still fail and views are broken

* Added Bounds/FrameToScreen

* Remamed ScreenToView->ScreenToFrame

* All unit tests pass

* Fixed ListView

* Fixed TableView

* Fixed ColorPicker

* Fixed RadioGroup

* Fixed ListView unit tests

* Fixed line drawing scenario

* Updated comment

* fixed api doc typo

* fixed formatting

* added some thickness Contains unit tests

* MouseEvent api doc updates

* More thickness tests

* More thickness tests
@tig tig closed this as completed Dec 17, 2023
@github-project-automation github-project-automation bot moved this from 📋 v2 BETA Backlog to ✅ Done in Terminal.Gui V2 Beta Dec 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
v2 For discussions, issues, etc... relavant for v2
Projects
No open projects
Status: ✅ Done
Development

No branches or pull requests

3 participants