Finished terminal hyperlinks for now
This commit is contained in:
parent
d2d49633f1
commit
4bc0afdafa
3 changed files with 124 additions and 73 deletions
|
@ -14,6 +14,7 @@ pub struct Overlay {
|
|||
anchor_position: Option<Vector2F>,
|
||||
anchor_corner: AnchorCorner,
|
||||
fit_mode: OverlayFitMode,
|
||||
position_mode: OverlayPositionMode,
|
||||
hoverable: bool,
|
||||
}
|
||||
|
||||
|
@ -24,6 +25,12 @@ pub enum OverlayFitMode {
|
|||
None,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, PartialEq, Eq)]
|
||||
pub enum OverlayPositionMode {
|
||||
Window,
|
||||
Local,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, PartialEq, Eq)]
|
||||
pub enum AnchorCorner {
|
||||
TopLeft,
|
||||
|
@ -73,6 +80,7 @@ impl Overlay {
|
|||
anchor_position: None,
|
||||
anchor_corner: AnchorCorner::TopLeft,
|
||||
fit_mode: OverlayFitMode::None,
|
||||
position_mode: OverlayPositionMode::Window,
|
||||
hoverable: false,
|
||||
}
|
||||
}
|
||||
|
@ -92,6 +100,11 @@ impl Overlay {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn with_position_mode(mut self, position_mode: OverlayPositionMode) -> Self {
|
||||
self.position_mode = position_mode;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_hoverable(mut self, hoverable: bool) -> Self {
|
||||
self.hoverable = hoverable;
|
||||
self
|
||||
|
@ -123,8 +136,20 @@ impl Element for Overlay {
|
|||
size: &mut Self::LayoutState,
|
||||
cx: &mut PaintContext,
|
||||
) {
|
||||
let anchor_position = self.anchor_position.unwrap_or_else(|| bounds.origin());
|
||||
let mut bounds = self.anchor_corner.get_bounds(anchor_position, *size);
|
||||
let (anchor_position, mut bounds) = match self.position_mode {
|
||||
OverlayPositionMode::Window => {
|
||||
let anchor_position = self.anchor_position.unwrap_or_else(|| bounds.origin());
|
||||
let bounds = self.anchor_corner.get_bounds(anchor_position, *size);
|
||||
(anchor_position, bounds)
|
||||
}
|
||||
OverlayPositionMode::Local => {
|
||||
let anchor_position = self.anchor_position.unwrap_or_default();
|
||||
let bounds = self
|
||||
.anchor_corner
|
||||
.get_bounds(bounds.origin() + anchor_position, *size);
|
||||
(anchor_position, bounds)
|
||||
}
|
||||
};
|
||||
|
||||
match self.fit_mode {
|
||||
OverlayFitMode::SnapToWindow => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue