mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
Datatable extend background (#1946)
* Extending DataTable widget horizontally * Fading background of extended DataTable rows * Updating DataTable snapshots * Update CHANGELOG.md --------- Co-authored-by: Will McGugan <willmcgugan@gmail.com>
This commit is contained in:
@@ -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
|
||||
- Changed the `Checkbox` character due to issues with Windows Terminal and Windows 10 https://github.com/Textualize/textual/issues/1934
|
||||
- Changed the `RadioButton` character due to issues with Windows Terminal and Windows 10 and 11 https://github.com/Textualize/textual/issues/1934
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ from .._segment_tools import line_crop
|
||||
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
|
||||
@@ -880,6 +881,9 @@ class DataTable(ScrollView, Generic[CellType], can_focus=True):
|
||||
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":
|
||||
@@ -1682,6 +1686,25 @@ class DataTable(ScrollView, Generic[CellType], can_focus=True):
|
||||
)[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
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user