gui housekeeping

This commit is contained in:
scawful
2024-08-13 01:09:18 -04:00
parent f1f2a7a25f
commit 3c433e5fd5
4 changed files with 6 additions and 15 deletions

View File

@@ -13,7 +13,7 @@ namespace yaze {
namespace app { namespace app {
namespace gui { namespace gui {
ImVec4 ConvertSNESColorToImVec4(const SnesColor& color) { ImVec4 ConvertSnesColorToImVec4(const SnesColor& color) {
return ImVec4(static_cast<float>(color.rgb().x) / 255.0f, return ImVec4(static_cast<float>(color.rgb().x) / 255.0f,
static_cast<float>(color.rgb().y) / 255.0f, static_cast<float>(color.rgb().y) / 255.0f,
static_cast<float>(color.rgb().z) / 255.0f, static_cast<float>(color.rgb().z) / 255.0f,
@@ -26,7 +26,7 @@ IMGUI_API bool SnesColorButton(absl::string_view id, SnesColor& color,
ImGuiColorEditFlags flags, ImGuiColorEditFlags flags,
const ImVec2& size_arg) { const ImVec2& size_arg) {
// Convert the SNES color values to ImGui color values // Convert the SNES color values to ImGui color values
ImVec4 displayColor = ConvertSNESColorToImVec4(color); ImVec4 displayColor = ConvertSnesColorToImVec4(color);
// Call the original ImGui::ColorButton with the converted color // Call the original ImGui::ColorButton with the converted color
bool pressed = ImGui::ColorButton(id.data(), displayColor, flags, size_arg); bool pressed = ImGui::ColorButton(id.data(), displayColor, flags, size_arg);
@@ -41,7 +41,7 @@ IMGUI_API bool SnesColorButton(absl::string_view id, SnesColor& color,
IMGUI_API bool SnesColorEdit4(absl::string_view label, SnesColor* color, IMGUI_API bool SnesColorEdit4(absl::string_view label, SnesColor* color,
ImGuiColorEditFlags flags) { ImGuiColorEditFlags flags) {
ImVec4 displayColor = ConvertSNESColorToImVec4(*color); ImVec4 displayColor = ConvertSnesColorToImVec4(*color);
// Call the original ImGui::ColorEdit4 with the converted color // Call the original ImGui::ColorEdit4 with the converted color
bool pressed = bool pressed =

View File

@@ -18,7 +18,7 @@ using gfx::SnesColor;
// A utility function to convert an SnesColor object to an ImVec4 with // A utility function to convert an SnesColor object to an ImVec4 with
// normalized color values // normalized color values
ImVec4 ConvertSNESColorToImVec4(const SnesColor& color); ImVec4 ConvertSnesColorToImVec4(const SnesColor& color);
// The wrapper function for ImGui::ColorButton that takes a SnesColor reference // The wrapper function for ImGui::ColorButton that takes a SnesColor reference
IMGUI_API bool SnesColorButton(absl::string_view id, SnesColor& color, IMGUI_API bool SnesColorButton(absl::string_view id, SnesColor& color,

View File

@@ -7,6 +7,7 @@ namespace yaze {
namespace app { namespace app {
namespace gui { namespace gui {
// TODO: Add more display settings to popup windows.
void BeginWindowWithDisplaySettings(const char* id, bool* active, void BeginWindowWithDisplaySettings(const char* id, bool* active,
const ImVec2& size, const ImVec2& size,
ImGuiWindowFlags flags) { ImGuiWindowFlags flags) {
@@ -418,6 +419,7 @@ void TextWithSeparators(const absl::string_view& text) {
ImGui::Separator(); ImGui::Separator();
} }
// TODO: Make the ColorsYaze style into a configuration file.
void ColorsYaze() { void ColorsYaze() {
ImGuiStyle* style = &ImGui::GetStyle(); ImGuiStyle* style = &ImGui::GetStyle();
ImVec4* colors = style->Colors; ImVec4* colors = style->Colors;
@@ -517,14 +519,6 @@ void ColorsYaze() {
colors[ImGuiCol_ModalWindowDimBg] = ImVec4(0.20f, 0.20f, 0.20f, 0.35f); colors[ImGuiCol_ModalWindowDimBg] = ImVec4(0.20f, 0.20f, 0.20f, 0.35f);
} }
void RenderTabItem(const std::string& title,
const std::function<void()>& render_func) {
if (ImGui::BeginTabItem(title.c_str())) {
render_func();
ImGui::EndTabItem();
}
}
// ============================================================================ // ============================================================================
// 65816 LanguageDefinition // 65816 LanguageDefinition
// ============================================================================ // ============================================================================

View File

@@ -41,9 +41,6 @@ void ColorsYaze();
TextEditor::LanguageDefinition GetAssemblyLanguageDef(); TextEditor::LanguageDefinition GetAssemblyLanguageDef();
void RenderTabItem(const std::string& title,
const std::function<void()>& render_func);
class BitmapViewer { class BitmapViewer {
public: public:
BitmapViewer() : current_bitmap_index_(0) {} BitmapViewer() : current_bitmap_index_(0) {}