mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-22 20:07:01 +00:00
ColorPicker,ColorButton: Honor Border/Shadow style settings (#346)
This commit is contained in:
parent
790d0eb5be
commit
a8b202782f
19
imgui.cpp
19
imgui.cpp
@ -2977,6 +2977,16 @@ void ImGui::RenderFrame(ImVec2 p_min, ImVec2 p_max, ImU32 fill_col, bool border,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ImGui::RenderFrameBorder(ImVec2 p_min, ImVec2 p_max, float rounding)
|
||||||
|
{
|
||||||
|
ImGuiWindow* window = GetCurrentWindow();
|
||||||
|
if (window->Flags & ImGuiWindowFlags_ShowBorders)
|
||||||
|
{
|
||||||
|
window->DrawList->AddRect(p_min+ImVec2(1,1), p_max+ImVec2(1,1), GetColorU32(ImGuiCol_BorderShadow), rounding);
|
||||||
|
window->DrawList->AddRect(p_min, p_max, GetColorU32(ImGuiCol_Border), rounding);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Render a triangle to denote expanded/collapsed state
|
// Render a triangle to denote expanded/collapsed state
|
||||||
void ImGui::RenderCollapseTriangle(ImVec2 p_min, bool is_open, float scale)
|
void ImGui::RenderCollapseTriangle(ImVec2 p_min, bool is_open, float scale)
|
||||||
{
|
{
|
||||||
@ -9033,8 +9043,7 @@ bool ImGui::ColorButton(const char* desc_id, const ImVec4& col, ImGuiColorEditFl
|
|||||||
|
|
||||||
bool hovered, held;
|
bool hovered, held;
|
||||||
bool pressed = ButtonBehavior(bb, id, &hovered, &held);
|
bool pressed = ButtonBehavior(bb, id, &hovered, &held);
|
||||||
window->DrawList->AddRectFilled(bb.Min, bb.Max, GetColorU32(*(ImVec4*)&col), style.FrameRounding);
|
RenderFrame(bb.Min, bb.Max, GetColorU32(*(ImVec4*)&col), true, style.FrameRounding);
|
||||||
//window->DrawList->AddRect(bb.Min, bb.Max, GetColorU32(border_col), style.FrameRounding);
|
|
||||||
|
|
||||||
if (hovered && !(flags & ImGuiColorEditFlags_NoTooltip))
|
if (hovered && !(flags & ImGuiColorEditFlags_NoTooltip))
|
||||||
ColorTooltip(desc_id, &col.x, flags & ImGuiColorEditFlags_NoAlpha);
|
ColorTooltip(desc_id, &col.x, flags & ImGuiColorEditFlags_NoAlpha);
|
||||||
@ -9347,6 +9356,7 @@ bool ImGui::ColorPicker4(const char* label, float col[4], ImGuiColorEditFlags fl
|
|||||||
hue_colors[i], hue_colors[i], hue_colors[i + 1], hue_colors[i + 1]);
|
hue_colors[i], hue_colors[i], hue_colors[i + 1], hue_colors[i + 1]);
|
||||||
}
|
}
|
||||||
float bar0_line_y = (float)(int)(picker_pos.y + H * sv_picker_size + 0.5f);
|
float bar0_line_y = (float)(int)(picker_pos.y + H * sv_picker_size + 0.5f);
|
||||||
|
RenderFrameBorder(ImVec2(bar0_pos_x, picker_pos.y), ImVec2(bar0_pos_x + bars_width, picker_pos.y + sv_picker_size), 0.0f);
|
||||||
draw_list->AddLine(ImVec2(bar0_pos_x - bars_line_extrude, bar0_line_y), ImVec2(bar0_pos_x + bars_width + bars_line_extrude, bar0_line_y), IM_COL32_WHITE);
|
draw_list->AddLine(ImVec2(bar0_pos_x - bars_line_extrude, bar0_line_y), ImVec2(bar0_pos_x + bars_width + bars_line_extrude, bar0_line_y), IM_COL32_WHITE);
|
||||||
|
|
||||||
// Render alpha bar
|
// Render alpha bar
|
||||||
@ -9354,7 +9364,9 @@ bool ImGui::ColorPicker4(const char* label, float col[4], ImGuiColorEditFlags fl
|
|||||||
{
|
{
|
||||||
float alpha = ImSaturate(col[3]);
|
float alpha = ImSaturate(col[3]);
|
||||||
float bar1_line_y = (float)(int)(picker_pos.y + (1.0f - alpha) * sv_picker_size + 0.5f);
|
float bar1_line_y = (float)(int)(picker_pos.y + (1.0f - alpha) * sv_picker_size + 0.5f);
|
||||||
draw_list->AddRectFilledMultiColor(ImVec2(bar1_pos_x, picker_pos.y), ImVec2(bar1_pos_x + bars_width, picker_pos.y + sv_picker_size), IM_COL32_WHITE, IM_COL32_WHITE, IM_COL32_BLACK, IM_COL32_BLACK);
|
ImRect bar1_bb(bar1_pos_x, picker_pos.y, bar1_pos_x + bars_width, picker_pos.y + sv_picker_size);
|
||||||
|
draw_list->AddRectFilledMultiColor(bar1_bb.Min, bar1_bb.Max, IM_COL32_WHITE, IM_COL32_WHITE, IM_COL32_BLACK, IM_COL32_BLACK);
|
||||||
|
RenderFrameBorder(bar1_bb.Min, bar1_bb.Max, 0.0f);
|
||||||
draw_list->AddLine(ImVec2(bar1_pos_x - bars_line_extrude, bar1_line_y), ImVec2(bar1_pos_x + bars_width + bars_line_extrude, bar1_line_y), IM_COL32_WHITE);
|
draw_list->AddLine(ImVec2(bar1_pos_x - bars_line_extrude, bar1_line_y), ImVec2(bar1_pos_x + bars_width + bars_line_extrude, bar1_line_y), IM_COL32_WHITE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -9362,6 +9374,7 @@ bool ImGui::ColorPicker4(const char* label, float col[4], ImGuiColorEditFlags fl
|
|||||||
ImU32 hue_color32 = ColorConvertFloat4ToU32(hue_color_f);
|
ImU32 hue_color32 = ColorConvertFloat4ToU32(hue_color_f);
|
||||||
draw_list->AddRectFilledMultiColor(picker_pos, picker_pos + ImVec2(sv_picker_size,sv_picker_size), IM_COL32_WHITE, hue_color32, hue_color32, IM_COL32_WHITE);
|
draw_list->AddRectFilledMultiColor(picker_pos, picker_pos + ImVec2(sv_picker_size,sv_picker_size), IM_COL32_WHITE, hue_color32, hue_color32, IM_COL32_WHITE);
|
||||||
draw_list->AddRectFilledMultiColor(picker_pos, picker_pos + ImVec2(sv_picker_size,sv_picker_size), IM_COL32_BLACK_TRANS, IM_COL32_BLACK_TRANS, IM_COL32_BLACK, IM_COL32_BLACK);
|
draw_list->AddRectFilledMultiColor(picker_pos, picker_pos + ImVec2(sv_picker_size,sv_picker_size), IM_COL32_BLACK_TRANS, IM_COL32_BLACK_TRANS, IM_COL32_BLACK, IM_COL32_BLACK);
|
||||||
|
RenderFrameBorder(picker_pos, picker_pos + ImVec2(sv_picker_size,sv_picker_size), 0.0f);
|
||||||
|
|
||||||
// Render cross-hair
|
// Render cross-hair
|
||||||
const float CROSSHAIR_SIZE = 7.0f;
|
const float CROSSHAIR_SIZE = 7.0f;
|
||||||
|
@ -732,6 +732,7 @@ namespace ImGui
|
|||||||
IMGUI_API void RenderTextWrapped(ImVec2 pos, const char* text, const char* text_end, float wrap_width);
|
IMGUI_API void RenderTextWrapped(ImVec2 pos, const char* text, const char* text_end, float wrap_width);
|
||||||
IMGUI_API void RenderTextClipped(const ImVec2& pos_min, const ImVec2& pos_max, const char* text, const char* text_end, const ImVec2* text_size_if_known, const ImVec2& align = ImVec2(0,0), const ImRect* clip_rect = NULL);
|
IMGUI_API void RenderTextClipped(const ImVec2& pos_min, const ImVec2& pos_max, const char* text, const char* text_end, const ImVec2* text_size_if_known, const ImVec2& align = ImVec2(0,0), const ImRect* clip_rect = NULL);
|
||||||
IMGUI_API void RenderFrame(ImVec2 p_min, ImVec2 p_max, ImU32 fill_col, bool border = true, float rounding = 0.0f);
|
IMGUI_API void RenderFrame(ImVec2 p_min, ImVec2 p_max, ImU32 fill_col, bool border = true, float rounding = 0.0f);
|
||||||
|
IMGUI_API void RenderFrameBorder(ImVec2 p_min, ImVec2 p_max, float rounding = 0.0f);
|
||||||
IMGUI_API void RenderCollapseTriangle(ImVec2 pos, bool is_open, float scale = 1.0f);
|
IMGUI_API void RenderCollapseTriangle(ImVec2 pos, bool is_open, float scale = 1.0f);
|
||||||
IMGUI_API void RenderBullet(ImVec2 pos);
|
IMGUI_API void RenderBullet(ImVec2 pos);
|
||||||
IMGUI_API void RenderCheckMark(ImVec2 pos, ImU32 col);
|
IMGUI_API void RenderCheckMark(ImVec2 pos, ImU32 col);
|
||||||
|
Loading…
Reference in New Issue
Block a user