Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Datatable extend background #1946

Merged
merged 7 commits into from
Mar 6, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## [0.14.0] - Unreleased

### Changes
### Changed

- Breaking change: There is now only `post_message` to post events, which is non-async, `post_message_no_wait` was dropped. https://github.com/Textualize/textual/pull/1940
- Breaking change: The Timer class now has just one method to stop it, `Timer.stop` which is non sync https://github.com/Textualize/textual/pull/1940
- Breaking change: Messages don't require a `sender` in their constructor https://github.com/Textualize/textual/pull/1940
- Many messages have grown a `control` property which returns the control they relate to. https://github.com/Textualize/textual/pull/1940
- Dropped `time` attribute from Messages https://github.com/Textualize/textual/pull/1940
- Updated styling to make it clear DataTable grows horizontally https://github.com/Textualize/textual/pull/1946

### Added

Expand Down
23 changes: 23 additions & 0 deletions src/textual/widgets/_data_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from .._two_way_dict import TwoWayDict
from .._types import SegmentLines
from ..binding import Binding, BindingType
from ..color import Color
from ..coordinate import Coordinate
from ..geometry import Region, Size, Spacing, clamp
from ..message import Message
Expand Down Expand Up @@ -880,6 +881,9 @@ async def on_styles_updated(self) -> None:
self._clear_caches()
self.refresh()

def on_resize(self, event: events.Resize) -> None:
self._update_count += 1

def watch_show_cursor(self, show_cursor: bool) -> None:
self._clear_caches()
if show_cursor and self.cursor_type != "none":
Expand Down Expand Up @@ -1682,6 +1686,25 @@ def _should_highlight(
)[line_no]
scrollable_row.append(cell_lines)

# Extending the styling out horizontally to fill the container
widget_width = self.size.width
table_width = (
sum(
column.render_width
for column in self.ordered_columns[self.fixed_columns :]
)
+ self._row_label_column_width
)
remaining_space = max(0, widget_width - table_width)
background_color = self.background_colors[1]
faded_color = Color.from_rich_color(row_style.bgcolor).blend(
background_color, factor=0.25
)
faded_style = Style.from_color(
color=row_style.color, bgcolor=faded_color.rich_color
)
scrollable_row.append([Segment(" " * remaining_space, faded_style)])

row_pair = (fixed_row, scrollable_row)
self._row_render_cache[cache_key] = row_pair
return row_pair
Expand Down
Loading