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
48IMGUI_API bool DisplayPalette(gfx::SnesPalette &palette, bool loaded);
49
50IMGUI_API absl::Status DisplayEditablePalette(gfx::SnesPalette &palette,
51 const std::string &title = "",
52 bool show_color_picker = false,
53 int colors_per_row = 8,
54 ImGuiColorEditFlags flags = 0);
55
56void SelectablePalettePipeline(uint64_t &palette_id, bool &refresh_graphics,
57 gfx::SnesPalette &palette);
58
59} // namespace gui
60} // namespace yaze
61
62#endif
SNES Color container.
Definition snes_color.h:38
Represents a palette of colors for the Super Nintendo Entertainment System (SNES).
ImVec4 ConvertColorToImVec4(const Color &color)
Definition color.h:21
IMGUI_API bool SnesColorButton(absl::string_view id, gfx::SnesColor &color, ImGuiColorEditFlags flags, const ImVec2 &size_arg)
Definition color.cc:19
ImVec4 ConvertSnesColorToImVec4(const gfx::SnesColor &color)
Definition color.cc:10
void SelectablePalettePipeline(uint64_t &palette_id, bool &refresh_graphics, gfx::SnesPalette &palette)
Definition color.cc:123
IMGUI_API bool SnesColorEdit4(absl::string_view label, gfx::SnesColor *color, ImGuiColorEditFlags flags)
Definition color.cc:36
std::string ColorToHexString(const Color &color)
Definition color.h:25
IMGUI_API bool DisplayPalette(gfx::SnesPalette &palette, bool loaded)
Definition color.cc:50
gfx::SnesColor ConvertImVec4ToSnesColor(const ImVec4 &color)
Definition color.cc:15
absl::Status DisplayEditablePalette(gfx::SnesPalette &palette, const std::string &title, bool show_color_picker, int colors_per_row, ImGuiColorEditFlags flags)
Definition color.cc:166
Main namespace for the application.
float alpha
Definition color.h:18
float green
Definition color.h:16