Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flamegraph prototype + text improvements #176

Merged
merged 30 commits into from
Apr 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
6c88f4c
Initial flamegraph POC
thomasballinger Mar 18, 2022
9735c0f
Better colors
janpaul123 Mar 22, 2022
a09ec02
Fix various ellipsis bugs
janpaul123 Mar 22, 2022
e062e20
Make `generate_2d_glyphs` take an iterator
janpaul123 Mar 22, 2022
e6bb000
Re-implement ellipsis
janpaul123 Mar 23, 2022
92c12b9
Abstract out “split_string_at_wrap_points”
janpaul123 Mar 23, 2022
4c692bf
Consolidate things in an `apply_wrapping` function
janpaul123 Mar 23, 2022
13b4ace
Document some text drawing functions
janpaul123 Mar 24, 2022
9b0eed0
Add ellipsis to flamegraph
janpaul123 Mar 24, 2022
86e8c00
Better hover and down colors
janpaul123 Mar 24, 2022
d137310
Tighter padding / height
janpaul123 Mar 24, 2022
a1c2403
Precompute spans in flamegraph
janpaul123 Mar 24, 2022
820117a
Add TODOs for confusing behavior in pointer events
janpaul123 Mar 24, 2022
6bcc4f9
Add panning/zooming with mouse to flamegraph
janpaul123 Mar 24, 2022
a1dd4a9
Focus on rect when clicking it
janpaul123 Mar 24, 2022
ce07d98
Add zooming animation to flamegraph when clicking rectangle
janpaul123 Mar 24, 2022
8e5a978
Make text stick to the left hand side
janpaul123 Mar 24, 2022
249d4b0
Add from_lerp functions to library
janpaul123 Mar 24, 2022
3435c43
Add TODO for dynamic animations
janpaul123 Mar 24, 2022
df71fdb
Add TODOs about font rendering inline
janpaul123 Mar 25, 2022
3b1fa1d
Add example_flamegraph to .code-workspace for LLDB
janpaul123 Mar 25, 2022
d416f37
Fix path to example_flamegraph.wasm in index.html
janpaul123 Mar 25, 2022
907495a
Make flamegraph font rendering look better
janpaul123 Mar 25, 2022
42a850a
Fmt & Rustdoc
janpaul123 Mar 25, 2022
6e38da9
Add example_flamegraph to screenshots
janpaul123 Mar 25, 2022
9ff94b5
Make string interner thread safe
janpaul123 Mar 26, 2022
cb68f2d
Fix text wrapping + add unit tests
janpaul123 Mar 26, 2022
803e7f9
Add LLDB profile for unit tests in “zaplib” to VSCode workspace
janpaul123 Mar 26, 2022
38c6325
Add to “demos” page
janpaul123 Apr 7, 2022
b494592
Update TS++ blog title
janpaul123 Apr 7, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 37 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 6 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ members = [
"zaplib/examples/example_bigedit/microserde",
"zaplib/examples/example_bigedit/microserde/derive",
"zaplib/examples/example_charts",
"zaplib/examples/example_flamegraph",
"zaplib/examples/example_image",
"zaplib/examples/example_lightning",
"zaplib/examples/example_lots_of_buttons",
"zaplib/examples/example_shader",
"zaplib/examples/example_single_button",
"zaplib/examples/example_text",
"zaplib/examples/example_lightning",
"zaplib/examples/test_bottom_bar",
"zaplib/examples/test_geometry",
"zaplib/examples/test_layout",
Expand All @@ -24,15 +25,15 @@ members = [
"zaplib/examples/test_padding",
"zaplib/examples/test_popover",
"zaplib/examples/test_shader_2d_primitives",
"zaplib/examples/tutorial_hello_world_console",
"zaplib/examples/tutorial_hello_thread",
"zaplib/examples/tutorial_hello_world_canvas",
"zaplib/examples/tutorial_2d_rendering/step1",
"zaplib/examples/tutorial_2d_rendering/step2",
"zaplib/examples/tutorial_2d_rendering/step3",
"zaplib/examples/tutorial_js_rust_bridge",
"zaplib/examples/tutorial_3d_rendering/step2",
"zaplib/examples/tutorial_3d_rendering/step3",
"zaplib/examples/tutorial_hello_thread",
"zaplib/examples/tutorial_hello_world_canvas",
"zaplib/examples/tutorial_hello_world_console",
"zaplib/examples/tutorial_js_rust_bridge",
"zaplib/examples/tutorial_ui_components",
"zaplib/examples/tutorial_ui_layout",
"zaplib/web/test_suite",
Expand Down
37 changes: 37 additions & 0 deletions zaplib.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,24 @@
"args": [],
"cwd": "."
},
{
"type": "lldb",
"request": "launch",
"name": "Debug executable 'example_flamegraph'",
"cargo": {
"args": [
"build",
"--bin=example_flamegraph",
"--package=example_flamegraph"
],
"filter": {
"name": "example_flamegraph",
"kind": "bin"
}
},
"args": [],
"cwd": "."
},
{
"type": "lldb",
"request": "launch",
Expand Down Expand Up @@ -523,6 +541,25 @@
"args": [],
"cwd": "."
},
{
"type": "lldb",
"request": "launch",
"name": "Debug unit tests in library 'zaplib'",
"cargo": {
"args": [
"test",
"--no-run",
"--lib",
"--package=zaplib"
],
"filter": {
"name": "zaplib",
"kind": "lib"
}
},
"args": [],
"cwd": "."
},
]
},
}
1 change: 1 addition & 0 deletions zaplib/ci/src/cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ async fn screenshots(browser_name: &str, driver: &mut WebDriver, local_port: u16
// ("example_charts", "/zaplib/examples/example_charts/?release"), // TODO(JP): Randomness.
// "example_lightning", // TODO(JP): Pause animation.
("example_image", "/zaplib/examples/example_image/?release"),
("example_flamegraph", "/zaplib/examples/example_flamegraph/?release"),
("example_lots_of_buttons", "/zaplib/examples/example_lots_of_buttons/?release"),
("example_single_button", "/zaplib/examples/example_single_button/?release"),
("example_text", "/zaplib/examples/example_text/?release"),
Expand Down
2 changes: 1 addition & 1 deletion zaplib/components/src/checkbox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ impl Checkbox {

cx.add_box(LayoutSize::new(Width::Fix(20.), Height::Fix(0.)));
let draw_str_props = TextInsProps {
wrapping: Wrapping::Ellipsis(cx.get_width_left() - 20.),
wrapping: Wrapping::Ellipsis(cx.get_width_left()),
color: if errored {
vec4(0.94, 0., 0., opacity)
} else if checked {
Expand Down
3 changes: 1 addition & 2 deletions zaplib/components/src/foldcaption.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,7 @@ impl FoldCaption {
cx.request_draw();
}
cx.begin_right_box();
let draw_str_props =
TextInsProps { wrapping: Wrapping::Ellipsis(cx.get_width_left() - 10.), ..TextInsProps::DEFAULT };
let draw_str_props = TextInsProps { wrapping: Wrapping::Ellipsis(cx.get_width_left()), ..TextInsProps::DEFAULT };
TextIns::draw_walk(cx, label, &draw_str_props);
cx.end_right_box();
}
Expand Down
4 changes: 2 additions & 2 deletions zaplib/components/src/texteditor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1305,7 +1305,7 @@ impl TextEditor {
scale /= 10;
}
let draw_str_props = TextInsProps {
wrapping: Wrapping::Line,
wrapping: Wrapping::None,
text_style: TEXT_STYLE_MONO,
font_scale: self.current_font_scale,
draw_depth: 1.5,
Expand All @@ -1329,7 +1329,7 @@ impl TextEditor {
origin.y + line_geom.walk.y,
),
0,
&line_number_text.chars().collect::<Vec<char>>(),
line_number_text.chars(),
|_, _, _, _| 0.0,
));
}
Expand Down
2 changes: 1 addition & 1 deletion zaplib/docs/src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,4 @@
- [Contributing](./contributing.md)

# Blog
- [Language idea: Typescript++](./blog_ts++.md)
- [Typescript as fast as Rust: Typescript++](./blog_ts++.md)
2 changes: 1 addition & 1 deletion zaplib/docs/src/blog_ts++.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Language idea: Typescript++
# Typescript as fast as Rust: Typescript++

_JP Posma, April 2022_

Expand Down
3 changes: 3 additions & 0 deletions zaplib/docs/src/demos.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ Besides the lightning bolt demo in the [introduction](./introduction.md), we hav

<!-- TODO(JP): add some missing examples that have text editing, after fixing that when having multiple iframes with Zaplib on the same page -->

[example_flamegraph](https://github.com/Zaplib/zaplib/blob/main/zaplib/examples/example_flamegraph/src/main.rs)
<div style="height: 600px"><iframe src="/example_flamegraph.html?release" style="position: absolute; left: 0; width: 100%; height: 600px; border: none;"></iframe></div>

[example_charts](https://github.com/Zaplib/zaplib/blob/main/zaplib/examples/example_charts/src/main.rs)
<div style="height: 600px"><iframe src="/example_charts.html?release" style="position: absolute; left: 0; width: 100%; height: 600px; border: none;"></iframe></div>

Expand Down
6 changes: 2 additions & 4 deletions zaplib/examples/example_bigedit/src/filetree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -410,8 +410,7 @@ impl FileTree {
cx.begin_row(self.node_layout_size.width, self.node_layout_size.height);
cx.begin_center_y_align();
tree_text_props.color = self.color_tree_folder;
let wleft = cx.get_width_left() - 10.;
tree_text_props.wrapping = Wrapping::Ellipsis(wleft);
tree_text_props.wrapping = Wrapping::Ellipsis(cx.get_width_left());
TextIns::draw_walk(cx, name, &tree_text_props);
cx.end_center_y_align();
cx.end_row();
Expand Down Expand Up @@ -443,8 +442,7 @@ impl FileTree {
FileNode::File { name, .. } => {
cx.begin_row(self.node_layout_size.width, self.node_layout_size.height);
cx.begin_center_y_align();
let wleft = cx.get_width_left() - 10.;
tree_text_props.wrapping = Wrapping::Ellipsis(wleft);
tree_text_props.wrapping = Wrapping::Ellipsis(cx.get_width_left());
tree_text_props.color = if is_marked { self.color_tree_folder } else { self.color_tree_file };
TextIns::draw_walk(cx, name, &tree_text_props);
cx.end_center_y_align();
Expand Down
9 changes: 9 additions & 0 deletions zaplib/examples/example_flamegraph/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[package]
name = "example_flamegraph"
version = "0.0.1"
edition = "2021"
publish = false

[dependencies]
zaplib = { path="../../main" }
zaplib_components = { path="../../components" }
26 changes: 26 additions & 0 deletions zaplib/examples/example_flamegraph/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<!DOCTYPE html>
<!--
Copyright (c) 2021-present, Cruise LLC

This source code is licensed under the Apache License, Version 2.0,
found in the LICENSE-APACHE file in the root directory of this source tree.
You may not use this file except in compliance with the License.
-->
<html>

<head>
<meta charset="utf-8">
<meta http-equiv="Cache-Control" content="no-cache">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="mobile-web-app-capable" content="yes">
<title>Example</title>
<script type="text/javascript" src="/zaplib/web/dist/zaplib_runtime.development.js"></script>
<script type="text/javascript">
const env = new URL(window.document.location).searchParams.has("release") ? "release" : "debug";
zaplib.initialize({ wasmModule: `target/wasm32-unknown-unknown/${env}/example_flamegraph.wasm`, defaultStyles: true });
</script>
</head>

</html>
Loading