yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
color.h
Go to the documentation of this file.
1#ifndef YAZE_GUI_COLOR_H
2#define YAZE_GUI_COLOR_H
3
4#include "absl/strings/str_format.h"
5#include <string>
6
7#include "absl/status/status.h"
9#include "imgui/imgui.h"
10
11namespace yaze {
12namespace gui {
13
14struct Color {
15 float red;
16 float green;
17 float blue;
18 float alpha;
19};
20
21inline ImVec4 ConvertColorToImVec4(const Color &color) {
22 return ImVec4(color.red, color.green, color.blue, color.alpha);
23}
24
25inline std::string ColorToHexString(const Color &color) {
26 return absl::StrFormat("%02X%02X%02X%02X",
27 static_cast<int>(color.red * 255),
28 static_cast<int>(color.green * 255),
29 static_cast<int>(color.blue * 255),
30 static_cast<int>(color.alpha * 255));
31}
32
33// A utility function to convert an SnesColor object to an ImVec4 with
34// normalized color values
35ImVec4 ConvertSnesColorToImVec4(const gfx::SnesColor &color);
36
37// A utility function to convert an ImVec4 to an SnesColor object
38gfx::SnesColor ConvertImVec4ToSnesColor(const ImVec4 &color);
39
40// The wrapper function for ImGui::ColorButton that takes a SnesColor reference
41IMGUI_API bool SnesColorButton(absl::string_view id, gfx::SnesColor &color,
42 ImGuiColorEditFlags flags = 0,
43 const ImVec2 &size_arg = ImVec2(0, 0));
44
45IMGUI_API bool SnesColorEdit4(absl::string_view label, gfx::SnesColor *color,
46 ImGuiColorEditFlags flags = 0);
47
48// ============================================================================
49// Palette Widget Functions
50// ============================================================================
51
59IMGUI_API bool InlinePaletteSelector(gfx::SnesPalette &palette,
60 int num_colors = 8,
61 int* selected_index = nullptr);
62
70IMGUI_API absl::Status InlinePaletteEditor(gfx::SnesPalette &palette,
71 const std::string &title = "",
72 ImGuiColorEditFlags flags = 0);
73
81IMGUI_API bool PopupPaletteEditor(const char* popup_id,
82 gfx::SnesPalette &palette,
83 ImGuiColorEditFlags flags = 0);
84
85// Legacy functions (kept for compatibility, will be deprecated)
86IMGUI_API bool DisplayPalette(gfx::SnesPalette &palette, bool loaded);
87
88IMGUI_API absl::Status DisplayEditablePalette(gfx::SnesPalette &palette,
89 const std::string &title = "",
90 bool show_color_picker = false,
91 int colors_per_row = 8,
92 ImGuiColorEditFlags flags = 0);
93
94void SelectablePalettePipeline(uint64_t &palette_id, bool &refresh_graphics,
95 gfx::SnesPalette &palette);
96
97// Palette color button with selection and modification indicators
98IMGUI_API bool PaletteColorButton(const char* id, const gfx::SnesColor& color,
99 bool is_selected, bool is_modified,
100 const ImVec2& size = ImVec2(28, 28),
101 ImGuiColorEditFlags flags = 0);
102
103} // namespace gui
104} // namespace yaze
105
106#endif
SNES Color container.
Definition snes_color.h:109
Represents a palette of colors for the Super Nintendo Entertainment System (SNES).
ImVec4 ConvertColorToImVec4(const Color &color)
Definition color.h:21
IMGUI_API bool InlinePaletteSelector(gfx::SnesPalette &palette, int num_colors, int *selected_index)
Small inline palette selector - just color buttons for selection.
Definition color.cc:77
IMGUI_API bool SnesColorButton(absl::string_view id, gfx::SnesColor &color, ImGuiColorEditFlags flags, const ImVec2 &size_arg)
Definition color.cc:37
IMGUI_API bool PopupPaletteEditor(const char *popup_id, gfx::SnesPalette &palette, ImGuiColorEditFlags flags)
Popup palette editor - same as inline but in a popup.
Definition color.cc:183
IMGUI_API absl::Status InlinePaletteEditor(gfx::SnesPalette &palette, const std::string &title, ImGuiColorEditFlags flags)
Full inline palette editor with color picker and copy options.
Definition color.cc:117
IMGUI_API bool PaletteColorButton(const char *id, const gfx::SnesColor &color, bool is_selected, bool is_modified, const ImVec2 &size, ImGuiColorEditFlags flags)
Definition color.cc:445
ImVec4 ConvertSnesColorToImVec4(const gfx::SnesColor &color)
Convert SnesColor to standard ImVec4 for display.
Definition color.cc:19
void SelectablePalettePipeline(uint64_t &palette_id, bool &refresh_graphics, gfx::SnesPalette &palette)
Definition color.cc:305
IMGUI_API bool SnesColorEdit4(absl::string_view label, gfx::SnesColor *color, ImGuiColorEditFlags flags)
Definition color.cc:54
std::string ColorToHexString(const Color &color)
Definition color.h:25
IMGUI_API bool DisplayPalette(gfx::SnesPalette &palette, bool loaded)
Definition color.cc:232
gfx::SnesColor ConvertImVec4ToSnesColor(const ImVec4 &color)
Convert standard ImVec4 to SnesColor.
Definition color.cc:32
absl::Status DisplayEditablePalette(gfx::SnesPalette &palette, const std::string &title, bool show_color_picker, int colors_per_row, ImGuiColorEditFlags flags)
Definition color.cc:348
Main namespace for the application.
Definition controller.cc:20
float alpha
Definition color.h:18
float green
Definition color.h:16