mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
optimize link highlight
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
# Content-align
|
# Content-align
|
||||||
|
|
||||||
The `content-align` property allows you to align content _inside_ a widget.
|
The `content-align` style aligns content _inside_ a widget.
|
||||||
|
|
||||||
You can specify the alignment of content on both the horizontal and vertical axes.
|
You can specify the alignment of content on both the horizontal and vertical axes.
|
||||||
|
|
||||||
@@ -15,7 +15,7 @@ content-align: <HORIZONTAL> <VERTICAL>;
|
|||||||
#### `HORIZONTAL`
|
#### `HORIZONTAL`
|
||||||
|
|
||||||
| Value | Description |
|
| Value | Description |
|
||||||
|------------------|----------------------------------------------------|
|
| ---------------- | -------------------------------------------------- |
|
||||||
| `left` (default) | Align content on the left of the horizontal axis |
|
| `left` (default) | Align content on the left of the horizontal axis |
|
||||||
| `center` | Align content in the center of the horizontal axis |
|
| `center` | Align content in the center of the horizontal axis |
|
||||||
| `right` | Align content on the right of the horizontal axis |
|
| `right` | Align content on the right of the horizontal axis |
|
||||||
@@ -23,7 +23,7 @@ content-align: <HORIZONTAL> <VERTICAL>;
|
|||||||
#### `VERTICAL`
|
#### `VERTICAL`
|
||||||
|
|
||||||
| Value | Description |
|
| Value | Description |
|
||||||
|-----------------|--------------------------------------------------|
|
| --------------- | ------------------------------------------------ |
|
||||||
| `top` (default) | Align content at the top of the vertical axis |
|
| `top` (default) | Align content at the top of the vertical axis |
|
||||||
| `middle` | Align content in the middle of the vertical axis |
|
| `middle` | Align content in the middle of the vertical axis |
|
||||||
| `bottom` | Align content at the bottom of the vertical axis |
|
| `bottom` | Align content at the bottom of the vertical axis |
|
||||||
|
|||||||
@@ -977,7 +977,7 @@ class App(Generic[ReturnType], DOMNode):
|
|||||||
finally:
|
finally:
|
||||||
self.mouse_over = None
|
self.mouse_over = None
|
||||||
else:
|
else:
|
||||||
if self.mouse_over != widget:
|
if self.mouse_over is not widget:
|
||||||
try:
|
try:
|
||||||
if self.mouse_over is not None:
|
if self.mouse_over is not None:
|
||||||
await self.mouse_over._forward_event(events.Leave(self))
|
await self.mouse_over._forward_event(events.Leave(self))
|
||||||
|
|||||||
@@ -147,7 +147,8 @@ class Widget(DOMNode):
|
|||||||
auto_links = Reactive(True)
|
auto_links = Reactive(True)
|
||||||
"""Widget will highlight links automatically."""
|
"""Widget will highlight links automatically."""
|
||||||
|
|
||||||
hover_style: Reactive[Style] = Reactive(Style)
|
hover_style: Reactive[Style] = Reactive(Style, repaint=False)
|
||||||
|
highlight_link_id: Reactive[str] = Reactive("")
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
@@ -446,6 +447,12 @@ class Widget(DOMNode):
|
|||||||
|
|
||||||
return height
|
return height
|
||||||
|
|
||||||
|
def watch_hover_style(
|
||||||
|
self, previous_hover_style: Style, hover_style: Style
|
||||||
|
) -> None:
|
||||||
|
if self.auto_links:
|
||||||
|
self.highlight_link_id = hover_style.link_id
|
||||||
|
|
||||||
def watch_scroll_x(self, new_value: float) -> None:
|
def watch_scroll_x(self, new_value: float) -> None:
|
||||||
self.horizontal_scrollbar.position = int(new_value)
|
self.horizontal_scrollbar.position = int(new_value)
|
||||||
self.refresh(layout=True)
|
self.refresh(layout=True)
|
||||||
|
|||||||
Reference in New Issue
Block a user