yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
tile16_editor_action_state.h
Go to the documentation of this file.
1#ifndef YAZE_APP_EDITOR_OVERWORLD_TILE16_EDITOR_ACTION_STATE_H
2#define YAZE_APP_EDITOR_OVERWORLD_TILE16_EDITOR_ACTION_STATE_H
3
4#include <algorithm>
5
6namespace yaze {
7namespace editor {
8
10 bool can_write_pending = false;
11 bool can_discard_all = false;
12 bool can_discard_current = false;
13 bool can_undo = false;
14 bool can_redo = false;
15};
16
18 bool has_pending, bool current_tile_pending, bool can_undo, bool can_redo) {
20 state.can_write_pending = has_pending;
21 state.can_discard_all = has_pending;
22 state.can_discard_current = current_tile_pending;
23 state.can_undo = can_undo;
24 state.can_redo = can_redo;
25 return state;
26}
27
28inline int ComputeTile16CompactActionColumnCount(float available_width_px) {
29 if (available_width_px >= 900.0f) {
30 return 7;
31 }
32 if (available_width_px >= 620.0f) {
33 return 5;
34 }
35 if (available_width_px >= 420.0f) {
36 return 3;
37 }
38 if (available_width_px >= 260.0f) {
39 return 2;
40 }
41 return 1;
42}
43
44inline int ComputeTile16ActionRowCount(int action_count, int column_count) {
45 if (action_count <= 0) {
46 return 0;
47 }
48 if (column_count <= 0) {
49 column_count = 1;
50 }
51 return (action_count + column_count - 1) / column_count;
52}
53
54inline float ComputeTile16PaletteButtonSize(float available_width_px) {
55 if (available_width_px <= 0.0f) {
56 return 24.0f;
57 }
58 return std::clamp((available_width_px - 16.0f) / 4.0f, 24.0f, 32.0f);
59}
60
61} // namespace editor
62} // namespace yaze
63
64#endif // YAZE_APP_EDITOR_OVERWORLD_TILE16_EDITOR_ACTION_STATE_H
int ComputeTile16CompactActionColumnCount(float available_width_px)
float ComputeTile16PaletteButtonSize(float available_width_px)
Tile16ActionControlState ComputeTile16ActionControlState(bool has_pending, bool current_tile_pending, bool can_undo, bool can_redo)
int ComputeTile16ActionRowCount(int action_count, int column_count)