yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
implot_support.h
Go to the documentation of this file.
1#ifndef YAZE_APP_GUI_PLOTS_IMPLOT_SUPPORT_H
2#define YAZE_APP_GUI_PLOTS_IMPLOT_SUPPORT_H
3
4#include <string>
5
7#include "imgui/imgui.h"
8#include "implot.h"
9
10namespace yaze {
11namespace gui {
12namespace plotting {
13
15 float line_weight = 2.0f; // also the marker edge weight in ImPlot 1.x
16 float marker_size = 4.0f;
17 float fill_alpha = 0.35f;
18 float grid_alpha = 0.35f;
19 float background_alpha = 0.9f;
20 bool use_iso_8601 = true;
21 bool use_24h_clock = true;
22};
23
24struct PlotConfig {
25 std::string id;
26 const char* x_label = nullptr;
27 const char* y_label = nullptr;
28 ImVec2 size = ImVec2(0, 0);
29 ImPlotFlags flags = ImPlotFlags_NoLegend;
30 ImPlotAxisFlags x_axis_flags = ImPlotAxisFlags_AutoFit;
31 ImPlotAxisFlags y_axis_flags = ImPlotAxisFlags_AutoFit;
32};
33
35ImPlotStyle BuildStyleFromTheme(const Theme& theme,
36 const PlotStyleConfig& config = {});
37// ImPlot 1.x styles plot items only through the ImPlotSpec passed to each
38// PlotX call; ImPlotStyle no longer carries line, fill, or marker defaults.
39ImPlotSpec BuildItemSpecFromTheme(const Theme& theme,
40 const PlotStyleConfig& config = {});
41
42// Applies the themed ImPlotStyle for its lifetime. Pass item_spec() to each
43// PlotX call inside the scope so items match the theme too.
45 public:
46 PlotStyleScope(const Theme& theme, const PlotStyleConfig& config = {});
48
49 const ImPlotSpec& item_spec() const { return item_spec_; }
50
51 private:
52 ImPlotStyle previous_style_{};
53 ImPlotSpec item_spec_{};
54};
55
56class PlotGuard {
57 public:
58 explicit PlotGuard(const PlotConfig& config);
59 ~PlotGuard();
60
61 bool IsOpen() const { return should_end_; }
62 explicit operator bool() const { return IsOpen(); }
63
64 private:
65 bool should_end_ = false;
66};
67
68} // namespace plotting
69} // namespace gui
70} // namespace yaze
71
72#endif // YAZE_APP_GUI_PLOTS_IMPLOT_SUPPORT_H
PlotGuard(const PlotConfig &config)
const ImPlotSpec & item_spec() const
PlotStyleScope(const Theme &theme, const PlotStyleConfig &config={})
ImPlotSpec BuildItemSpecFromTheme(const Theme &theme, const PlotStyleConfig &config)
ImPlotStyle BuildStyleFromTheme(const Theme &theme, const PlotStyleConfig &config)
Comprehensive theme structure for YAZE.