Skip to content

Commit ea492d6

Browse files
committed
fix(controls): table border transparency and scroll event bubbling
TableControl.Rendering: use effectiveBg (transparent) instead of bgColor for border lines, allowing gradient backgrounds to show through. TableControl.Mouse: return false when scroll offset didn't change, allowing parent ScrollablePanel to handle the event. MultilineEditControl.Mouse: same fix — bubble scroll events at limits instead of unconditionally consuming them.
1 parent c15d317 commit ea492d6

3 files changed

Lines changed: 30 additions & 16 deletions

File tree

SharpConsoleUI/Controls/MultilineEdit/MultilineEditControl.Mouse.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -398,8 +398,9 @@ public bool ProcessMouseEvent(MouseEventArgs args)
398398
_skipUpdateScrollPositionsInRender = true;
399399
_verticalScrollOffset -= scrollAmount;
400400
Container?.Invalidate(true);
401+
return true;
401402
}
402-
return true;
403+
return false; // at top, bubble to parent
403404
}
404405

405406
// Mouse wheel down
@@ -414,8 +415,9 @@ public bool ProcessMouseEvent(MouseEventArgs args)
414415
_skipUpdateScrollPositionsInRender = true;
415416
_verticalScrollOffset += scrollAmount;
416417
Container?.Invalidate(true);
418+
return true;
417419
}
418-
return true;
420+
return false; // at bottom, bubble to parent
419421
}
420422

421423
// Regular mouse move (no drag)

SharpConsoleUI/Controls/TableControl/TableControl.Mouse.cs

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,27 +120,39 @@ public bool ProcessMouseEvent(MouseEventArgs args)
120120
{
121121
if (args.HasFlag(MouseFlags.ButtonShift))
122122
{
123+
int oldH = _horizontalScrollOffset;
123124
_horizontalScrollOffset = Math.Max(0, _horizontalScrollOffset - 3);
124-
Container?.Invalidate(true);
125-
return true;
125+
if (_horizontalScrollOffset != oldH)
126+
{
127+
Container?.Invalidate(true);
128+
return true;
129+
}
130+
return false; // bubble to parent
126131
}
127132

133+
int oldOffset = _scrollOffset;
128134
ScrollOffset = Math.Max(0, _scrollOffset - 3);
129-
return true;
135+
return _scrollOffset != oldOffset; // bubble if didn't scroll
130136
}
131137

132138
if (args.HasFlag(MouseFlags.WheeledDown))
133139
{
134140
if (args.HasFlag(MouseFlags.ButtonShift))
135141
{
142+
int oldH = _horizontalScrollOffset;
136143
_horizontalScrollOffset += 3;
137-
Container?.Invalidate(true);
138-
return true;
144+
if (_horizontalScrollOffset != oldH)
145+
{
146+
Container?.Invalidate(true);
147+
return true;
148+
}
149+
return false; // bubble to parent
139150
}
140151

152+
int oldOffset = _scrollOffset;
141153
int maxOffset = Math.Max(0, RowCount - GetVisibleRowCount());
142154
ScrollOffset = Math.Min(maxOffset, _scrollOffset + 3);
143-
return true;
155+
return _scrollOffset != oldOffset; // bubble if didn't scroll
144156
}
145157

146158
// Left-click

SharpConsoleUI/Controls/TableControl/TableControl.Rendering.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,7 @@ void FillSideMargins(int y)
587587
if (hasBorder && currentY < maxY)
588588
{
589589
FillSideMargins(currentY);
590-
DrawHorizontalLine(buffer, startX, currentY, colWidths, clipRect, box, borderColor, bgColor,
590+
DrawHorizontalLine(buffer, startX, currentY, colWidths, clipRect, box, borderColor, effectiveBg,
591591
box.TopLeft, box.TopTee, box.TopRight, box.Horizontal);
592592
currentY++;
593593
}
@@ -626,7 +626,7 @@ void FillSideMargins(int y)
626626
}
627627
}
628628

629-
DrawDataRow(buffer, startX, currentY, colWidths, clipRect, box, borderColor, bgColor,
629+
DrawDataRow(buffer, startX, currentY, colWidths, clipRect, box, borderColor, effectiveBg,
630630
headerCells, colSnapshot, headerFg, headerBg, hasBorder);
631631

632632
// Update column rendered positions for hit testing (always, including DataSource mode)
@@ -653,7 +653,7 @@ void FillSideMargins(int y)
653653
if (hasBorder && currentY < maxY)
654654
{
655655
FillSideMargins(currentY);
656-
DrawHorizontalLine(buffer, startX, currentY, colWidths, clipRect, box, borderColor, bgColor,
656+
DrawHorizontalLine(buffer, startX, currentY, colWidths, clipRect, box, borderColor, effectiveBg,
657657
box.LeftTee, box.Cross, box.RightTee, box.Horizontal);
658658
currentY++;
659659
}
@@ -675,7 +675,7 @@ void FillSideMargins(int y)
675675
if (displayR > startRow && _showRowSeparators && hasBorder && currentY < maxY)
676676
{
677677
FillSideMargins(currentY);
678-
DrawHorizontalLine(buffer, startX, currentY, colWidths, clipRect, box, borderColor, bgColor,
678+
DrawHorizontalLine(buffer, startX, currentY, colWidths, clipRect, box, borderColor, effectiveBg,
679679
box.LeftTee, box.Cross, box.RightTee, box.Horizontal);
680680
currentY++;
681681
}
@@ -795,7 +795,7 @@ void FillSideMargins(int y)
795795
{
796796
FillSideMargins(currentY);
797797
DrawMergedHorizontalLine(buffer, startX, currentY, colWidths, clipRect,
798-
box, borderColor, bgColor, box.LeftTee, box.RightTee, box.Horizontal);
798+
box, borderColor, effectiveBg, box.LeftTee, box.RightTee, box.Horizontal);
799799
currentY++;
800800
}
801801

@@ -817,15 +817,15 @@ void FillSideMargins(int y)
817817
{
818818
FillSideMargins(currentY);
819819
DrawMergedHorizontalLine(buffer, startX, currentY, colWidths, clipRect,
820-
box, borderColor, bgColor, box.BottomLeft, box.BottomRight, box.Horizontal);
820+
box, borderColor, effectiveBg, box.BottomLeft, box.BottomRight, box.Horizontal);
821821
currentY++;
822822
}
823823
}
824824
else if (hasBorder && currentY < maxY)
825825
{
826826
// Standard bottom border with column tees
827827
FillSideMargins(currentY);
828-
DrawHorizontalLine(buffer, startX, currentY, colWidths, clipRect, box, borderColor, bgColor,
828+
DrawHorizontalLine(buffer, startX, currentY, colWidths, clipRect, box, borderColor, effectiveBg,
829829
box.BottomLeft, box.BottomTee, box.BottomRight, box.Horizontal);
830830
currentY++;
831831
}
@@ -861,7 +861,7 @@ void FillSideMargins(int y)
861861
{
862862
int cornerX = startX + contentWidth;
863863
if (cornerX >= clipRect.X && cornerX < clipRect.Right)
864-
buffer.SetNarrowCell(cornerX, currentY, ' ', fgColor, bgColor);
864+
buffer.SetNarrowCell(cornerX, currentY, ' ', fgColor, effectiveBg);
865865
}
866866
currentY++;
867867
}

0 commit comments

Comments
 (0)