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.pdfiles 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.pdfiles to extract the information in thepd METAcanvas. 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_newfunction 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 thettidattribute. 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_newto receive the rtext-text; - In
g_graph.c'sgraph_visfunction , a call tortext_gettextbefore 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_ioto play the cute animation. We just modifygui_highlight_ioto retrieve tooltip content fromk12_xlet_ttusing thettidattribute, 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_iofunction 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_iofunction 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_vmesstogui_gobj_new. When this happens, the<g>will not have a correctttidattribute 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_newcalls fordemo_sequencer_complex.pdand the result is as below.
Edited by nerrons

