|
|
@ -2064,23 +2064,23 @@ static void ShowDemoWindowLayout()
|
|
|
|
// Vertical scroll functions
|
|
|
|
// Vertical scroll functions
|
|
|
|
HelpMarker("Use SetScrollHereY() or SetScrollFromPosY() to scroll to a given vertical position.");
|
|
|
|
HelpMarker("Use SetScrollHereY() or SetScrollFromPosY() to scroll to a given vertical position.");
|
|
|
|
|
|
|
|
|
|
|
|
static bool track = true;
|
|
|
|
|
|
|
|
static int track_item = 50;
|
|
|
|
static int track_item = 50;
|
|
|
|
|
|
|
|
static bool enable_track = true;
|
|
|
|
static float scroll_to_off_px = 0.0f;
|
|
|
|
static float scroll_to_off_px = 0.0f;
|
|
|
|
static float scroll_to_pos_px = 200.0f;
|
|
|
|
static float scroll_to_pos_px = 200.0f;
|
|
|
|
ImGui::Checkbox("Track", &track);
|
|
|
|
ImGui::Checkbox("Track", &enable_track);
|
|
|
|
ImGui::PushItemWidth(100);
|
|
|
|
ImGui::PushItemWidth(100);
|
|
|
|
ImGui::SameLine(140); track |= ImGui::DragInt("##item", &track_item, 0.25f, 0, 99, "Item = %d");
|
|
|
|
ImGui::SameLine(140); enable_track |= ImGui::DragInt("##item", &track_item, 0.25f, 0, 99, "Item = %d");
|
|
|
|
|
|
|
|
|
|
|
|
bool scroll_to_off = ImGui::Button("Scroll Offset");
|
|
|
|
bool scroll_to_off = ImGui::Button("Scroll Offset");
|
|
|
|
ImGui::SameLine(140); scroll_to_off |= ImGui::DragFloat("##off", &scroll_to_off_px, 1.00f, 0, 9999, "+%.0f px");
|
|
|
|
ImGui::SameLine(140); scroll_to_off |= ImGui::DragFloat("##off", &scroll_to_off_px, 1.00f, 0, 9999, "+%.0f px");
|
|
|
|
|
|
|
|
|
|
|
|
bool scroll_to_pos = ImGui::Button("Scroll To Pos");
|
|
|
|
bool scroll_to_pos = ImGui::Button("Scroll To Pos");
|
|
|
|
ImGui::SameLine(140); scroll_to_pos |= ImGui::DragFloat("##pos", &scroll_to_pos_px, 1.00f, 0, 9999, "X/Y = %.0f px");
|
|
|
|
ImGui::SameLine(140); scroll_to_pos |= ImGui::DragFloat("##pos", &scroll_to_pos_px, 1.00f, 0, 9999, "X/Y = %.0f px");
|
|
|
|
|
|
|
|
|
|
|
|
ImGui::PopItemWidth();
|
|
|
|
ImGui::PopItemWidth();
|
|
|
|
|
|
|
|
|
|
|
|
if (scroll_to_off || scroll_to_pos)
|
|
|
|
if (scroll_to_off || scroll_to_pos)
|
|
|
|
track = false;
|
|
|
|
enable_track = false;
|
|
|
|
|
|
|
|
|
|
|
|
ImGuiStyle& style = ImGui::GetStyle();
|
|
|
|
ImGuiStyle& style = ImGui::GetStyle();
|
|
|
|
float child_w = (ImGui::GetContentRegionAvail().x - 4 * style.ItemSpacing.x) / 5;
|
|
|
|
float child_w = (ImGui::GetContentRegionAvail().x - 4 * style.ItemSpacing.x) / 5;
|
|
|
@ -2101,7 +2101,7 @@ static void ShowDemoWindowLayout()
|
|
|
|
ImGui::SetScrollFromPosY(ImGui::GetCursorStartPos().y + scroll_to_pos_px, i * 0.25f);
|
|
|
|
ImGui::SetScrollFromPosY(ImGui::GetCursorStartPos().y + scroll_to_pos_px, i * 0.25f);
|
|
|
|
for (int item = 0; item < 100; item++)
|
|
|
|
for (int item = 0; item < 100; item++)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (track && item == track_item)
|
|
|
|
if (enable_track && item == track_item)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ImGui::TextColored(ImVec4(1,1,0,1), "Item %d", item);
|
|
|
|
ImGui::TextColored(ImVec4(1,1,0,1), "Item %d", item);
|
|
|
|
ImGui::SetScrollHereY(i * 0.25f); // 0.0f:top, 0.5f:center, 1.0f:bottom
|
|
|
|
ImGui::SetScrollHereY(i * 0.25f); // 0.0f:top, 0.5f:center, 1.0f:bottom
|
|
|
@ -2133,7 +2133,7 @@ static void ShowDemoWindowLayout()
|
|
|
|
ImGui::SetScrollFromPosX(ImGui::GetCursorStartPos().x + scroll_to_pos_px, i * 0.25f);
|
|
|
|
ImGui::SetScrollFromPosX(ImGui::GetCursorStartPos().x + scroll_to_pos_px, i * 0.25f);
|
|
|
|
for (int item = 0; item < 100; item++)
|
|
|
|
for (int item = 0; item < 100; item++)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (track && item == track_item)
|
|
|
|
if (enable_track && item == track_item)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ImGui::TextColored(ImVec4(1, 1, 0, 1), "Item %d", item);
|
|
|
|
ImGui::TextColored(ImVec4(1, 1, 0, 1), "Item %d", item);
|
|
|
|
ImGui::SetScrollHereX(i * 0.25f); // 0.0f:left, 0.5f:center, 1.0f:right
|
|
|
|
ImGui::SetScrollHereX(i * 0.25f); // 0.0f:left, 0.5f:center, 1.0f:right
|
|
|
|