mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-03-28 07:47:03 -05:00
impr: Make reset button of color settings widgets look nicer
This commit is contained in:
@@ -362,16 +362,25 @@ namespace hex {
|
||||
m_flags = flags;
|
||||
}
|
||||
|
||||
static bool areColorsEquals(const std::array<float, 4> &a, const std::array<float, 4> &b) {
|
||||
return std::abs(a[0] - b[0]) < 0.005f &&
|
||||
std::abs(a[1] - b[1]) < 0.005f &&
|
||||
std::abs(a[2] - b[2]) < 0.005f &&
|
||||
std::abs(a[3] - b[3]) < 0.005f;
|
||||
}
|
||||
|
||||
bool ColorPicker::draw(const std::string &name) {
|
||||
ImGui::PushID(name.c_str());
|
||||
auto result = ImGui::ColorEdit4("##color_picker", m_value.data(), ImGuiColorEditFlags_NoInputs | m_flags);
|
||||
|
||||
ImGui::SameLine();
|
||||
|
||||
if (ImGui::Button("X", ImGui::GetStyle().FramePadding * 2 + ImVec2(ImGui::GetTextLineHeight(), ImGui::GetTextLineHeight()))) {
|
||||
ImGui::BeginDisabled(areColorsEquals(m_value, m_defaultValue));
|
||||
if (ImGuiExt::DimmedButton("\xee\xab\xa2", ImGui::GetStyle().FramePadding * 2 + ImVec2(ImGui::GetTextLineHeight(), ImGui::GetTextLineHeight()))) {
|
||||
m_value = m_defaultValue;
|
||||
result = true;
|
||||
}
|
||||
ImGui::EndDisabled();
|
||||
|
||||
ImGui::SameLine();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user