1
0
mirror of https://github.com/ocornut/imgui.git synced 2024-11-12 02:00:58 +01:00

DragFloat(): passing min>=max (e.g. 0.0f) for range makes the drag unbound #180, removed extra APIs

This commit is contained in:
ocornut 2015-04-03 15:13:59 +01:00
parent 61d886e14b
commit 916a8955ec
2 changed files with 5 additions and 15 deletions

View File

@ -5460,7 +5460,9 @@ static bool DragScalarBehavior(const ImRect& frame_bb, ImGuiID id, float* v, flo
step = v_step * g.DragSpeedScaleSlow;
*v += (mouse_drag_delta.x - g.DragLastMouseDelta.x) * step;
*v = ImClamp(*v, v_min, v_max);
if (v_min < v_max)
*v = ImClamp(*v, v_min, v_max);
g.DragLastMouseDelta.x = mouse_drag_delta.x;
value_changed = true;
@ -5543,11 +5545,6 @@ bool ImGui::DragFloat(const char* label, float *v, float v_step, float v_min, fl
return value_changed;
}
bool ImGui::DragFloat(const char* label, float* v, float v_step, const char* display_format)
{
return ImGui::DragFloat(label, v, v_step, -FLT_MAX, FLT_MAX, display_format);
}
bool ImGui::DragInt(const char* label, int* v, int v_step, int v_min, int v_max, const char* display_format)
{
if (!display_format)
@ -5558,11 +5555,6 @@ bool ImGui::DragInt(const char* label, int* v, int v_step, int v_min, int v_max,
return value_changed;
}
bool ImGui::DragInt(const char* label, int* v, int v_step, const char* display_format)
{
return ImGui::DragInt(label, v, v_step, IM_INT_MIN, IM_INT_MAX, display_format);
}
enum ImGuiPlotType
{
ImGuiPlotType_Lines,

View File

@ -301,10 +301,8 @@ namespace ImGui
IMGUI_API void PlotHistogram(const char* label, float (*values_getter)(void* data, int idx), void* data, 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));
// Widgets: Drags (tip: ctrl+click on a drag box to input text)
IMGUI_API bool DragFloat(const char* label, float* v, float v_step = 1.0f, float v_min = -FLT_MAX, float v_max = FLT_MAX, const char* display_format = "%.3f");
IMGUI_API bool DragFloat(const char* label, float* v, float v_step, const char* display_format);
IMGUI_API bool DragInt(const char* label, int* v, int v_step = 1, int v_min = -0x7fffffff-1, int v_max = 0x7fffffff, const char* display_format = "%.0f");
IMGUI_API bool DragInt(const char* label, int* v, int v_step, const char* display_format = "%.0f");
IMGUI_API bool DragFloat(const char* label, float* v, float v_step = 1.0f, float v_min = 0.0f, float v_max = 0.0f, const char* display_format = "%.3f"); // If v_max >= v_max we have no bound
IMGUI_API bool DragInt(const char* label, int* v, int v_step = 1, int v_min = 0.0f, int v_max = 0.0f, const char* display_format = "%.0f"); // If v_max >= v_max we have no bound
// Widgets: Sliders (tip: ctrl+click on a slider to input text)
IMGUI_API bool SliderFloat(const char* label, float* v, float v_min, float v_max, const char* display_format = "%.3f", float power = 1.0f); // adjust display_format to decorate the value with a prefix or a suffix. Use power!=1.0 for logarithmic sliders