-
Автор темы
- #1
I just want to reverse the checkbox with text. Where is "Hud" i want this checkbox and after this text
Like as in 2 picture
Like as in 2 picture
C++:
struct
{
std::map<ImGuiID, float> slider_size;
std::map<ImGuiID, float> slider_old_value;
std::map<ImGuiID, float> slider_active_value;
std::map<ImGuiID, ImVec4> slider_hover_color;
std::map<ImGuiID, ImVec4> begin_combo_hover_color;
std::map<ImGuiID, float> begin_combo_size_active;
std::map<ImGuiID, float> checkbox_pos_active;
std::map<ImGuiID, float> checkbox_size_active;
std::map<ImGuiID, ImVec4> tab_button_hover_color;
std::map<ImGuiID, ImVec4> selectable_hover_color;
std::map<ImGuiID, ImVec4> custom_button_hover_color;
std::map<ImGuiID, ImVec4> custom_button_rect_hover_color;
} m_Animations;
bool ImGui::Checkbox(const char* label, bool* v)
{
ImGuiWindow* window = GetCurrentWindow();
if (window->SkipItems)
return false;
ImGuiContext& g = *GImGui;
const ImGuiStyle& style = g.Style;
const ImGuiID id = window->GetID(label);
const ImVec2 label_size = CalcTextSize(label, NULL, true);
const float square_sz = 12;
const ImVec2 pos = window->DC.CursorPos;
const ImRect total_bb(pos + ImVec2(window->Size.x - 64, 0), pos + ImVec2(window->Size.x - 24, square_sz + 4));
ItemSize(total_bb, style.FramePadding.y);
if (!ItemAdd(total_bb, id))
return false;
bool hovered, held;
bool pressed = ButtonBehavior(total_bb, id, &hovered, &held);
if (pressed)
{
*v = !(*v);
MarkItemEdited(id);
}
const ImRect check_bb(pos + ImVec2(window->Size.x - 50, 0), pos + ImVec2(window->Size.x - 24, square_sz));
RenderNavHighlight(total_bb, id);
window->DrawList->AddRectFilled(check_bb.Min, check_bb.Max, ImColor(36, 36, 36, (int)(g.Style.Alpha * 255)), 10);
//static float pos_active = 3.f;
//static float size_active = 6.f;
//static std::map<ImGuiID, float> pos_active;
//static std::map<ImGuiID, float> size_active;
auto it_pos_active = m_Animations.checkbox_pos_active.find(id);
auto it_size_active = m_Animations.checkbox_size_active.find(id);
if (it_pos_active == m_Animations.checkbox_pos_active.end())
{
m_Animations.checkbox_pos_active.insert({ id, 3.f });
it_pos_active = m_Animations.checkbox_pos_active.find(id);
}
if (it_size_active == m_Animations.checkbox_size_active.end())
{
m_Animations.checkbox_size_active.insert({ id, 6.f });
it_size_active =m_Animations.checkbox_size_active.find(id);
}
if (*v)
{
if (it_pos_active->second < 22)
it_pos_active->second += 1.5f;
if (it_size_active->second < 8)
it_size_active->second += 0.1f;
window->DrawList->AddRectFilled(check_bb.Min, ImVec2(check_bb.Min.x + it_pos_active->second, check_bb.Max.y), ImColor(40, 40, 40, (int)(g.Style.Alpha * 255)), 10);
window->DrawList->AddRect(check_bb.Min, check_bb.Max, ImColor(60 / 255.f, 60 / 255.f, 60 / 255.f, g.Style.Alpha), 10);
window->DrawList->AddCircleFilled(check_bb.Min + ImVec2(it_pos_active->second, 6), it_size_active->second, ImColor(96, 124, 255, (int)(g.Style.Alpha * 255)), 16);
}
else
{
if (it_pos_active->second > 3)
it_pos_active->second -= 1.5f;
if (it_size_active->second > 6)
it_size_active->second -= 0.1f;
window->DrawList->AddRectFilled(check_bb.Min, ImVec2(check_bb.Min.x + it_pos_active->second, check_bb.Max.y), ImColor(40, 40, 40, (int)(g.Style.Alpha * 255)), 10);
window->DrawList->AddRect(check_bb.Min, check_bb.Max, ImColor(60 / 255.f, 60 / 255.f, 60 / 255.f, g.Style.Alpha), 10);
window->DrawList->AddCircleFilled(check_bb.Min + ImVec2(it_pos_active->second, 6), it_size_active->second, ImColor(76, 76, 76, (int)(g.Style.Alpha * 255)), 16);
}
if (g.LogEnabled)
LogRenderedText(&total_bb.Min, *v ? "[x]" : "[ ]");
if (label_size.x > 0.0f)
RenderText(ImVec2(pos.x, total_bb.Min.y - 5), label);
IMGUI_TEST_ENGINE_ITEM_INFO(id, label, window->DC.ItemFlags | ImGuiItemStatusFlags_Checkable | (*v ? ImGuiItemStatusFlags_Checked : 0));
return pressed;
}
Вложения
-
1.2 KB Просмотры: 94
-
1 KB Просмотры: 84