PREVIEW: Crossplatform tooltip system by objorke · Pull Request #1415 · oxyplot/oxyplot · GitHub
Skip to content

PREVIEW: Crossplatform tooltip system - #1415

Closed
objorke wants to merge 57 commits into
oxyplot:developfrom
silviubogan:crossplatform-tooltip-system
Closed

objorke wants to merge 57 commits into
oxyplot:developfrom
silviubogan:crossplatform-tooltip-system

Conversation

@objorke

@objorke objorke commented Oct 27, 2019

Copy link
Copy Markdown
Member

this is a preview for #1081

@silviubogan
silviubogan force-pushed the crossplatform-tooltip-system branch from c665f47 to 3c14084 Compare October 28, 2019 10:43

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can these examples be implemented with the PlotController instead? #111

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@VisualMelon I am not sure how to do this. My first impression is to use the extension method IController.BindMouseDown with a parameter of type DelegateViewCommand but I do not know how code-gen handles this, and, more important to me, I do not know what IController method to use instead of the model's MouseUp event.

Thank you.

@VisualMelon VisualMelon Oct 31, 2019 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure, I've never used them myself. However, take a look at ManipulatorBase: you should be able to bind a MouseDownGesture, and implement the started/delta/completed events to handle the entire interaction.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@VisualMelon I posted my unsuccessful attempt on this in a gist. The relevant lines with comments are here. I think I will try more tomorrow. (I think that I must also find how to use the OxyMouseDownGesture class). It would be great if you could help me more. Thank you for all the help.

@VisualMelon VisualMelon Oct 31, 2019 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Manipulators are, I believe, a transient thing. Lots of examples in PlotCommands.cs (e.g. PanAt. I'd expect the code to be more like this:

plot.PlotView.ActualController.BindMouseDown(OxyMouseButton.Left, OxyModifierKeys.None, new DelegateViewCommand<OxyMouseDownEventArgs>((v, c, e) =>
{
    plot.PlotView.ActualController.AddMouseManipulator(plot.PlotView, new CustomMouseManipulator(v, rnd), e);
}));

However, this can never work, because we just created the model, so it can't have a plotview or controller, so my gut feeling is that answer to @objorke question is that it is not possible. I think I'm going to have to try to get my head around #111...

Comment thread Source/OxyPlot.Wpf/PlotBase.cs Outdated
/// <param name="updateData">The update Data.</param>
public void InvalidatePlot(bool updateData = true)
{
if (this.ActualWidth <= 0 || this.ActualHeight <= 0)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be reverted

/// </returns>
protected override HitTestResult HitTestOverride(HitTestArguments args)
{
if (!this.PlotModel.PlotArea.Contains(args.Point))

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move this into calling method?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@VisualMelon Please, can you tell me how can I access the (PlotModel.)PlotArea from the calling method of the code above, UIElement.HitTest? Should there be a new UIElement.PlotModel property? Thank you.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure. UIElement.PlotModel would couple UIElement to PlotModel unnecessarily. I'm not sure if objorke means that the decision to test agains the PlotArea should be handled higher up (though currently it cannot, because Model and not PlotModel do the work), or if the idea is just to reduce redundancy.

I am not totally convinced that the elements should be filtered at this layer, and I wonder if Model.HitTest should give more control to the inheriting class. That's all assuming the change is desirable, which I don't think is entirely clear with annotations.

@objorke

objorke commented Oct 29, 2019

Copy link
Copy Markdown
Member Author

Can we remove https://github.com/oxyplot/oxyplot/blob/develop/Source/OxyPlot/Rendering/RenderContext/IRenderContext.cs#L187 with these changes?

/// Shows the tooltip.
/// </summary>
/// <param name="str">The string to show as tooltip.</param>
void ShowToolTip(string str);

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@objorke I do not have a strong opinion on this. I think that:

  • there are some configuration variables in IToolTipView that would pollute IView implementations
  • loosely coupled objects are good on the long term

Thank you.

@silviubogan

Copy link
Copy Markdown

@objorke

Can we remove https://github.com/oxyplot/oxyplot/blob/develop/Source/OxyPlot/Rendering/RenderContext/IRenderContext.cs#L187 with these changes?

It is done in a new commit: 192c643.

Thank you.

@silviubogan

Copy link
Copy Markdown

@VisualMelon A few unimportant questions, only if you have time for them:

  1. What should be the order of the priorities of the tooltip string, the tooltip formatter and the tooltip format string? I would do it like this but I am not sure how good this is: if the tooltip string is available, take it, else if the tooltip format string is available take it, else take the tooltip formatter.

  2. What variables should be passed to the format string if they should be? Currently the HitTestResult object is passed to the tooltip formatter. I think that in the next week I will take a better look at how this is done for the tracker format string.

  3. If it is the case, is it possible to do a rebase onto upstream/develop without removing the existing comments on GitHub?

Thank you.

@VisualMelon

Copy link
Copy Markdown
Contributor

@silviubogan

  1. I'd go with (in preferential order) Formatter, Format String, just the String. I think that's what is done elsewhere.
  2. I'm not sure. I'd forgotten the tracker was handled per-element, otherwise that would have been my suggestion. I might have another look later when I have more time.
  3. Sorry, I don't know. I'd expect they just become 'outdated', but couldn't say for sure.

@trovialdo

trovialdo commented Nov 1, 2019 •

Copy link
Copy Markdown

I'm wondering if we can just drop the ToolTip string property all together and only provide the formatter function and string. I do not think you would lose any functionality, you can also use the format string to show a static message (or formatter function for that matter).

Be careful if you want to pass more arguments to the formatter function since, if you do it like the tracker (possible custom # arguments per element), it will become the responsibility of the element to generate the tooltip. Hence you might need to add string GetToolTip(HitTestResult) on the element API, which i would try to avoid.

(and thanks for adding the formatter function!)

(whatever we decide upon we should do the same for the tracker to be consistent in API imo, so probably add a formatter function there as well. But this can be done later on and in another issue.)

+ improved a bit the code style
+ removed a piece of unused commented code
+ left the toggle to on (the new tooltip system) and a few comments
+ removed a few lines of XAML
renamed a variable +
improved some comments
removed a call in OxyPlot.Wpf to Dispatcher.BeginInvoke after testing without it
removed a few useless comments +
dispose the ToolTip in OxyPlot.Wpf when the PlotView is disposed
improved XML comments in the two CustomToolTip classes
solved some bugs about tooltip timing logic
@silviubogan
silviubogan force-pushed the crossplatform-tooltip-system branch from 3c1d82e to cb70700 Compare November 3, 2019 07:40
@silviubogan

Copy link
Copy Markdown

@VisualMelon In your opinion is it good to start working on a global tooltip functionality? What I want to say is a new property IPlotView.GlobalToolTip of type string that is shown, if it is not null, when the user moves the mouse over a portion of the plot that has no specific tooltip (e.g. a PlotElement that has no ToolTip(Formatter) set). Thank you.

@Jonarw

Jonarw commented Jul 11, 2023

Copy link
Copy Markdown
Member

@Jonarw Jonarw closed this Jul 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants