mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-23 12:27:01 +00:00
Examples: Tiding up. Moved Dragging example higher up.
This commit is contained in:
parent
616a7e6c61
commit
9ace617e7e
53
imgui.cpp
53
imgui.cpp
@ -10687,6 +10687,25 @@ void ImGui::ShowTestWindow(bool* opened)
|
||||
ImGui::TreePop();
|
||||
}
|
||||
|
||||
if (ImGui::TreeNode("Dragging"))
|
||||
{
|
||||
ImGui::TextWrapped("You can use ImGui::GetItemActiveDragDelta() to query for the dragged amount on any widget.");
|
||||
ImGui::Button("Drag Me");
|
||||
if (ImGui::IsItemActive())
|
||||
{
|
||||
// Draw a line between the button and the mouse cursor
|
||||
ImDrawList* draw_list = ImGui::GetWindowDrawList();
|
||||
draw_list->PushClipRectFullScreen();
|
||||
draw_list->AddLine(ImGui::CalcItemRectClosestPoint(ImGui::GetIO().MousePos, true, -2.0f), ImGui::GetIO().MousePos, ImColor(ImGui::GetStyle().Colors[ImGuiCol_Button]), 4.0f);
|
||||
draw_list->PopClipRect();
|
||||
ImVec2 value_raw = ImGui::GetMouseDragDelta(0, 0.0f);
|
||||
ImVec2 value_with_lock_threshold = ImGui::GetMouseDragDelta(0);
|
||||
ImGui::SameLine(); ImGui::Text("Raw (%.1f, %.1f), WithLockThresold (%.1f, %.1f)", value_raw.x, value_raw.y, value_with_lock_threshold.x, value_with_lock_threshold.y);
|
||||
}
|
||||
|
||||
ImGui::TreePop();
|
||||
}
|
||||
|
||||
static bool check = true;
|
||||
ImGui::Checkbox("checkbox", &check);
|
||||
|
||||
@ -10760,29 +10779,23 @@ void ImGui::ShowTestWindow(bool* opened)
|
||||
}
|
||||
|
||||
{
|
||||
static int i1=50;
|
||||
static int i2=42;
|
||||
static int i1=50, i2=42;
|
||||
ImGui::DragInt("drag int", &i1, 1);
|
||||
ImGui::SameLine(); ShowHelpMarker("Click and drag to edit value.\nHold SHIFT/ALT for faster/slower edit.\nDouble-click or CTRL+click to input text.");
|
||||
|
||||
ImGui::DragInt("drag int 0..100", &i2, 1, 0, 100, "%.0f%%");
|
||||
|
||||
static float f1=1.00f;
|
||||
static float f2=0.0067f;
|
||||
static float f1=1.00f, f2=0.0067f;
|
||||
ImGui::DragFloat("drag float", &f1, 1.0f);
|
||||
ImGui::DragFloat("drag small float", &f2, 0.0001f, 0.0f, 0.0f, "%.06f ns");
|
||||
}
|
||||
|
||||
{
|
||||
static int i1=0;
|
||||
//static int i2=42;
|
||||
ImGui::SliderInt("slider int", &i1, 0, 3);
|
||||
ImGui::SameLine(); ShowHelpMarker("CTRL+click to input value.");
|
||||
|
||||
//ImGui::SliderInt("slider int -100..100", &i2, -100, 100);
|
||||
|
||||
static float f1=0.123f;
|
||||
static float f2=0.0f;
|
||||
static float f1=0.123f, f2=0.0f;
|
||||
ImGui::SliderFloat("slider float", &f1, 0.0f, 1.0f, "ratio = %.3f");
|
||||
ImGui::SliderFloat("slider log float", &f2, -10.0f, 10.0f, "%.4f", 3.0f);
|
||||
static float angle = 0.0f;
|
||||
@ -10905,28 +10918,6 @@ void ImGui::ShowTestWindow(bool* opened)
|
||||
ImGui::Indent();
|
||||
ImGui::TreePop();
|
||||
}
|
||||
|
||||
if (ImGui::TreeNode("Dragging"))
|
||||
{
|
||||
// You can use ImGui::GetItemActiveDragDelta() to query for the dragged amount on any widget.
|
||||
static ImVec2 value_raw(0.0f, 0.0f);
|
||||
static ImVec2 value_with_lock_threshold(0.0f, 0.0f);
|
||||
ImGui::Button("Drag Me");
|
||||
if (ImGui::IsItemActive())
|
||||
{
|
||||
value_raw = ImGui::GetMouseDragDelta(0, 0.0f);
|
||||
value_with_lock_threshold = ImGui::GetMouseDragDelta(0);
|
||||
//ImGui::SetTooltip("Delta: %.1f, %.1f", value.x, value.y);
|
||||
|
||||
// Draw a line between the button and the mouse cursor
|
||||
ImDrawList* draw_list = ImGui::GetWindowDrawList();
|
||||
draw_list->PushClipRectFullScreen();
|
||||
draw_list->AddLine(ImGui::CalcItemRectClosestPoint(ImGui::GetIO().MousePos, true, -2.0f), ImGui::GetIO().MousePos, ImColor(ImGui::GetStyle().Colors[ImGuiCol_Button]), 4.0f);
|
||||
draw_list->PopClipRect();
|
||||
}
|
||||
ImGui::SameLine(); ImGui::Text("Raw (%.1f, %.1f), WithLockThresold (%.1f, %.1f)", value_raw.x, value_raw.y, value_with_lock_threshold.x, value_with_lock_threshold.y);
|
||||
ImGui::TreePop();
|
||||
}
|
||||
}
|
||||
|
||||
if (ImGui::CollapsingHeader("Graphs widgets"))
|
||||
|
Loading…
Reference in New Issue
Block a user