mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-08-25 19:55:50 +00:00
VideoCommon: add graphics mod editor control for displaying a colored box
This commit is contained in:
parent
130d7a6904
commit
28c2526c48
2 changed files with 58 additions and 0 deletions
|
@ -0,0 +1,46 @@
|
||||||
|
// Copyright 2024 Dolphin Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
#include "VideoCommon/GraphicsModEditor/Controls/MiscControls.h"
|
||||||
|
|
||||||
|
namespace GraphicsModEditor::Controls
|
||||||
|
{
|
||||||
|
bool ColorButton(const char* label, ImVec2 buttonSize, ImVec4 color)
|
||||||
|
{
|
||||||
|
ImGui::PushStyleColor(ImGuiCol_Button, color);
|
||||||
|
bool pressed = ImGui::Button(label, buttonSize);
|
||||||
|
|
||||||
|
// Draw a gradient on top of the button
|
||||||
|
{
|
||||||
|
ImVec2 tl = ImGui::GetItemRectMin();
|
||||||
|
ImVec2 br = ImGui::GetItemRectMax();
|
||||||
|
ImVec2 size = ImGui::GetItemRectSize();
|
||||||
|
|
||||||
|
float k = 0.3f;
|
||||||
|
|
||||||
|
ImVec2 tl_middle(tl.x, tl.y + size.y * (1.f - k));
|
||||||
|
ImVec2 br_middle(br.x, tl.y + size.y * k);
|
||||||
|
|
||||||
|
ImVec4 col_darker(0.f, 0.f, 0.f, 0.2f);
|
||||||
|
ImVec4 col_interm(0.f, 0.f, 0.f, 0.1f);
|
||||||
|
ImVec4 col_transp(0.f, 0.f, 0.f, 0.f);
|
||||||
|
|
||||||
|
ImGui::GetForegroundDrawList()->AddRectFilledMultiColor(
|
||||||
|
tl, br_middle,
|
||||||
|
ImGui::GetColorU32(col_interm), // upper left
|
||||||
|
ImGui::GetColorU32(col_interm), // upper right
|
||||||
|
ImGui::GetColorU32(col_transp), // bottom right
|
||||||
|
ImGui::GetColorU32(col_transp) // bottom left
|
||||||
|
);
|
||||||
|
ImGui::GetForegroundDrawList()->AddRectFilledMultiColor(
|
||||||
|
tl_middle, br,
|
||||||
|
ImGui::GetColorU32(col_transp), // upper left
|
||||||
|
ImGui::GetColorU32(col_transp), // upper right
|
||||||
|
ImGui::GetColorU32(col_darker), // bottom right
|
||||||
|
ImGui::GetColorU32(col_darker) // bottom left
|
||||||
|
);
|
||||||
|
}
|
||||||
|
ImGui::PopStyleColor();
|
||||||
|
return pressed;
|
||||||
|
}
|
||||||
|
} // namespace GraphicsModEditor::Controls
|
|
@ -0,0 +1,12 @@
|
||||||
|
// Copyright 2024 Dolphin Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <imgui.h>
|
||||||
|
|
||||||
|
namespace GraphicsModEditor::Controls
|
||||||
|
{
|
||||||
|
// Pulled from the tips and tricks cafe on 2023, credit to pthom
|
||||||
|
bool ColorButton(const char* label, ImVec2 buttonSize, ImVec4 color);
|
||||||
|
} // namespace GraphicsModEditor::Controls
|
Loading…
Add table
Add a link
Reference in a new issue