yaze 0.2.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
input.h
Go to the documentation of this file.
1#ifndef YAZE_APP_CORE_INPUT_H
2#define YAZE_APP_CORE_INPUT_H
3
4#define IMGUI_DEFINE_MATH_OPERATORS
5
6#include <cstddef>
7#include <cstdint>
8#include <functional>
9#include <optional>
10#include <string>
11#include <variant>
12#include <vector>
13
14#include "absl/strings/string_view.h"
15#include "app/gfx/snes_tile.h"
16#include "imgui/imgui.h"
17
18namespace yaze {
19namespace gui {
20
21constexpr ImVec2 kDefaultModalSize = ImVec2(200, 0);
22constexpr ImVec2 kZeroPos = ImVec2(0, 0);
23
24IMGUI_API bool InputHex(const char *label, uint64_t *data);
25IMGUI_API bool InputHex(const char *label, int *data, int num_digits = 4,
26 float input_width = 50.f);
27
28IMGUI_API bool InputHexShort(const char *label, uint32_t *data);
29IMGUI_API bool InputHexWord(const char *label, uint16_t *data,
30 float input_width = 50.f, bool no_step = false);
31IMGUI_API bool InputHexWord(const char *label, int16_t *data,
32 float input_width = 50.f, bool no_step = false);
33IMGUI_API bool InputHexByte(const char *label, uint8_t *data,
34 float input_width = 50.f, bool no_step = false);
35
36IMGUI_API bool InputHexByte(const char *label, uint8_t *data, uint8_t max_value,
37 float input_width = 50.f, bool no_step = false);
38
39IMGUI_API bool ListBox(const char *label, int *current_item,
40 const std::vector<std::string> &items,
41 int height_in_items = -1);
42
43bool InputTileInfo(const char *label, gfx::TileInfo *tile_info);
44
45using ItemLabelFlags = enum ItemLabelFlag {
46 Left = 1u << 0u,
47 Right = 1u << 1u,
48 Default = Left,
49};
50
51IMGUI_API void ItemLabel(absl::string_view title, ItemLabelFlags flags);
52
53IMGUI_API ImGuiID GetID(const std::string &id);
54
55using GuiElement = std::variant<std::function<void()>, std::string>;
56
57struct Table {
58 const char *id;
60 ImGuiTableFlags flags;
61 ImVec2 size;
62 std::vector<std::string> column_labels;
63 std::vector<GuiElement> column_contents;
64};
65
66void AddTableColumn(Table &table, const std::string &label, GuiElement element);
67
68void DrawTable(Table &params);
69
70} // namespace gui
71} // namespace yaze
72
73#endif
SNES 16-bit tile metadata container.
Definition snes_tile.h:49
void ItemLabel(absl::string_view title, ItemLabelFlags flags)
Definition input.cc:187
bool InputHexWord(const char *label, uint16_t *data, float input_width, bool no_step)
Definition input.cc:153
bool ListBox(const char *label, int *current_item, const std::vector< std::string > &items, int height_in_items)
Definition input.cc:230
bool InputHexShort(const char *label, uint32_t *data)
Definition input.cc:147
void AddTableColumn(Table &table, const std::string &label, GuiElement element)
Definition input.cc:258
enum ItemLabelFlag { Left=1u<< 0u, Right=1u<< 1u, Default=Left, } ItemLabelFlags
Definition input.h:45
void DrawTable(Table &params)
Definition input.cc:263
bool InputHex(const char *label, uint64_t *data)
Definition input.cc:134
bool InputTileInfo(const char *label, gfx::TileInfo *tile_info)
Definition input.cc:242
std::variant< std::function< void()>, std::string > GuiElement
Definition input.h:55
constexpr ImVec2 kZeroPos
Definition input.h:22
constexpr ImVec2 kDefaultModalSize
Definition input.h:21
ImGuiID GetID(const std::string &id)
Definition input.cc:256
bool InputHexByte(const char *label, uint8_t *data, float input_width, bool no_step)
Definition input.cc:167
Main namespace for the application.
Definition controller.cc:18
std::vector< std::string > column_labels
Definition input.h:62
std::vector< GuiElement > column_contents
Definition input.h:63
ImVec2 size
Definition input.h:61
int num_columns
Definition input.h:59
const char * id
Definition input.h:58
ImGuiTableFlags flags
Definition input.h:60