Skip to content

Commit

Permalink
drawflame: Fix info box and hotkeys
Browse files Browse the repository at this point in the history
Signed-off-by: iipeace <iipeace5@gmail.com>
  • Loading branch information
iipeace committed Aug 10, 2024
1 parent 2379d45 commit 9a29e15
Showing 1 changed file with 23 additions and 16 deletions.
39 changes: 23 additions & 16 deletions guider/guider.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
__credits__ = "Peace Lee"
__license__ = "GPLv2"
__version__ = "3.9.8"
__revision__ = "240807"
__revision__ = "240810"
__maintainer__ = "Peace Lee"
__email__ = "iipeace5@gmail.com"
__repository__ = "https://github.com/iipeace/guider"
Expand Down Expand Up @@ -8868,7 +8868,7 @@ def writeFlamegraph(path, samples, title, depth=20, infodata=""):
# fixed font size: 12, bar height: 17 #
titleBarHeight = 14.4
titleLen = title.count("<tspan ") + 1
infoLen = infodata.count("\n") + 1
infoLen = infodata.count("\n") * 0.9
titleHeight = titleLen * titleBarHeight
barHeight = 17
height = barHeight * max(depth, infoLen) + 50 + titleHeight
Expand Down Expand Up @@ -8977,7 +8977,7 @@ def writeFlamegraph(path, samples, title, depth=20, infodata=""):
matchedtxt.attributes.x.value = svgWidth - xpad - 100;
infobtn.attributes.x.value = searchbtn.attributes.x.value - 100;
};
window.addEventListener('resize', function() {
window.addEventListener("resize", function() {
update_for_width_change();
});
// This needs to be done asynchronously for Safari to work.
Expand Down Expand Up @@ -9022,8 +9022,7 @@ def writeFlamegraph(path, samples, title, depth=20, infodata=""):
else if (e.target.id == "search") search_prompt();
else if (e.target.id == "info") info_print();
}, false)
// mouse-over for info
// show
// mouse-over for info show
window.addEventListener("mouseover", function(e) {
var target = find_group(e.target);
if (target && details) {
Expand All @@ -9037,18 +9036,22 @@ def writeFlamegraph(path, samples, title, depth=20, infodata=""):
details.nodeValue = ' ';
}
}, false)
// F3 / ctrl-F for search, ESC for reset search or zoom
// hotkey
window.addEventListener("keydown",function (e) {
if (e.keyCode === 114 || (e.ctrlKey && e.keyCode === 70)) {
// F2 for print info
if (e.keyCode === 113) {
e.preventDefault();
info_print();
}
// F3 for search
else if (e.keyCode === 114) {
e.preventDefault();
search_prompt();
// ESC for reset search or zoom
} else if (e.keyCode === 27 || (e.ctrlKey && e.keyCode === 90)) {
e.preventDefault();
reset_search();
unzoom()
} else if (e.keyCode === 113) {
e.preventDefault();
info_print();
}
}, false)
// functions
Expand Down Expand Up @@ -9376,17 +9379,17 @@ def writeFlamegraph(path, samples, title, depth=20, infodata=""):
// backtround rect #
let rect = document.createElementNS(svgNS, "rect");
rect.setAttribute('x', '10%');
rect.setAttribute('y', '10%');
rect.setAttribute('y', '95');
rect.setAttribute('width', '80%');
rect.setAttribute('height', '90%');
rect.setAttribute('height', '100%');
rect.setAttribute('fill', 'white');
rect.setAttribute('stroke', 'black');
rect.setAttribute('stroke-width', '2');

// text element
let textElement = document.createElementNS(svgNS, "text");
textElement.setAttribute('x', '12%');
textElement.setAttribute('y', '15%');
textElement.setAttribute('y', '115');
textElement.setAttribute('fill', 'black');

// text content
Expand All @@ -9404,15 +9407,19 @@ def writeFlamegraph(path, samples, title, depth=20, infodata=""):
closeButton.setAttribute('cursor', 'pointer');

let closeRect = document.createElementNS(svgNS, "rect");
closeRect.setAttribute('width', '20');
closeRect.setAttribute('x', '10%');
closeRect.setAttribute('y', '95');
closeRect.setAttribute('width', '12');
closeRect.setAttribute('height', '20');
closeRect.setAttribute('fill', 'red');
closeRect.setAttribute('stroke', 'black');
closeRect.setAttribute('stroke-width', '2');

let closeText = document.createElementNS(svgNS, "text");
closeText.textContent = 'X';
closeText.setAttribute('fill', 'white');
closeText.setAttribute('x', '5');
closeText.setAttribute('y', '15');
closeText.setAttribute('x', '10%');
closeText.setAttribute('y', '110');

closeButton.appendChild(closeRect);
closeButton.appendChild(closeText);
Expand Down

0 comments on commit 9a29e15

Please sign in to comment.