yaze 0.2.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#if defined(__clang__)
5#include <format>
6#endif
7#include <string>
8
9#include "absl/status/status.h"
10#include "absl/strings/str_format.h"
12#include "imgui/imgui.h"
13
14namespace yaze {
15namespace gui {
16
17struct Color {
18 float red;
19 float blue;
20 float green;
21 float alpha;
22};
23
24inline ImVec4 ConvertColorToImVec4(const Color &color) {
25 return ImVec4(color.red, color.green, color.blue, color.alpha);
26}
27
28inline std::string ColorToHexString(const Color &color) {
29#if defined(__clang__)
30 return std::format(
31 "{:02X}{:02X}{:02X}{:02X}", static_cast<int>(color.red * 255),
32 static_cast<int>(color.green * 255), static_cast<int>(color.blue * 255),
33 static_cast<int>(color.alpha * 255));
34#else
35 return absl::StrFormat("%02X%02X%02X%02X", static_cast<int>(color.red * 255),
36 static_cast<int>(color.green * 255),
37 static_cast<int>(color.blue * 255),
38 static_cast<int>(color.alpha * 255));
39#endif
40}
41
42// A utility function to convert an SnesColor object to an ImVec4 with
43// normalized color values
44ImVec4 ConvertSnesColorToImVec4(const gfx::SnesColor &color);
45
46// The wrapper function for ImGui::ColorButton that takes a SnesColor reference
47IMGUI_API bool SnesColorButton(absl::string_view id, gfx::SnesColor &color,
48 ImGuiColorEditFlags flags = 0,
49 const ImVec2 &size_arg = ImVec2(0, 0));
50
51IMGUI_API bool SnesColorEdit4(absl::string_view label, gfx::SnesColor *color,
52 ImGuiColorEditFlags flags = 0);
53
54absl::Status DisplayPalette(gfx::SnesPalette &palette, bool loaded);
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).
Graphical User Interface (GUI) components for the application.
Definition canvas.cc:15
ImVec4 ConvertColorToImVec4(const Color &color)
Definition color.h:24
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:28
absl::Status DisplayPalette(gfx::SnesPalette &palette, bool loaded)
Definition color.cc:50
Main namespace for the application.
Definition controller.cc:18
float alpha
Definition color.h:21
float green
Definition color.h:20