137 if (!palette_group_result) {
138 ImGui::TextDisabled(
"Invalid palette group");
142 auto palette_group = *palette_group_result;
144 ImGui::TextDisabled(
"Invalid palette index");
151 int colors_per_row = 16;
152 int total_colors =
static_cast<int>(palette.size());
153 int num_rows = (total_colors + colors_per_row - 1) / colors_per_row;
155 for (
int row = 0; row < num_rows; row++) {
156 for (
int col = 0; col < colors_per_row; col++) {
157 int idx = row * colors_per_row + col;
158 if (idx >= total_colors)
break;
160 if (col > 0) ImGui::SameLine();
162 auto& color = palette[idx];
163 ImVec4 im_color(color.rgb().x / 255.0f, color.rgb().y / 255.0f,
164 color.rgb().z / 255.0f, 1.0f);
167 bool in_sub_palette =
169 if (in_sub_palette) {
170 ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 2.0f);
171 ImGui::PushStyleColor(ImGuiCol_Border, ImVec4(1.0f, 1.0f, 0.0f, 1.0f));
174 std::string
id = absl::StrFormat(
"##PalColor%d", idx);
175 if (ImGui::ColorButton(
id.c_str(), im_color,
176 ImGuiColorEditFlags_NoTooltip, ImVec2(18, 18))) {
182 if (in_sub_palette) {
183 ImGui::PopStyleColor();
184 ImGui::PopStyleVar();
187 if (ImGui::IsItemHovered()) {
188 ImGui::BeginTooltip();
189 ImGui::Text(
"Index: %d (Row %d, Col %d)", idx, row, col);
190 ImGui::Text(
"SNES: $%04X", color.snes());
191 ImGui::Text(
"RGB: %d, %d, %d",
static_cast<int>(color.rgb().x),
192 static_cast<int>(color.rgb().y),
193 static_cast<int>(color.rgb().z));
200 ImGui::Text(
"Sub-palette Row:");
201 for (
int i = 0; i < std::min(8, num_rows); i++) {
202 if (i > 0) ImGui::SameLine();
205 ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0.3f, 0.5f, 0.8f, 1.0f));
207 if (ImGui::SmallButton(absl::StrFormat(
"%d", i).c_str())) {
212 ImGui::PopStyleColor();