yaze
0.3.2
Link to the Past ROM Editor
Loading...
Searching...
No Matches
canvas_types.h
Go to the documentation of this file.
1
#ifndef YAZE_APP_GUI_CANVAS_CANVAS_TYPES_H
2
#define YAZE_APP_GUI_CANVAS_CANVAS_TYPES_H
3
4
// POD and option structs for the canvas subsystem.
5
6
#include <cstdint>
7
#include <optional>
8
9
#include "imgui/imgui.h"
10
11
namespace
yaze
{
12
namespace
gui {
13
14
enum class
CanvasType
{
kTile
,
kBlock
,
kMap
};
15
enum class
CanvasMode
{
kPaint
,
kSelect
};
16
enum class
CanvasGridSize
{
k8x8
,
k16x16
,
k32x32
,
k64x64
};
17
18
// Describes the role this canvas plays: what it's for, distinct from
19
// CanvasMode which describes the input behavior the user is currently
20
// performing. A canvas can have CanvasMode::kSelect while being either a
21
// kSelectionSource (picker) or a kEditableScratchpad (rect-select-then-edit).
22
//
23
// Editors set this once at Init/Begin time. Canvas reads it for cursor and
24
// hover-hint defaults; it does not gate operations.
25
enum class
CanvasRole
: uint8_t {
26
kPreviewOnly
,
// Read-only display (gfx-group sheet thumbnail).
27
kSelectionSource
,
// Read-only tile/region picker source.
28
kEditableScratchpad
,
// User-editable target (default).
29
kCompositeOutput
,
// Post-render composite output.
30
};
31
32
// True when the canvas's underlying bitmap is owned by the editor and may be
33
// mutated through it. False for kPreviewOnly/kSelectionSource canvases whose
34
// bitmap is a shared view (gfx-group sheets, sprite atlas thumbnails) where
35
// destructive operations like Reformat/SetPalette would corrupt every other
36
// view of the same data. The context menu uses this to suppress
37
// "Pixel Format" and "Edit Palette" entries on read-only canvases.
38
constexpr
bool
RoleAllowsBitmapMutation
(
CanvasRole
role) {
39
return
role ==
CanvasRole::kEditableScratchpad
||
40
role ==
CanvasRole::kCompositeOutput
;
41
}
42
43
struct
CanvasRuntime
{
44
ImDrawList*
draw_list
=
nullptr
;
45
ImVec2
canvas_p0
= ImVec2(0, 0);
46
ImVec2
canvas_sz
= ImVec2(0, 0);
47
ImVec2
scrolling
= ImVec2(0, 0);
48
ImVec2
mouse_pos_local
= ImVec2(0, 0);
49
bool
hovered
=
false
;
50
float
grid_step
= 16.0f;
51
float
scale
= 1.0f;
52
ImVec2
content_size
= ImVec2(0, 0);
53
};
54
55
struct
CanvasFrameOptions
{
56
ImVec2
canvas_size
= ImVec2(0, 0);
57
bool
draw_context_menu
=
true
;
58
bool
draw_grid
=
true
;
59
std::optional<float>
grid_step
;
60
bool
draw_overlay
=
true
;
61
bool
render_popups
=
true
;
62
bool
use_child_window
=
false
;
63
bool
show_scrollbar
=
false
;
64
};
65
66
struct
BitmapPreviewOptions
{
67
ImVec2
canvas_size
= ImVec2(0, 0);
68
ImVec2
dest_pos
= ImVec2(0, 0);
69
ImVec2
dest_size
= ImVec2(0, 0);
70
ImVec2
src_pos
= ImVec2(0, 0);
71
ImVec2
src_size
= ImVec2(0, 0);
72
float
scale
= 1.0f;
73
int
alpha
= 255;
74
bool
draw_context_menu
=
false
;
75
bool
draw_grid
=
true
;
76
std::optional<float>
grid_step
;
77
bool
draw_overlay
=
true
;
78
bool
render_popups
=
true
;
79
bool
ensure_texture
=
false
;
80
int
selector_tile_size
= 0;
81
int
selector_tile_size_y
= 0;
82
};
83
84
struct
TileHit
{
85
int
tile_index
= -1;
86
ImVec2
tile_origin
= ImVec2(0, 0);
87
ImVec2
tile_size
= ImVec2(0, 0);
88
};
89
90
struct
BitmapDrawOpts
{
91
ImVec2
dest_pos
= ImVec2(0, 0);
92
ImVec2
dest_size
= ImVec2(0, 0);
93
ImVec2
src_pos
= ImVec2(0, 0);
94
ImVec2
src_size
= ImVec2(0, 0);
95
float
scale
= 1.0f;
96
int
alpha
= 255;
97
bool
ensure_texture
=
true
;
98
};
99
100
struct
SelectorPanelOpts
{
101
ImVec2
canvas_size
= ImVec2(0, 0);
102
float
grid_step
= 16.0f;
103
bool
show_grid
=
true
;
104
bool
show_overlay
=
true
;
105
bool
render_popups
=
true
;
106
bool
ensure_texture
=
true
;
107
int
tile_selector_size
= 0;
108
int
tile_selector_size_y
= 0;
109
};
110
111
struct
PreviewPanelOpts
{
112
ImVec2
canvas_size
= ImVec2(0, 0);
113
ImVec2
dest_pos
= ImVec2(0, 0);
114
ImVec2
dest_size
= ImVec2(0, 0);
115
float
grid_step
= 0.0f;
116
bool
render_popups
=
false
;
117
bool
ensure_texture
=
true
;
118
};
119
120
struct
ZoomToFitResult
{
121
float
scale
= 1.0f;
122
ImVec2
scroll
= ImVec2(0, 0);
123
};
124
125
}
// namespace gui
126
}
// namespace yaze
127
128
#endif
// YAZE_APP_GUI_CANVAS_CANVAS_TYPES_H
yaze::gui::CanvasMode
CanvasMode
Definition
canvas_types.h:15
yaze::gui::CanvasMode::kSelect
@ kSelect
yaze::gui::CanvasMode::kPaint
@ kPaint
yaze::gui::CanvasRole
CanvasRole
Definition
canvas_types.h:25
yaze::gui::CanvasRole::kCompositeOutput
@ kCompositeOutput
yaze::gui::CanvasRole::kEditableScratchpad
@ kEditableScratchpad
yaze::gui::CanvasRole::kPreviewOnly
@ kPreviewOnly
yaze::gui::CanvasRole::kSelectionSource
@ kSelectionSource
yaze::gui::CanvasType
CanvasType
Definition
canvas_types.h:14
yaze::gui::CanvasType::kBlock
@ kBlock
yaze::gui::CanvasType::kTile
@ kTile
yaze::gui::CanvasType::kMap
@ kMap
yaze::gui::RoleAllowsBitmapMutation
constexpr bool RoleAllowsBitmapMutation(CanvasRole role)
Definition
canvas_types.h:38
yaze::gui::CanvasGridSize
CanvasGridSize
Definition
canvas_types.h:16
yaze::gui::CanvasGridSize::k16x16
@ k16x16
yaze::gui::CanvasGridSize::k8x8
@ k8x8
yaze::gui::CanvasGridSize::k32x32
@ k32x32
yaze::gui::CanvasGridSize::k64x64
@ k64x64
yaze
Definition
patch_export_usage.cc:8
yaze::gui::BitmapDrawOpts
Definition
canvas_types.h:90
yaze::gui::BitmapDrawOpts::alpha
int alpha
Definition
canvas_types.h:96
yaze::gui::BitmapDrawOpts::dest_pos
ImVec2 dest_pos
Definition
canvas_types.h:91
yaze::gui::BitmapDrawOpts::dest_size
ImVec2 dest_size
Definition
canvas_types.h:92
yaze::gui::BitmapDrawOpts::src_size
ImVec2 src_size
Definition
canvas_types.h:94
yaze::gui::BitmapDrawOpts::src_pos
ImVec2 src_pos
Definition
canvas_types.h:93
yaze::gui::BitmapDrawOpts::scale
float scale
Definition
canvas_types.h:95
yaze::gui::BitmapDrawOpts::ensure_texture
bool ensure_texture
Definition
canvas_types.h:97
yaze::gui::BitmapPreviewOptions
Definition
canvas_types.h:66
yaze::gui::BitmapPreviewOptions::scale
float scale
Definition
canvas_types.h:72
yaze::gui::BitmapPreviewOptions::alpha
int alpha
Definition
canvas_types.h:73
yaze::gui::BitmapPreviewOptions::selector_tile_size_y
int selector_tile_size_y
Definition
canvas_types.h:81
yaze::gui::BitmapPreviewOptions::src_pos
ImVec2 src_pos
Definition
canvas_types.h:70
yaze::gui::BitmapPreviewOptions::draw_grid
bool draw_grid
Definition
canvas_types.h:75
yaze::gui::BitmapPreviewOptions::canvas_size
ImVec2 canvas_size
Definition
canvas_types.h:67
yaze::gui::BitmapPreviewOptions::src_size
ImVec2 src_size
Definition
canvas_types.h:71
yaze::gui::BitmapPreviewOptions::ensure_texture
bool ensure_texture
Definition
canvas_types.h:79
yaze::gui::BitmapPreviewOptions::grid_step
std::optional< float > grid_step
Definition
canvas_types.h:76
yaze::gui::BitmapPreviewOptions::draw_context_menu
bool draw_context_menu
Definition
canvas_types.h:74
yaze::gui::BitmapPreviewOptions::selector_tile_size
int selector_tile_size
Definition
canvas_types.h:80
yaze::gui::BitmapPreviewOptions::draw_overlay
bool draw_overlay
Definition
canvas_types.h:77
yaze::gui::BitmapPreviewOptions::render_popups
bool render_popups
Definition
canvas_types.h:78
yaze::gui::BitmapPreviewOptions::dest_pos
ImVec2 dest_pos
Definition
canvas_types.h:68
yaze::gui::BitmapPreviewOptions::dest_size
ImVec2 dest_size
Definition
canvas_types.h:69
yaze::gui::CanvasFrameOptions
Definition
canvas_types.h:55
yaze::gui::CanvasFrameOptions::show_scrollbar
bool show_scrollbar
Definition
canvas_types.h:63
yaze::gui::CanvasFrameOptions::draw_context_menu
bool draw_context_menu
Definition
canvas_types.h:57
yaze::gui::CanvasFrameOptions::render_popups
bool render_popups
Definition
canvas_types.h:61
yaze::gui::CanvasFrameOptions::use_child_window
bool use_child_window
Definition
canvas_types.h:62
yaze::gui::CanvasFrameOptions::draw_grid
bool draw_grid
Definition
canvas_types.h:58
yaze::gui::CanvasFrameOptions::canvas_size
ImVec2 canvas_size
Definition
canvas_types.h:56
yaze::gui::CanvasFrameOptions::grid_step
std::optional< float > grid_step
Definition
canvas_types.h:59
yaze::gui::CanvasFrameOptions::draw_overlay
bool draw_overlay
Definition
canvas_types.h:60
yaze::gui::CanvasRuntime
Definition
canvas_types.h:43
yaze::gui::CanvasRuntime::scale
float scale
Definition
canvas_types.h:51
yaze::gui::CanvasRuntime::scrolling
ImVec2 scrolling
Definition
canvas_types.h:47
yaze::gui::CanvasRuntime::grid_step
float grid_step
Definition
canvas_types.h:50
yaze::gui::CanvasRuntime::canvas_sz
ImVec2 canvas_sz
Definition
canvas_types.h:46
yaze::gui::CanvasRuntime::mouse_pos_local
ImVec2 mouse_pos_local
Definition
canvas_types.h:48
yaze::gui::CanvasRuntime::draw_list
ImDrawList * draw_list
Definition
canvas_types.h:44
yaze::gui::CanvasRuntime::content_size
ImVec2 content_size
Definition
canvas_types.h:52
yaze::gui::CanvasRuntime::canvas_p0
ImVec2 canvas_p0
Definition
canvas_types.h:45
yaze::gui::CanvasRuntime::hovered
bool hovered
Definition
canvas_types.h:49
yaze::gui::PreviewPanelOpts
Definition
canvas_types.h:111
yaze::gui::PreviewPanelOpts::ensure_texture
bool ensure_texture
Definition
canvas_types.h:117
yaze::gui::PreviewPanelOpts::dest_pos
ImVec2 dest_pos
Definition
canvas_types.h:113
yaze::gui::PreviewPanelOpts::render_popups
bool render_popups
Definition
canvas_types.h:116
yaze::gui::PreviewPanelOpts::canvas_size
ImVec2 canvas_size
Definition
canvas_types.h:112
yaze::gui::PreviewPanelOpts::dest_size
ImVec2 dest_size
Definition
canvas_types.h:114
yaze::gui::PreviewPanelOpts::grid_step
float grid_step
Definition
canvas_types.h:115
yaze::gui::SelectorPanelOpts
Definition
canvas_types.h:100
yaze::gui::SelectorPanelOpts::grid_step
float grid_step
Definition
canvas_types.h:102
yaze::gui::SelectorPanelOpts::canvas_size
ImVec2 canvas_size
Definition
canvas_types.h:101
yaze::gui::SelectorPanelOpts::tile_selector_size_y
int tile_selector_size_y
Definition
canvas_types.h:108
yaze::gui::SelectorPanelOpts::render_popups
bool render_popups
Definition
canvas_types.h:105
yaze::gui::SelectorPanelOpts::tile_selector_size
int tile_selector_size
Definition
canvas_types.h:107
yaze::gui::SelectorPanelOpts::show_overlay
bool show_overlay
Definition
canvas_types.h:104
yaze::gui::SelectorPanelOpts::show_grid
bool show_grid
Definition
canvas_types.h:103
yaze::gui::SelectorPanelOpts::ensure_texture
bool ensure_texture
Definition
canvas_types.h:106
yaze::gui::TileHit
Definition
canvas_types.h:84
yaze::gui::TileHit::tile_index
int tile_index
Definition
canvas_types.h:85
yaze::gui::TileHit::tile_origin
ImVec2 tile_origin
Definition
canvas_types.h:86
yaze::gui::TileHit::tile_size
ImVec2 tile_size
Definition
canvas_types.h:87
yaze::gui::ZoomToFitResult
Definition
canvas_types.h:120
yaze::gui::ZoomToFitResult::scale
float scale
Definition
canvas_types.h:121
yaze::gui::ZoomToFitResult::scroll
ImVec2 scroll
Definition
canvas_types.h:122
src
app
gui
canvas
canvas_types.h
Generated by
1.10.0