|
020-imGui窗口中的滑块UI控件Slider
郁金香灬外挂技术
https://www.yjxsoft.com/
本教程视频1920*1080分辩率下观看最佳
VS2017+win10 64位 环境
郁金香老师:Q扣 150330575
欢迎大家参加 郁金香灬技术 游戏安全与外挂的研究学习。
兴趣是我们最好的老师
成长需要过程与循序渐进
兴趣+坚持+时间+优秀的教程会帮助你快速成功
交流扣扣群 29817979,9569245
学习目标:
imGui窗口中的滑块UI控件Slider
enum ImGuiSliderFlags_
{
ImGuiSliderFlags_None = 0,
ImGuiSliderFlags_AlwaysClamp = 1 << 4, //不允许越界 溢出
// Clamp value to min/max bounds when input manually with CTRL+Click. By default CTRL+Click allows going out of bounds.
ImGuiSliderFlags_Logarithmic = 1 << 5,
// Make the widget logarithmic (linear otherwise). Consider using ImGuiSliderFlags_NoRoundToFormat with this if using a format-string with small amount of digits.
ImGuiSliderFlags_NoRoundToFormat = 1 << 6,
// Disable rounding underlying value to match precision of the display format string (e.g. %.3f values are rounded to those 3 digits)
ImGuiSliderFlags_NoInput = 1 << 7, //禁用 CTRL+鼠标左键单击 快捷键 直接输入值
// Disable CTRL+Click or Enter key allowing to input text directly into the widget
ImGuiSliderFlags_InvalidMask_ = 0x7000000F,
// [Internal] We treat using those bits as being potentially a 'float power' argument from the previous API that has got miscast to this enum, and will trigger an assert if needed.
// Obsolete names
//ImGuiSliderFlags_ClampOnInput = ImGuiSliderFlags_AlwaysClamp, // [renamed in 1.79]
};
IMGUI_API bool SliderFloat(const char* label, float* v, float v_min, float v_max, const char* format = "%.3f", ImGuiSliderFlags flags = 0); // adjust format to decorate the value with a prefix or a suffix for in-slider labels or unit display.
IMGUI_API bool SliderFloat2(const char* label, float v[2], float v_min, float v_max, const char* format = "%.3f", ImGuiSliderFlags flags = 0);
IMGUI_API bool SliderFloat3(const char* label, float v[3], float v_min, float v_max, const char* format = "%.3f", ImGuiSliderFlags flags = 0);
IMGUI_API bool SliderFloat4(const char* label, float v[4], float v_min, float v_max, const char* format = "%.3f", ImGuiSliderFlags flags = 0);
IMGUI_API bool SliderAngle(const char* label, float* v_rad, float v_degrees_min = -360.0f, float v_degrees_max = +360.0f, const char* format = "%.0f deg", ImGuiSliderFlags flags = 0);
IMGUI_API bool SliderInt(const char* label, int* v, int v_min, int v_max, const char* format = "%d", ImGuiSliderFlags flags = 0);
IMGUI_API bool SliderInt2(const char* label, int v[2], int v_min, int v_max, const char* format = "%d", ImGuiSliderFlags flags = 0);
IMGUI_API bool SliderInt3(const char* label, int v[3], int v_min, int v_max, const char* format = "%d", ImGuiSliderFlags flags = 0);
IMGUI_API bool SliderInt4(const char* label, int v[4], int v_min, int v_max, const char* format = "%d", ImGuiSliderFlags flags = 0);
IMGUI_API bool SliderScalar(const char* label, ImGuiDataType data_type, void* p_data, const void* p_min, const void* p_max, const char* format = NULL, ImGuiSliderFlags flags = 0);
IMGUI_API bool SliderScalarN(const char* label, ImGuiDataType data_type, void* p_data, int components, const void* p_min, const void* p_max, const char* format = NULL, ImGuiSliderFlags flags = 0);
IMGUI_API bool VSliderFloat(const char* label, const ImVec2& size, float* v, float v_min, float v_max, const char* format = "%.3f", ImGuiSliderFlags flags = 0);
IMGUI_API bool VSliderInt(const char* label, const ImVec2& size, int* v, int v_min, int v_max, const char* format = "%d", ImGuiSliderFlags flags = 0);
IMGUI_API bool VSliderScalar(const char* label, const ImVec2& size, ImGuiDataType data_type, void* p_data, const void* p_min, const void* p_max, const char* format = NULL, ImGuiSliderFlags flags = 0);
IMGUI_API bool SliderInt(
const char* label,
int* v, //OUT 滑块所在的位置 返回值
int v_min, int v_max,
const char* format = "%d",
ImGuiSliderFlags flags = 0);
bool 返回值 true 表示按下拖动
ImGui::SliderInt("slider int", &i1, -1, 3);
static float f1 = 0.123f, f2 = 0.0f;
ImGui::SliderFloat("slider float",
&f1, 0.0f, 1.0f,
"ratio = %.3f");
ImGui::SliderFloat("slider float (log)",
&f2,
-10.0f, 10.0f,
"%.4f",
ImGuiSliderFlags_Logarithmic);
void CDX11::滑块UI接口测试()
{
static int outValue = 30;
ImGui::Begin(u8"滑块UI接口测试");
ImGui::Text(u8"滑块测试 返回值=%d", outValue);
ImGui::SliderInt("###slider int", &outValue, 1, 60, "<+++%d+++>",
ImGuiSliderFlags_AlwaysClamp| ImGuiSliderFlags_Logarithmic );
char formatbuf[256];
static float foutValue = 33;
sprintf_s(formatbuf, "<<<<<++%f++", foutValue);
ImGui::SliderFloat("###slider float", &foutValue, 1, 100.0f, formatbuf,
ImGuiSliderFlags_NoInput|ImGuiSliderFlags_NoRoundToFormat| ImGuiSliderFlags_AlwaysClamp);
ImGui::Text(u8"滑块测试 foutValue=%f", foutValue);
ImGui::End();
};
|
|