mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-22 11:57:00 +00:00
Tables: Double-clicking on fixed column to resize. Extracted code BeginTableEx().
# Conflicts: # imgui_internal.h
This commit is contained in:
parent
883c236eda
commit
0c3d7bb154
@ -2181,6 +2181,8 @@ namespace ImGui
|
|||||||
//IMGUI_API int GetTableColumnNo();
|
//IMGUI_API int GetTableColumnNo();
|
||||||
//IMGUI_API bool SetTableColumnNo(int column_n);
|
//IMGUI_API bool SetTableColumnNo(int column_n);
|
||||||
//IMGUI_API int GetTableLineNo();
|
//IMGUI_API int GetTableLineNo();
|
||||||
|
|
||||||
|
IMGUI_API bool BeginTableEx(const char* name, ImGuiID id, int columns_count, ImGuiTableFlags flags = 0, const ImVec2& outer_size = ImVec2(0, 0), float inner_width = 0.0f);
|
||||||
IMGUI_API void TableBeginInitVisibility(ImGuiTable* table);
|
IMGUI_API void TableBeginInitVisibility(ImGuiTable* table);
|
||||||
IMGUI_API void TableUpdateDrawChannels(ImGuiTable* table);
|
IMGUI_API void TableUpdateDrawChannels(ImGuiTable* table);
|
||||||
IMGUI_API void TableUpdateLayout(ImGuiTable* table);
|
IMGUI_API void TableUpdateLayout(ImGuiTable* table);
|
||||||
|
@ -145,13 +145,18 @@ inline ImGuiTableFlags TableFixFlags(ImGuiTableFlags flags)
|
|||||||
// FIXME-TABLE: Replace enlarge vs fixed width by a flag.
|
// FIXME-TABLE: Replace enlarge vs fixed width by a flag.
|
||||||
// Even if not really useful, we allow 'inner_scroll_width < outer_size.x' for consistency and to facilitate understanding of what the value does.
|
// Even if not really useful, we allow 'inner_scroll_width < outer_size.x' for consistency and to facilitate understanding of what the value does.
|
||||||
bool ImGui::BeginTable(const char* str_id, int columns_count, ImGuiTableFlags flags, const ImVec2& outer_size, float inner_width)
|
bool ImGui::BeginTable(const char* str_id, int columns_count, ImGuiTableFlags flags, const ImVec2& outer_size, float inner_width)
|
||||||
|
{
|
||||||
|
ImGuiID id = GetID(str_id);
|
||||||
|
return BeginTableEx(str_id, id, columns_count, flags, outer_size, inner_width);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ImGui::BeginTableEx(const char* name, ImGuiID id, int columns_count, ImGuiTableFlags flags, const ImVec2& outer_size, float inner_width)
|
||||||
{
|
{
|
||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
ImGuiWindow* outer_window = GetCurrentWindow();
|
ImGuiWindow* outer_window = GetCurrentWindow();
|
||||||
IM_ASSERT(columns_count > 0 && columns_count < IMGUI_TABLE_MAX_COLUMNS && "Only 0..63 columns allowed!");
|
IM_ASSERT(columns_count > 0 && columns_count < IMGUI_TABLE_MAX_COLUMNS && "Only 0..63 columns allowed!");
|
||||||
if (flags & ImGuiTableFlags_ScrollX)
|
if (flags & ImGuiTableFlags_ScrollX)
|
||||||
IM_ASSERT(inner_width >= 0.0f);
|
IM_ASSERT(inner_width >= 0.0f);
|
||||||
ImGuiID id = GetID(str_id);
|
|
||||||
|
|
||||||
const bool use_child_window = (flags & (ImGuiTableFlags_ScrollX | ImGuiTableFlags_ScrollY)) != 0;
|
const bool use_child_window = (flags & (ImGuiTableFlags_ScrollX | ImGuiTableFlags_ScrollY)) != 0;
|
||||||
const ImVec2 avail_size = GetContentRegionAvail();
|
const ImVec2 avail_size = GetContentRegionAvail();
|
||||||
@ -209,7 +214,7 @@ bool ImGui::BeginTable(const char* str_id, int columns_count, ImGuiTableFlags
|
|||||||
|
|
||||||
// Create scrolling region (without border = zero window padding)
|
// Create scrolling region (without border = zero window padding)
|
||||||
ImGuiWindowFlags child_flags = (flags & ImGuiTableFlags_ScrollX) ? ImGuiWindowFlags_HorizontalScrollbar : ImGuiWindowFlags_None;
|
ImGuiWindowFlags child_flags = (flags & ImGuiTableFlags_ScrollX) ? ImGuiWindowFlags_HorizontalScrollbar : ImGuiWindowFlags_None;
|
||||||
BeginChildEx(str_id, instance_id, table->OuterRect.GetSize(), false, child_flags);
|
BeginChildEx(name, instance_id, table->OuterRect.GetSize(), false, child_flags);
|
||||||
table->InnerWindow = g.CurrentWindow;
|
table->InnerWindow = g.CurrentWindow;
|
||||||
table->WorkRect = table->InnerWindow->WorkRect;
|
table->WorkRect = table->InnerWindow->WorkRect;
|
||||||
table->OuterRect = table->InnerWindow->Rect();
|
table->OuterRect = table->InnerWindow->Rect();
|
||||||
@ -810,7 +815,14 @@ void ImGui::TableUpdateBorders(ImGuiTable* table)
|
|||||||
KeepAliveID(column_id);
|
KeepAliveID(column_id);
|
||||||
|
|
||||||
bool hovered = false, held = false;
|
bool hovered = false, held = false;
|
||||||
ButtonBehavior(hit_rect, column_id, &hovered, &held, ImGuiButtonFlags_FlattenChildren | ImGuiButtonFlags_AllowItemOverlap);
|
bool pressed = ButtonBehavior(hit_rect, column_id, &hovered, &held, ImGuiButtonFlags_FlattenChildren | ImGuiButtonFlags_AllowItemOverlap | ImGuiButtonFlags_PressedOnClick | ImGuiButtonFlags_PressedOnDoubleClick);
|
||||||
|
if (pressed && IsMouseDoubleClicked(0) && !(column->Flags & ImGuiTableColumnFlags_WidthStretch))
|
||||||
|
{
|
||||||
|
// FIXME-TABLE: Double-clicking on column edge could auto-fit weighted column?
|
||||||
|
TableSetColumnAutofit(table, column_n);
|
||||||
|
ClearActiveID();
|
||||||
|
held = hovered = false;
|
||||||
|
}
|
||||||
if (held)
|
if (held)
|
||||||
{
|
{
|
||||||
table->ResizedColumn = (ImS8)column_n;
|
table->ResizedColumn = (ImS8)column_n;
|
||||||
|
Loading…
Reference in New Issue
Block a user