-
Notifications
You must be signed in to change notification settings - Fork 437
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support customizable alignment for image display
- Loading branch information
Showing
15 changed files
with
262 additions
and
192 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
use ratatui::layout::Size; | ||
use yazi_config::{PREVIEW, preview::{HorizontalAlignment, VerticalAlignment}}; | ||
|
||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)] | ||
pub struct Offset { | ||
pub x: u16, | ||
pub y: u16, | ||
} | ||
|
||
impl From<(Size, Size)> for Offset { | ||
fn from(value: (Size, Size)) -> Self { | ||
let inner = value.0; | ||
let outer = value.1; | ||
let offset_x = match PREVIEW.alignment.horizontal { | ||
HorizontalAlignment::Left => 0, | ||
HorizontalAlignment::Center => (outer.width - inner.width) / 2, | ||
HorizontalAlignment::Right => outer.width - inner.width, | ||
}; | ||
let offset_y = match PREVIEW.alignment.vertical { | ||
VerticalAlignment::Top => 0, | ||
VerticalAlignment::Center => (outer.height - inner.height) / 2, | ||
VerticalAlignment::Bottom => outer.height - inner.height, | ||
}; | ||
Self { x: offset_x, y: offset_y } | ||
} | ||
} |
Oops, something went wrong.