The source project of this merge request has been removed.
WIP: GSoC Phase 3: K12 Mode xlet tooltips
This MR is based on and a superset of !301 (closed). I tried to make minimal changes to the C code base.
What this MR does
- Parses all
-help.pd
files in the K12 directory to extract the content of the tooltips. - Adds feature: when the mouse is hovering over the xlets, a tooltip shows up.
How it works
- When starting Pd in K12 mode, a parser goes over all
-help.pd
files to extract the information in thepd META
canvas. The content of the tooltip is stored in a global object calledk12_xlet_tt
, structured like this:
{
"abstraction1": {
"i0": "content...",
"i1": "content...",
"o0": "content..."
},
"abstraction2": {
...
}, ...
}
- When opening a .pd file and Purr Data is creating gobjs on the svg, the
gui_gobj_new
function from JS receives the rtext-text of the graph object from the C side (which is essentially the name of the K12 abstraction), and stores it in the DOM using thettid
attribute. This way, Purr Data knows which K12 abstraction is our new gobj representing, making it possible to retrieve tooltip content fromk12_xlet_tt
. Relevant changes include:- In
pdgui.js
, an additional parameter forgui_gobj_new
to receive the rtext-text; - In
g_graph.c
'sgraph_vis
function , a call tortext_gettext
before vmessinggui_obj_new
.
- In
- C code now already has a (very complex) mechanism for detecting whether the mouse cursor is hovering over any xlet, and if so, it will vmess
gui_gobj_highlight_io
to play the cute animation. We just modifygui_highlight_io
to retrieve tooltip content fromk12_xlet_tt
using thettid
attribute, and then display the tooltip div at the appropriate position. Relevant changes include:- In
pd_canvas.html
, there's a new<div>
to contain the tooltip. -
pdgui.js
'sgui_gobj_highlight_io
function now shows the tooltip div when the cursor is hovering over xlets. For inlets, the tooltip will be located below the cursor, because there will be guaranteed space; the opposite for outlets. -
pdgui.js
'sgui_gobj_configure_io
function hides the tooltip div, since this function is called every time when the cursor is moving out of the xlet.
- In
Screenshot
Todo
- Feature: when the xlet is on the right-most edge of the canvas, show the xlet on the left of the cursor.
- Bug: For some unknown reason, when creating certain K12 abstractions, the rtext-text doesn't get passed through
gui_vmess
togui_gobj_new
. When this happens, the<g>
will not have a correctttid
attribute and thus won't display the tooltip. I fail to find a pattern when this will happen. It's always the same abstractions.
I tried printing all thegui_gobj_new
calls fordemo_sequencer_complex.pd
and the result is as below.