diff options
| author | hachem <im@hachem.wtf> | 2026-09-18 12:25:58 +0200 |
|---|---|---|
| committer | hachem <im@hachem.wtf> | 2026-09-18 12:25:58 +0200 |
| commit | 4f74d1400180ca4ad7cfcd1903386fda8779818d (patch) | |
| tree | 258a332c3076045461b5d6f8592a52140225abd1 /src/ui/source_view.h | |
| parent | 0846724177d823b632f2a4deffdcb5b6e226cd56 (diff) | |
feat: improve layout and themes
Diffstat (limited to 'src/ui/source_view.h')
| -rw-r--r-- | src/ui/source_view.h | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/src/ui/source_view.h b/src/ui/source_view.h index 7dd949d..1e68265 100644 --- a/src/ui/source_view.h +++ b/src/ui/source_view.h @@ -7,6 +7,7 @@ #include <filesystem> #include <optional> #include <string> +#include <unordered_set> #include <vector> struct ImDrawList; @@ -46,6 +47,14 @@ namespace Hsdbg auto draw(Debugger& debugger) -> void; auto set_highlighted_line(uint32_t line) -> void; + + // the lines of the function the selected frame is in (zero for unknown): + // live values are only annotated inside it + auto set_frame_extent(uint32_t first, uint32_t last) -> void; + + // names of locals that moved since the previous stop; their annotations + // take the accent. the set is owned by the caller and read each frame + auto set_changed_locals(const std::unordered_set<std::string>* names) -> void { m_changed_locals = names; } auto set_highlighting(bool enabled) -> void { m_highlighting_enabled = enabled; } auto set_line_numbers(bool enabled) -> void { m_line_numbers = enabled; } auto set_highlight_current_line(bool enabled) -> void { m_highlight_current_line = enabled; } @@ -54,8 +63,12 @@ namespace Hsdbg auto set_syntax_color(size_t kind, unsigned int color) -> void { m_syntax_colors[kind] = color; } auto set_current_line_color(unsigned int color) -> void { m_current_line_color = color; } - // the monospace face the code (and its gutter) is rendered in + // the monospace face the code (and its gutter) is rendered in, and its + // size in px before ui scaling: cmd/ctrl + wheel over the code nudges the + // size, and the ui reads it back to persist it auto set_mono_font(ImFont* font) -> void { m_mono_font = font; } + auto set_font_size(float size) -> void { m_font_size = size; } + auto font_size() const -> float { return m_font_size; } auto path() const -> const std::filesystem::path& { return m_path; } auto line_count() const -> size_t { return m_lines.size(); } @@ -77,6 +90,7 @@ namespace Hsdbg private: auto draw_open_bar() -> void; auto draw_lines(Debugger& debugger) -> void; + auto handle_zoom() -> void; // renders a highlighted macro name: hovering previews its expansion, // clicking records the invocation for the macros panel to open @@ -107,5 +121,18 @@ namespace Hsdbg std::string m_error; uint32_t m_highlighted_line = 0; bool m_scroll_to_highlight = false; + + // the location bar shows the open path as a breadcrumb; a click swaps in + // the text field (and asks for its focus) until a file opens or it loses focus + bool m_editing_path = false; + bool m_focus_path = false; + + float m_font_size = 16.0f; + float m_zoom_accumulator = 0.0f; // wheel travel not yet turned into a step + double m_zoom_badge_until = 0.0; // the "NN px" badge shows until this time + + uint32_t m_frame_first_line = 0; + uint32_t m_frame_last_line = 0; + const std::unordered_set<std::string>* m_changed_locals = nullptr; }; } |
