Commit fe74de1f authored by nerrons's avatar nerrons
Browse files

Fix: scrolling the canvas screws up xlet tooltip positions

parent 7b1c2350
Pipeline #1638 failed with stage
in 0 seconds
...@@ -2239,7 +2239,7 @@ function gui_gobj_draw_io(cid, parenttag, tag, x1, y1, x2, y2, basex, basey, ...@@ -2239,7 +2239,7 @@ function gui_gobj_draw_io(cid, parenttag, tag, x1, y1, x2, y2, basex, basey,
xlet_class = "xlet_control"; xlet_class = "xlet_control";
xlet_id = tag + type + i; xlet_id = tag + type + i;
} }
if (k12_mode === 1) { if (k12_mode === 1 && type) {
xlet_class += " xlet_tt" + type; // used to determine the position of the tooltip xlet_class += " xlet_tt" + type; // used to determine the position of the tooltip
} }
rect = create_item(cid, "rect", { rect = create_item(cid, "rect", {
...@@ -2287,7 +2287,7 @@ function gui_gobj_configure_io(cid, tag, is_iemgui, is_signal, width) { ...@@ -2287,7 +2287,7 @@ function gui_gobj_configure_io(cid, tag, is_iemgui, is_signal, width) {
} else if (is_signal) { } else if (is_signal) {
type = "xlet_signal"; type = "xlet_signal";
} else { } else {
"xlet_control"; type = "xlet_control";
} }
e.classList.add(type); e.classList.add(type);
e.classList.remove("xlet_selected"); e.classList.remove("xlet_selected");
...@@ -2300,23 +2300,32 @@ function gui_gobj_configure_io(cid, tag, is_iemgui, is_signal, width) { ...@@ -2300,23 +2300,32 @@ function gui_gobj_configure_io(cid, tag, is_iemgui, is_signal, width) {
} }
function gui_gobj_highlight_io(cid, tag) { function gui_gobj_highlight_io(cid, tag) {
gui(cid).get_elem(tag, function(e) { gui(cid).get_nw_window(function (nw_win) {
e.classList.add("xlet_selected"); var xlet = nw_win.window.document.getElementById(tag);
if (k12_mode === 1 if (xlet) {
&& (e.classList.contains("xlet_tti") || e.classList.contains("xlet_tto"))) { xlet.classList.add("xlet_selected");
gui(cid).get_elem("xlet_tt", function(tt) { // for K12 abstraction xlets, show tooltips at mouse position
var e_rect = e.getBoundingClientRect(), if (k12_mode === 1
e_x = e_rect.left, && (xlet.classList.contains("xlet_tti") || xlet.classList.contains("xlet_tto"))) {
e_y = e_rect.top; var tt = nw_win.window.document.getElementById("xlet_tt"),
tt.innerHTML = k12_xlet_tt[e.parentNode.getAttribute("ttid")][tag.slice(-2)]; xlet_rect = xlet.getBoundingClientRect(),
tt.style.display = "block"; xlet_x = xlet_rect.left,
tt.style.left = e_x + 10 + "px"; xlet_y = xlet_rect.top,
if (e.classList.contains("xlet_tti")) { win_left = nw_win.window.document.body.scrollLeft,
tt.style.top = e_y + 3 + "px"; win_top = nw_win.window.document.body.scrollTop,
} else { abstraction_tt = k12_xlet_tt[xlet.parentNode.getAttribute("ttid")];
tt.style.top = e_y - 10 + "px"; if (abstraction_tt) {
tt.innerHTML = abstraction_tt[tag.slice(-2)];
tt.style.display = "block";
tt.style.left = xlet_x + win_left + 10 + "px";
if (xlet.classList.contains("xlet_tti")) {
tt.style.top = xlet_y + win_top + 3 + "px";
} else {
var tt_height = tt.offsetHeight;
tt.style.top = xlet_y + win_top - tt_height + "px";
}
} }
}); }
} }
}); });
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment