"code for a text box in imgui" Code Answer's
You're definitely familiar with the best coding language Whatever that developers use to develop their projects and they get all their queries like "code for a text box in imgui" answered properly. Developers are finding an appropriate answer about code for a text box in imgui related to the Whatever coding language. By visiting this online portal developers get answers concerning Whatever codes question like code for a text box in imgui. Enter your desired code related query in the search bar and get every piece of information about Whatever code related question on code for a text box in imgui.
code for a text box in imgui
#define MAX(a, b) (((a) < (b)) ? (b) : (a))
#define INTERNAL static
struct MultilineScrollState
{
// Input.
float scrollRegionX;
float scrollX;
ImGuiStorage *storage;
// Output.
bool newScrollPositionAvailable;
float newScrollX;
};
INTERNAL int MultilineScrollCallback(ImGuiTextEditCallbackData *data)
{
MultilineScrollState *scrollState = (MultilineScrollState *)data->UserData;
ImGuiID cursorId = ImGui::GetID("cursor");
int oldCursorIndex = scrollState->storage->GetInt(cursorId, 0);
if (oldCursorIndex != data->CursorPos)
{
int begin = data->CursorPos;
while ((begin > 0) && (data->Buf[begin - 1] != '\n'))
{
--begin;
}
float cursorOffset = ImGui::CalcTextSize(data->Buf + begin, data->Buf + data->CursorPos).x;
float SCROLL_INCREMENT = scrollState->scrollRegionX * 0.25f;
if (cursorOffset < scrollState->scrollX)
{
scrollState->newScrollPositionAvailable = true;
scrollState->newScrollX = MAX(0.0f, cursorOffset - SCROLL_INCREMENT);
}
else if ((cursorOffset - scrollState->scrollRegionX) >= scrollState->scrollX)
{
scrollState->newScrollPositionAvailable = true;
scrollState->newScrollX = cursorOffset - scrollState->scrollRegionX + SCROLL_INCREMENT;
}
}
scrollState->storage->SetInt(cursorId, data->CursorPos);
return 0;
}
INTERNAL bool ImGuiInputTextMultiline(const char* label, char* buf, size_t buf_size, float height, ImGuiInputTextFlags flags = 0)
{
float scrollbarSize = ImGui::GetStyle().ScrollbarSize;
float labelWidth = ImGui::CalcTextSize(label).x + scrollbarSize;
float SCROLL_WIDTH = 2000.0f; // Very large scrolling width to allow for very long lines.
MultilineScrollState scrollState = {};
// Set up child region for horizontal scrolling of the text box.
ImGui::BeginChild(label, ImVec2(-labelWidth, height), false, ImGuiWindowFlags_HorizontalScrollbar);
scrollState.scrollRegionX = MAX(0.0f, ImGui::GetWindowWidth() - scrollbarSize);
scrollState.scrollX = ImGui::GetScrollX();
scrollState.storage = ImGui::GetStateStorage();
bool changed = ImGui::InputTextMultiline(label, buf, buf_size, ImVec2(SCROLL_WIDTH, MAX(0.0f, height - scrollbarSize)),
flags | ImGuiInputTextFlags_CallbackAlways, MultilineScrollCallback, &scrollState);
if (scrollState.newScrollPositionAvailable)
{
ImGui::SetScrollX(scrollState.newScrollX);
}
ImGui::EndChild();
ImGui::SameLine();
ImGui::Text(label);
return changed;
}
Source: github.com
All those coders who are working on the Whatever based application and are stuck on code for a text box in imgui can get a collection of related answers to their query. Programmers need to enter their query on code for a text box in imgui related to Whatever code and they'll get their ambiguities clear immediately. On our webpage, there are tutorials about code for a text box in imgui for the programmers working on Whatever code while coding their module. Coders are also allowed to rectify already present answers of code for a text box in imgui while working on the Whatever language code. Developers can add up suggestions if they deem fit any other answer relating to "code for a text box in imgui". Visit this developer's friendly online web community, CodeProZone, and get your queries like code for a text box in imgui resolved professionally and stay updated to the latest Whatever updates.