|
@@ -967,6 +967,8 @@ void ImGui::TableUpdateLayout(ImGuiTable* table)
|
|
// clear ActiveId, which is equivalent to the change provided by _AllowWhenBLockedByActiveItem).
|
|
// clear ActiveId, which is equivalent to the change provided by _AllowWhenBLockedByActiveItem).
|
|
// - This allows columns to be marked as hovered when e.g. clicking a button inside the column, or using drag and drop.
|
|
// - This allows columns to be marked as hovered when e.g. clicking a button inside the column, or using drag and drop.
|
|
ImGuiTableInstanceData* table_instance = TableGetInstanceData(table, table->InstanceCurrent);
|
|
ImGuiTableInstanceData* table_instance = TableGetInstanceData(table, table->InstanceCurrent);
|
|
|
|
+ table_instance->HoveredRowLast = table_instance->HoveredRowNext;
|
|
|
|
+ table_instance->HoveredRowNext = -1;
|
|
table->HoveredColumnBody = -1;
|
|
table->HoveredColumnBody = -1;
|
|
table->HoveredColumnBorder = -1;
|
|
table->HoveredColumnBorder = -1;
|
|
const ImRect mouse_hit_rect(table->OuterRect.Min.x, table->OuterRect.Min.y, table->OuterRect.Max.x, ImMax(table->OuterRect.Max.y, table->OuterRect.Min.y + table_instance->LastOuterHeight));
|
|
const ImRect mouse_hit_rect(table->OuterRect.Min.x, table->OuterRect.Min.y, table->OuterRect.Max.x, ImMax(table->OuterRect.Max.y, table->OuterRect.Min.y + table_instance->LastOuterHeight));
|
|
@@ -1543,6 +1545,7 @@ void ImGui::TableSetupScrollFreeze(int columns, int rows)
|
|
// - TableGetCellBgRect() [Internal]
|
|
// - TableGetCellBgRect() [Internal]
|
|
// - TableGetColumnResizeID() [Internal]
|
|
// - TableGetColumnResizeID() [Internal]
|
|
// - TableGetHoveredColumn() [Internal]
|
|
// - TableGetHoveredColumn() [Internal]
|
|
|
|
+// - TableGetHoveredRow() [Internal]
|
|
// - TableSetBgColor()
|
|
// - TableSetBgColor()
|
|
//-----------------------------------------------------------------------------
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
@@ -1647,6 +1650,19 @@ int ImGui::TableGetHoveredColumn()
|
|
return (int)table->HoveredColumnBody;
|
|
return (int)table->HoveredColumnBody;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// Return -1 when table is not hovered. Return maxrow+1 if in table but below last submitted row.
|
|
|
|
+// *IMPORTANT* Unlike TableGetHoveredColumn(), this has a one frame latency in updating the value.
|
|
|
|
+// This difference with is the reason why this is not public yet.
|
|
|
|
+int ImGui::TableGetHoveredRow()
|
|
|
|
+{
|
|
|
|
+ ImGuiContext& g = *GImGui;
|
|
|
|
+ ImGuiTable* table = g.CurrentTable;
|
|
|
|
+ if (!table)
|
|
|
|
+ return -1;
|
|
|
|
+ ImGuiTableInstanceData* table_instance = TableGetInstanceData(table, table->InstanceCurrent);
|
|
|
|
+ return (int)table_instance->HoveredRowLast;
|
|
|
|
+}
|
|
|
|
+
|
|
void ImGui::TableSetBgColor(ImGuiTableBgTarget target, ImU32 color, int column_n)
|
|
void ImGui::TableSetBgColor(ImGuiTableBgTarget target, ImU32 color, int column_n)
|
|
{
|
|
{
|
|
ImGuiContext& g = *GImGui;
|
|
ImGuiContext& g = *GImGui;
|
|
@@ -1798,6 +1814,10 @@ void ImGui::TableEndRow(ImGuiTable* table)
|
|
const bool is_visible = (bg_y2 >= table->InnerClipRect.Min.y && bg_y1 <= table->InnerClipRect.Max.y);
|
|
const bool is_visible = (bg_y2 >= table->InnerClipRect.Min.y && bg_y1 <= table->InnerClipRect.Max.y);
|
|
if (is_visible)
|
|
if (is_visible)
|
|
{
|
|
{
|
|
|
|
+ // Update data for TableGetHoveredRow()
|
|
|
|
+ if (table->HoveredColumnBody != -1 && g.IO.MousePos.y >= bg_y1 && g.IO.MousePos.y < bg_y2)
|
|
|
|
+ TableGetInstanceData(table, table->InstanceCurrent)->HoveredRowNext = table->CurrentRow;
|
|
|
|
+
|
|
// Decide of background color for the row
|
|
// Decide of background color for the row
|
|
ImU32 bg_col0 = 0;
|
|
ImU32 bg_col0 = 0;
|
|
ImU32 bg_col1 = 0;
|
|
ImU32 bg_col1 = 0;
|
|
@@ -3591,6 +3611,11 @@ void ImGui::DebugNodeTable(ImGuiTable* table)
|
|
BulletText("CellPaddingX: %.1f, CellSpacingX: %.1f/%.1f, OuterPaddingX: %.1f", table->CellPaddingX, table->CellSpacingX1, table->CellSpacingX2, table->OuterPaddingX);
|
|
BulletText("CellPaddingX: %.1f, CellSpacingX: %.1f/%.1f, OuterPaddingX: %.1f", table->CellPaddingX, table->CellSpacingX1, table->CellSpacingX2, table->OuterPaddingX);
|
|
BulletText("HoveredColumnBody: %d, HoveredColumnBorder: %d", table->HoveredColumnBody, table->HoveredColumnBorder);
|
|
BulletText("HoveredColumnBody: %d, HoveredColumnBorder: %d", table->HoveredColumnBody, table->HoveredColumnBorder);
|
|
BulletText("ResizedColumn: %d, ReorderColumn: %d, HeldHeaderColumn: %d", table->ResizedColumn, table->ReorderColumn, table->HeldHeaderColumn);
|
|
BulletText("ResizedColumn: %d, ReorderColumn: %d, HeldHeaderColumn: %d", table->ResizedColumn, table->ReorderColumn, table->HeldHeaderColumn);
|
|
|
|
+ for (int n = 0; n < table->InstanceCurrent + 1; n++)
|
|
|
|
+ {
|
|
|
|
+ ImGuiTableInstanceData* table_instance = TableGetInstanceData(table, n);
|
|
|
|
+ BulletText("Instance %d: HoveredRow: %d, LastOuterHeight: %.2f", n, table_instance->HoveredRowLast, table_instance->LastOuterHeight);
|
|
|
|
+ }
|
|
//BulletText("BgDrawChannels: %d/%d", 0, table->BgDrawChannelUnfrozen);
|
|
//BulletText("BgDrawChannels: %d/%d", 0, table->BgDrawChannelUnfrozen);
|
|
float sum_weights = 0.0f;
|
|
float sum_weights = 0.0f;
|
|
for (int n = 0; n < table->ColumnsCount; n++)
|
|
for (int n = 0; n < table->ColumnsCount; n++)
|