mirror of
https://github.com/ocornut/imgui.git
synced 2026-01-11 00:04:24 +00:00
InputText: internals: expose LineCount, GetPreferredOffsetX().
This commit is contained in:
parent
11fff1ccf5
commit
e422a38e4c
2 changed files with 4 additions and 0 deletions
|
|
@ -1234,6 +1234,7 @@ struct IMGUI_API ImGuiInputTextState
|
||||||
ImVector<char> CallbackTextBackup; // temporary storage for callback to support automatic reconcile of undo-stack
|
ImVector<char> CallbackTextBackup; // temporary storage for callback to support automatic reconcile of undo-stack
|
||||||
int BufCapacity; // end-user buffer capacity (include zero terminator)
|
int BufCapacity; // end-user buffer capacity (include zero terminator)
|
||||||
ImVec2 Scroll; // horizontal offset (managed manually) + vertical scrolling (pulled from child window's own Scroll.y)
|
ImVec2 Scroll; // horizontal offset (managed manually) + vertical scrolling (pulled from child window's own Scroll.y)
|
||||||
|
int LineCount; // last line count (solely for debugging)
|
||||||
float CursorAnim; // timer for cursor blink, reset on every user action so the cursor reappears immediately
|
float CursorAnim; // timer for cursor blink, reset on every user action so the cursor reappears immediately
|
||||||
bool CursorFollow; // set when we want scrolling to follow the current cursor position (not always!)
|
bool CursorFollow; // set when we want scrolling to follow the current cursor position (not always!)
|
||||||
bool SelectedAllMouseLock; // after a double-click to select all, we ignore further mouse drags to update selection
|
bool SelectedAllMouseLock; // after a double-click to select all, we ignore further mouse drags to update selection
|
||||||
|
|
@ -1248,6 +1249,7 @@ struct IMGUI_API ImGuiInputTextState
|
||||||
void ClearFreeMemory() { TextA.clear(); TextToRevertTo.clear(); }
|
void ClearFreeMemory() { TextA.clear(); TextToRevertTo.clear(); }
|
||||||
void OnKeyPressed(int key); // Cannot be inline because we call in code in stb_textedit.h implementation
|
void OnKeyPressed(int key); // Cannot be inline because we call in code in stb_textedit.h implementation
|
||||||
void OnCharPressed(unsigned int c);
|
void OnCharPressed(unsigned int c);
|
||||||
|
float GetPreferredOffsetX() const;
|
||||||
|
|
||||||
// Cursor & Selection
|
// Cursor & Selection
|
||||||
void CursorAnimReset();
|
void CursorAnimReset();
|
||||||
|
|
|
||||||
|
|
@ -4206,6 +4206,7 @@ void ImGuiInputTextState::ClearSelection() { Stb->select_start
|
||||||
int ImGuiInputTextState::GetCursorPos() const { return Stb->cursor; }
|
int ImGuiInputTextState::GetCursorPos() const { return Stb->cursor; }
|
||||||
int ImGuiInputTextState::GetSelectionStart() const { return Stb->select_start; }
|
int ImGuiInputTextState::GetSelectionStart() const { return Stb->select_start; }
|
||||||
int ImGuiInputTextState::GetSelectionEnd() const { return Stb->select_end; }
|
int ImGuiInputTextState::GetSelectionEnd() const { return Stb->select_end; }
|
||||||
|
float ImGuiInputTextState::GetPreferredOffsetX() const { return Stb->has_preferred_x ? Stb->preferred_x : -1; }
|
||||||
void ImGuiInputTextState::SelectAll() { Stb->select_start = 0; Stb->cursor = Stb->select_end = TextLen; Stb->has_preferred_x = 0; }
|
void ImGuiInputTextState::SelectAll() { Stb->select_start = 0; Stb->cursor = Stb->select_end = TextLen; Stb->has_preferred_x = 0; }
|
||||||
void ImGuiInputTextState::ReloadUserBufAndSelectAll() { WantReloadUserBuf = true; ReloadSelectionStart = 0; ReloadSelectionEnd = INT_MAX; }
|
void ImGuiInputTextState::ReloadUserBufAndSelectAll() { WantReloadUserBuf = true; ReloadSelectionStart = 0; ReloadSelectionEnd = INT_MAX; }
|
||||||
void ImGuiInputTextState::ReloadUserBufAndKeepSelection() { WantReloadUserBuf = true; ReloadSelectionStart = Stb->select_start; ReloadSelectionEnd = Stb->select_end; }
|
void ImGuiInputTextState::ReloadUserBufAndKeepSelection() { WantReloadUserBuf = true; ReloadSelectionStart = Stb->select_start; ReloadSelectionEnd = Stb->select_end; }
|
||||||
|
|
@ -5269,6 +5270,7 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
|
||||||
// Store text height (note that we haven't calculated text width at all, see GitHub issues #383, #1224)
|
// Store text height (note that we haven't calculated text width at all, see GitHub issues #383, #1224)
|
||||||
if (is_multiline)
|
if (is_multiline)
|
||||||
text_size = ImVec2(inner_size.x, line_count * g.FontSize);
|
text_size = ImVec2(inner_size.x, line_count * g.FontSize);
|
||||||
|
state->LineCount = line_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Scroll
|
// Scroll
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue