imgui horizontal scroll
- User
imgui horizontal scroll
- Assistant
- User
reaimgui horizontal scroll
- Assistant
imgui horizontal scroll
reaimgui horizontal scroll
In Dear ImGui, handling horizontal scrolling can be implemented in various ways depending on your specific needs. Below are some examples to guide you through implementing horizontal scrolling for different use cases:
In a scenario where you have a lot of text that requires horizontal scrolling, you can use ImGui::BeginChild with the ImGuiWindowFlags_HorizontalScrollbar flag.
#include "imgui.h"
void ShowExampleWindow()
{
if (ImGui::Begin("Example Window"))
{
ImVec2 size = ImGui::GetContentRegionAvail();
ImGui::BeginChild("ScrollingRegion", ImVec2(size.x, 200), true, ImGuiWindowFlags_HorizontalScrollbar);
// Example content with a long line of text
ImGui::Text("This is a very long line of text that will require horizontal scrolling to view completely.");
ImGui::EndChild();
}
ImGui::End();
}
If you are using tables and you need each column to be scrollable horizontally, you can use the ImGuiTableFlags_ScrollX flag when setting up your table.
#include "imgui.h"
void ShowTableExample()
{
if (ImGui::Begin("Table Example"))
{
ImGuiTableFlags flags = ImGuiTableFlags_ScrollX | ImGuiTableFlags_ScrollY;
if (ImGui::BeginTable("Table", 5, flags))
{
// Define columns
ImGui::TableSetupColumn("Column 1", ImGuiTableColumnFlags_WidthFixed, 100.0f);
ImGui::TableSetupColumn("Column 2", ImGuiTableColumnFlags_WidthFixed, 100.0f);
ImGui::TableSetupColumn("Column 3", ImGuiTableColumnFlags_WidthFixed, 100.0f);
ImGui::TableSetupColumn("Column 4", ImGuiTableColumnFlags_WidthFixed, 100.0f);
ImGui::TableSetupColumn("Column 5", ImGuiTableColumnFlags_WidthFixed, 100.0f);
ImGui::TableHeadersRow();
for (int row = 0; row < 10; row++)
{
ImGui::TableNextRow();
for (int column = 0; column < 5; column++)
{
ImGui::TableSetColumnIndex(column);
ImGui::Text("Row %d Column %d", row, column);
}
}
ImGui::EndTable();
}
ImGui::End();
}
}
These examples demonstrate two ways to implement horizontal scrolling in Dear ImGui. In the first example, text content within a child window is scrollable horizontally. The second example demonstrates how to use horizontal scrolling within a table. You can adjust the size and content to better fit your actual use case.
ImGui::BeginChild, ensure that the size you provide is appropriate for your layout.ImGuiWindowFlags_HorizontalScrollbar (for child windows) and ImGuiTableFlags_ScrollX (for tables).To implement horizontal scrolling in ReaImGui (which is the implementation of Dear ImGui for REAPER, a digital audio workstation), you can use methods similar to standard Dear ImGui usage. Here is an example to help guide you through integrating horizontal scrolling within ReaImGui.
local ctx = reaper.imGui_CreateContext("Example Window")
local function loop()
if reaper.ImGui_Begin(ctx, "Example Window") then
local size = reaper.ImGui_GetContentRegionAvail(ctx)
reaper.ImGui_BeginChild(ctx, "ScrollingRegion", size, true, reaper.ImGui_WindowFlags_HorizontalScrollbar())
-- Example content with a long line of text
reaper.ImGui_Text(ctx, "This is a very long line of text that will require horizontal scrolling to view completely.")
reaper.ImGui_EndChild(ctx)
end
reaper.ImGui_End(ctx)
reaper.defer(loop)
end
loop()
local ctx = reaper.imGui_CreateContext("Table Example")
local function loop()
if reaper.ImGui_Begin(ctx, "Table Example") then
local flags = reaper.ImGui_TableFlags_ScrollX() | reaper.ImGui_TableFlags_ScrollY()
if reaper.ImGui_BeginTable(ctx, "Table", 5, flags) then
-- Define columns
reaper.ImGui_TableSetupColumn(ctx, "Column 1", reaper.ImGui_TableColumnFlags_WidthFixed(), 100.0)
reaper.ImGui_TableSetupColumn(ctx, "Column 2", reaper.ImGui_TableColumnFlags_WidthFixed(), 100.0)
reaper.ImGui_TableSetupColumn(ctx, "Column 3", reaper.ImGui_TableColumnFlags_WidthFixed(), 100.0)
reaper.ImGui_TableSetupColumn(ctx, "Column 4", reaper.ImGui_TableColumnFlags_WidthFixed(), 100.0)
reaper.ImGui_TableSetupColumn(ctx, "Column 5", reaper.ImGui_TableColumnFlags_WidthFixed(), 100.0)
reaper.ImGui_TableHeadersRow(ctx)
for row = 0, 9 do
reaper.ImGui_TableNextRow(ctx)
for column = 0, 4 do
reaper.ImGui_TableSetColumnIndex(ctx, column)
reaper.ImGui_Text(ctx, string.format("Row %d Column %d", row, column))
end
end
reaper.ImGui_EndTable(ctx)
end
end
reaper.ImGui_End(ctx)
reaper.defer(loop)
end
loop()
reaper.ImGui_CreateContext.reaper.ImGui_WindowFlags_HorizontalScrollbar flag for child windows and reaper.ImGui_TableFlags_ScrollX for tables.reaper.ImGui_BeginChild and reaper.ImGui_EndChild to create a scrollable region within your main window.reaper.ImGui_BeginChild determines the size of the scrolling area, similar to Dear ImGui.reaper.defer(loop) to keep the GUI responsive and updated.These examples should give you a solid starting point for implementing horizontal scrolling in your ReaImGui projects. Adjust the content and size parameters as needed to fit your specific requirements.
Not yet included in a published release.