mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-22 03:47:00 +00:00
Checkbox() return true when pressed
This commit is contained in:
parent
cd3d027df0
commit
2fb63b6068
13
imgui.cpp
13
imgui.cpp
@ -3495,12 +3495,12 @@ void PlotHistogram(const char* label, const float* values, int values_count, int
|
|||||||
ImGui::Plot(ImGuiPlotType_Histogram, label, values, values_count, values_offset, overlay_text, scale_min, scale_max, graph_size, stride);
|
ImGui::Plot(ImGuiPlotType_Histogram, label, values, values_count, values_offset, overlay_text, scale_min, scale_max, graph_size, stride);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Checkbox(const char* label, bool* v)
|
bool Checkbox(const char* label, bool* v)
|
||||||
{
|
{
|
||||||
ImGuiState& g = GImGui;
|
ImGuiState& g = GImGui;
|
||||||
ImGuiWindow* window = GetCurrentWindow();
|
ImGuiWindow* window = GetCurrentWindow();
|
||||||
if (window->SkipItems)
|
if (window->SkipItems)
|
||||||
return;
|
return false;
|
||||||
|
|
||||||
const ImGuiStyle& style = g.Style;
|
const ImGuiStyle& style = g.Style;
|
||||||
const ImGuiID id = window->GetID(label);
|
const ImGuiID id = window->GetID(label);
|
||||||
@ -3516,7 +3516,7 @@ void Checkbox(const char* label, bool* v)
|
|||||||
const ImGuiAabb total_bb(ImMin(check_bb.Min, text_bb.Min), ImMax(check_bb.Max, text_bb.Max));
|
const ImGuiAabb total_bb(ImMin(check_bb.Min, text_bb.Min), ImMax(check_bb.Max, text_bb.Max));
|
||||||
|
|
||||||
if (ClipAdvance(total_bb))
|
if (ClipAdvance(total_bb))
|
||||||
return;
|
return false;
|
||||||
|
|
||||||
const bool hovered = (g.HoveredWindow == window) && (g.HoveredId == 0) && IsMouseHoveringBox(total_bb);
|
const bool hovered = (g.HoveredWindow == window) && (g.HoveredId == 0) && IsMouseHoveringBox(total_bb);
|
||||||
const bool pressed = hovered && g.IO.MouseClicked[0];
|
const bool pressed = hovered && g.IO.MouseClicked[0];
|
||||||
@ -3537,16 +3537,19 @@ void Checkbox(const char* label, bool* v)
|
|||||||
if (g.LogEnabled)
|
if (g.LogEnabled)
|
||||||
LogText(text_bb.GetTL(), *v ? "[x]" : "[ ]");
|
LogText(text_bb.GetTL(), *v ? "[x]" : "[ ]");
|
||||||
RenderText(text_bb.GetTL(), label);
|
RenderText(text_bb.GetTL(), label);
|
||||||
|
|
||||||
|
return pressed;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheckboxFlags(const char* label, unsigned int* flags, unsigned int flags_value)
|
bool CheckboxFlags(const char* label, unsigned int* flags, unsigned int flags_value)
|
||||||
{
|
{
|
||||||
bool v = (*flags & flags_value) ? true : false;
|
bool v = (*flags & flags_value) ? true : false;
|
||||||
ImGui::Checkbox(label, &v);
|
bool pressed = ImGui::Checkbox(label, &v);
|
||||||
if (v)
|
if (v)
|
||||||
*flags |= flags_value;
|
*flags |= flags_value;
|
||||||
else
|
else
|
||||||
*flags &= ~flags_value;
|
*flags &= ~flags_value;
|
||||||
|
return pressed;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RadioButton(const char* label, bool active)
|
bool RadioButton(const char* label, bool active)
|
||||||
|
4
imgui.h
4
imgui.h
@ -197,8 +197,8 @@ namespace ImGui
|
|||||||
bool SliderInt(const char* label, int* v, int v_min, int v_max, const char* display_format = "%.0f");
|
bool SliderInt(const char* label, int* v, int v_min, int v_max, const char* display_format = "%.0f");
|
||||||
void PlotLines(const char* label, const float* values, int values_count, int values_offset = 0, const char* overlay_text = NULL, float scale_min = FLT_MAX, float scale_max = FLT_MAX, ImVec2 graph_size = ImVec2(0,0), size_t stride = sizeof(float));
|
void PlotLines(const char* label, const float* values, int values_count, int values_offset = 0, const char* overlay_text = NULL, float scale_min = FLT_MAX, float scale_max = FLT_MAX, ImVec2 graph_size = ImVec2(0,0), size_t stride = sizeof(float));
|
||||||
void PlotHistogram(const char* label, const float* values, int values_count, int values_offset = 0, const char* overlay_text = NULL, float scale_min = FLT_MAX, float scale_max = FLT_MAX, ImVec2 graph_size = ImVec2(0,0), size_t stride = sizeof(float));
|
void PlotHistogram(const char* label, const float* values, int values_count, int values_offset = 0, const char* overlay_text = NULL, float scale_min = FLT_MAX, float scale_max = FLT_MAX, ImVec2 graph_size = ImVec2(0,0), size_t stride = sizeof(float));
|
||||||
void Checkbox(const char* label, bool* v);
|
bool Checkbox(const char* label, bool* v);
|
||||||
void CheckboxFlags(const char* label, unsigned int* flags, unsigned int flags_value);
|
bool CheckboxFlags(const char* label, unsigned int* flags, unsigned int flags_value);
|
||||||
bool RadioButton(const char* label, bool active);
|
bool RadioButton(const char* label, bool active);
|
||||||
bool RadioButton(const char* label, int* v, int v_button);
|
bool RadioButton(const char* label, int* v, int v_button);
|
||||||
bool InputFloat(const char* label, float* v, float step = 0.0f, float step_fast = 0.0f, int decimal_precision = -1);
|
bool InputFloat(const char* label, float* v, float step = 0.0f, float step_fast = 0.0f, int decimal_precision = -1);
|
||||||
|
Loading…
Reference in New Issue
Block a user