After installing R2018b, the first figure I opened contained an interesting message (shown in blue):
The reason it's interesting is because it contains features like text wrapping, transparency, the fact that the image maintains a constant width even though the text resizes (this reminded me of CSS3 flexbox, hence the tag), etc.
The last part of the animation is in slow motion, to better show how the div's size follows that of the figure.
In case it matters, I'm using Win 10 v1803.
Question:
I'd like to know how we can draw similar, custom, divs (for a lack of a better word) in our figures. (It's important to stress that this is not a UIFigure
!)
What I found so far:
The Learn More link opens the page:
web(fullfile(docroot, 'matlab/creating_plots/interactively-explore-plotted-data.html'))
yet breakpoints in the entry points of either
web
ordocroot
(or evendoc
) aren't hit.Assuming that this element is a
Child
of the figure, I attempted to locate a handle to it:>> set(gcf,'MenuBar','none'); findall(gcf) ans = 22×1 graphics array: Figure (1) ContextMenu AnnotationPane Axes AxesToolbar Text Text Text ToolbarStateButton (Brush/Select Data) ToolbarStateButton (Data Tips) ToolbarStateButton (Rotate 3-D) ToolbarStateButton (Pan) ToolbarStateButton (Zoom In) ToolbarStateButton (Zoom Out) ToolbarPushButton (Restore View) Button Button Button Button Button Button Button
however, making these controls invisible using
set(h(2:end), 'Visible', false)
didn't make the div disappear.Saving the figure as
.fig
or generating code for it, doesn't leave any trace of this div.When
uiinspect
-ing the figure, this div doesn't show (or at least, I couldn't find it).I don't know what exactly I did to make it reappear once more, but since it's set to appear on the very first time you boot R2018b, I suspect deleting
prefdir
(obviously, after backing it up) and restarting MATLAB could bring it back.- The only thing I didn't try yet, is to attach a java debugger to MATLAB and attempt to trace the caller to
com.mathworks.mlservices.MLHelpServices.setCurrentLocation
(frommlservices.jar
), which opens the help browser.
After some digging in the Java side of things (starting from
findjobj
, followed by a lot of.getComponent(0).getComponent(0)...
), I've finally managed to locate the component in question. Here's what I learned:This component is called
InfoPanel
, and is part of MATLAB's Java API. The class definition itself is found in:To make it appear, we need to call the
static
methodaddBannerPanel
, passing in a figure handle:Or another signature that also accepts a custom panel:
The MATLAB setting that controls whether this should appear is
showinteractioninfobar
inside the<prefdir>/matlab.settings
XML.It appears that the "interesting parts" of
InfoPanel
are private, which means it allows barely any customization (mostly some colors; not the string or the icon), but it should be fairly easy to make a copy of this class and expose all elements we need.