Various tidying up / comments, moved columns functions declarations, no functional changes
This commit is contained in:
parent
9cbc6e196b
commit
928832a5bc
22
imgui.cpp
22
imgui.cpp
@ -2826,13 +2826,13 @@ static ImGuiWindow* FindHoveredWindow(ImVec2 pos, bool excluding_childs)
|
||||
// Test if mouse cursor is hovering given rectangle
|
||||
// NB- Rectangle is clipped by our current clip setting
|
||||
// NB- Expand the rectangle to be generous on imprecise inputs systems (g.Style.TouchExtraPadding)
|
||||
bool ImGui::IsMouseHoveringRect(const ImVec2& pos_min, const ImVec2& pos_max, bool clip)
|
||||
bool ImGui::IsMouseHoveringRect(const ImVec2& r_min, const ImVec2& r_max, bool clip)
|
||||
{
|
||||
ImGuiState& g = *GImGui;
|
||||
ImGuiWindow* window = GetCurrentWindowRead();
|
||||
|
||||
// Clip
|
||||
ImRect rect_clipped(pos_min, pos_max);
|
||||
ImRect rect_clipped(r_min, r_max);
|
||||
if (clip)
|
||||
rect_clipped.Clip(window->ClipRect);
|
||||
|
||||
@ -8798,33 +8798,31 @@ void ImGui::EndGroup()
|
||||
}
|
||||
|
||||
// Gets back to previous line and continue with horizontal layout
|
||||
// local_pos_x == 0 : follow on previous item
|
||||
// local_pos_x != 0 : align to specified column
|
||||
// pos_x == 0 : follow on previous item
|
||||
// pos_x != 0 : align to specified column
|
||||
// spacing_w < 0 : use default spacing if column_x==0, no spacing if column_x!=0
|
||||
// spacing_w >= 0 : enforce spacing
|
||||
void ImGui::SameLine(float local_pos_x, float spacing_w)
|
||||
void ImGui::SameLine(float pos_x, float spacing_w)
|
||||
{
|
||||
ImGuiWindow* window = GetCurrentWindow();
|
||||
if (window->SkipItems)
|
||||
return;
|
||||
|
||||
ImGuiState& g = *GImGui;
|
||||
float x, y;
|
||||
if (local_pos_x != 0.0f)
|
||||
if (pos_x != 0.0f)
|
||||
{
|
||||
if (spacing_w < 0.0f) spacing_w = 0.0f;
|
||||
x = window->Pos.x - window->Scroll.x + local_pos_x + spacing_w;
|
||||
y = window->DC.CursorPosPrevLine.y;
|
||||
window->DC.CursorPos.x = window->Pos.x - window->Scroll.x + pos_x + spacing_w;
|
||||
window->DC.CursorPos.y = window->DC.CursorPosPrevLine.y;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (spacing_w < 0.0f) spacing_w = g.Style.ItemSpacing.x;
|
||||
x = window->DC.CursorPosPrevLine.x + spacing_w;
|
||||
y = window->DC.CursorPosPrevLine.y;
|
||||
window->DC.CursorPos.x = window->DC.CursorPosPrevLine.x + spacing_w;
|
||||
window->DC.CursorPos.y = window->DC.CursorPosPrevLine.y;
|
||||
}
|
||||
window->DC.CurrentLineHeight = window->DC.PrevLineHeight;
|
||||
window->DC.CurrentLineTextBaseOffset = window->DC.PrevLineTextBaseOffset;
|
||||
window->DC.CursorPos = ImVec2(x, y);
|
||||
}
|
||||
|
||||
void ImGui::NextColumn()
|
||||
|
27
imgui.h
27
imgui.h
@ -189,18 +189,11 @@ namespace ImGui
|
||||
IMGUI_API void BeginGroup(); // lock horizontal starting position. once closing a group it is seen as a single item (so you can use IsItemHovered() on a group, SameLine() between groups, etc.
|
||||
IMGUI_API void EndGroup();
|
||||
IMGUI_API void Separator(); // horizontal line
|
||||
IMGUI_API void SameLine(float local_pos_x = 0.0f, float spacing_w = -1.0f); // call between widgets or groups to layout them horizontally
|
||||
IMGUI_API void SameLine(float pos_x = 0.0f, float spacing_w = -1.0f); // call between widgets or groups to layout them horizontally
|
||||
IMGUI_API void Spacing(); // add spacing
|
||||
IMGUI_API void Dummy(const ImVec2& size); // add a dummy item of given size
|
||||
IMGUI_API void Indent(); // move content position toward the right by style.IndentSpacing pixels
|
||||
IMGUI_API void Unindent(); // move content position back to the left (cancel Indent)
|
||||
IMGUI_API void Columns(int count = 1, const char* id = NULL, bool border = true); // setup number of columns. use an identifier to distinguish multiple column sets. close with Columns(1).
|
||||
IMGUI_API void NextColumn(); // next column
|
||||
IMGUI_API int GetColumnIndex(); // get current column index
|
||||
IMGUI_API float GetColumnOffset(int column_index = -1); // get position of column line (in pixels, from the left side of the contents region). pass -1 to use current column, otherwise 0..GetcolumnsCount() inclusive. column 0 is usually 0.0f and not resizable unless you call this
|
||||
IMGUI_API void SetColumnOffset(int column_index, float offset_x); // set position of column line (in pixels, from the left side of the contents region). pass -1 to use current column
|
||||
IMGUI_API float GetColumnWidth(int column_index = -1); // column width (== GetColumnOffset(GetColumnIndex()+1) - GetColumnOffset(GetColumnOffset())
|
||||
IMGUI_API int GetColumnsCount(); // number of columns (what was passed to Columns())
|
||||
IMGUI_API ImVec2 GetCursorPos(); // cursor position is relative to window position
|
||||
IMGUI_API float GetCursorPosX(); // "
|
||||
IMGUI_API float GetCursorPosY(); // "
|
||||
@ -215,6 +208,16 @@ namespace ImGui
|
||||
IMGUI_API float GetTextLineHeightWithSpacing(); // distance (in pixels) between 2 consecutive lines of text == GetWindowFontSize() + GetStyle().ItemSpacing.y
|
||||
IMGUI_API float GetItemsLineHeightWithSpacing(); // distance (in pixels) between 2 consecutive lines of standard height widgets == GetWindowFontSize() + GetStyle().FramePadding.y*2 + GetStyle().ItemSpacing.y
|
||||
|
||||
// Columns
|
||||
// You can also use SameLine(pos_x) for simplified columning. The columns API is still work-in-progress.
|
||||
IMGUI_API void Columns(int count = 1, const char* id = NULL, bool border = true); // setup number of columns. use an identifier to distinguish multiple column sets. close with Columns(1).
|
||||
IMGUI_API void NextColumn(); // next column
|
||||
IMGUI_API int GetColumnIndex(); // get current column index
|
||||
IMGUI_API float GetColumnOffset(int column_index = -1); // get position of column line (in pixels, from the left side of the contents region). pass -1 to use current column, otherwise 0..GetcolumnsCount() inclusive. column 0 is usually 0.0f and not resizable unless you call this
|
||||
IMGUI_API void SetColumnOffset(int column_index, float offset_x); // set position of column line (in pixels, from the left side of the contents region). pass -1 to use current column
|
||||
IMGUI_API float GetColumnWidth(int column_index = -1); // column width (== GetColumnOffset(GetColumnIndex()+1) - GetColumnOffset(GetColumnOffset())
|
||||
IMGUI_API int GetColumnsCount(); // number of columns (what was passed to Columns())
|
||||
|
||||
// ID scopes
|
||||
// If you are creating widgets in a loop you most likely want to push a unique identifier so ImGui can differentiate them.
|
||||
// You can also use the "##foobar" syntax within widget label to distinguish them from each others. Read "A primer on the use of labels/IDs" in the FAQ for more details.
|
||||
@ -330,7 +333,7 @@ namespace ImGui
|
||||
IMGUI_API void ValueColor(const char* prefix, const ImVec4& v);
|
||||
IMGUI_API void ValueColor(const char* prefix, unsigned int v);
|
||||
|
||||
// Tooltip
|
||||
// Tooltips
|
||||
IMGUI_API void SetTooltip(const char* fmt, ...) IM_PRINTFARGS(1); // set tooltip under mouse-cursor, typically use with ImGui::IsHovered(). last call wins
|
||||
IMGUI_API void SetTooltipV(const char* fmt, va_list args);
|
||||
IMGUI_API void BeginTooltip(); // use to create full-featured tooltip windows that aren't just text
|
||||
@ -346,7 +349,7 @@ namespace ImGui
|
||||
IMGUI_API bool MenuItem(const char* label, const char* shortcut = NULL, bool selected = false, bool enabled = true); // return true when activated. shortcuts are displayed for convenience but not processed by ImGui at the moment
|
||||
IMGUI_API bool MenuItem(const char* label, const char* shortcut, bool* p_selected, bool enabled = true); // return true when activated + toggle (*p_selected) if p_selected != NULL
|
||||
|
||||
// Popup
|
||||
// Popups
|
||||
IMGUI_API void OpenPopup(const char* str_id); // mark popup as open. popups are closed when user click outside, or activate a pressable item, or CloseCurrentPopup() is called within a BeginPopup()/EndPopup() block. popup identifiers are relative to the current ID-stack (so OpenPopup and BeginPopup needs to be at the same level).
|
||||
IMGUI_API bool BeginPopup(const char* str_id); // return true if popup if opened and start outputting to it. only call EndPopup() if BeginPopup() returned true!
|
||||
IMGUI_API bool BeginPopupModal(const char* name, bool* p_opened = NULL, ImGuiWindowFlags extra_flags = 0); // modal dialog (can't close them by clicking outside)
|
||||
@ -407,7 +410,7 @@ namespace ImGui
|
||||
IMGUI_API bool IsMouseReleased(int button); // did mouse button released (went from Down to !Down)
|
||||
IMGUI_API bool IsMouseHoveringWindow(); // is mouse hovering current window ("window" in API names always refer to current window). disregarding of any consideration of being blocked by a popup. (unlike IsWindowHovered() this will return true even if the window is blocked because of a popup)
|
||||
IMGUI_API bool IsMouseHoveringAnyWindow(); // is mouse hovering any visible window
|
||||
IMGUI_API bool IsMouseHoveringRect(const ImVec2& pos_min, const ImVec2& pos_max, bool clip = true); // is mouse hovering given bounding rect (in screen space). clipped by current clipping settings. disregarding of consideration of focus/window ordering/blocked by a popup.
|
||||
IMGUI_API bool IsMouseHoveringRect(const ImVec2& r_min, const ImVec2& r_max, bool clip = true); // is mouse hovering given bounding rect (in screen space). clipped by current clipping settings. disregarding of consideration of focus/window ordering/blocked by a popup.
|
||||
IMGUI_API bool IsMouseDragging(int button = 0, float lock_threshold = -1.0f); // is mouse dragging. if lock_threshold < -1.0f uses io.MouseDraggingThreshold
|
||||
IMGUI_API ImVec2 GetMousePos(); // shortcut to ImGui::GetIO().MousePos provided by user, to be consistent with other calls
|
||||
IMGUI_API ImVec2 GetMousePosOnOpeningCurrentPopup(); // retrieve backup of mouse positioning at the time of opening popup we have BeginPopup() into
|
||||
@ -1255,7 +1258,7 @@ struct ImFontAtlas
|
||||
int TexWidth; // Texture width calculated during Build().
|
||||
int TexHeight; // Texture height calculated during Build().
|
||||
int TexDesiredWidth; // Texture width desired by user before Build(). Must be a power-of-two. If have many glyphs your graphics API have texture size restrictions you may want to increase texture width to decrease height.
|
||||
ImVec2 TexUvWhitePixel; // Texture coordinates to a white pixel (part of the TexExtraData block)
|
||||
ImVec2 TexUvWhitePixel; // Texture coordinates to a white pixel
|
||||
ImVector<ImFont*> Fonts; // Hold all the fonts returned by AddFont*. Fonts[0] is the default font upon calling ImGui::NewFrame(), use ImGui::PushFont()/PopFont() to change the current font.
|
||||
|
||||
// Private
|
||||
|
@ -906,7 +906,7 @@ void ImDrawList::AddText(const ImFont* font, float font_size, const ImVec2& pos,
|
||||
_VtxCurrentIdx = (unsigned int)VtxBuffer.Size;
|
||||
}
|
||||
|
||||
// This is one of the few function breaking the encapsulation of ImDrawLst, but it is just so useful.
|
||||
// [Uses global ImGui state] This is one of the few function breaking the encapsulation of ImDrawLst, but it is just so useful.
|
||||
void ImDrawList::AddText(const ImVec2& pos, ImU32 col, const char* text_begin, const char* text_end)
|
||||
{
|
||||
if ((col >> 24) == 0)
|
||||
|
@ -356,7 +356,7 @@ struct ImGuiState
|
||||
ImFont* Font; // (Shortcut) == FontStack.empty() ? IO.Font : FontStack.back()
|
||||
float FontSize; // (Shortcut) == FontBaseSize * g.CurrentWindow->FontWindowScale == window->FontSize()
|
||||
float FontBaseSize; // (Shortcut) == IO.FontGlobalScale * Font->Scale * Font->FontSize. Size of characters.
|
||||
ImVec2 FontTexUvWhitePixel; // (Shortcut) == Font->TexUvForWhite
|
||||
ImVec2 FontTexUvWhitePixel; // (Shortcut) == Font->TexUvWhitePixel
|
||||
|
||||
float Time;
|
||||
int FrameCount;
|
||||
|
Loading…
Reference in New Issue
Block a user