mirror of
https://github.com/extrawurst/gitui.git
synced 2024-11-22 11:03:25 +03:00
commit popup centered
This commit is contained in:
parent
7b289ab71b
commit
472bec5db3
@ -19,7 +19,7 @@ Over the last 2 years my go to GUI tool for this was [fork](https://git-fork.com
|
||||
* [x] support staging
|
||||
* [x] show added files on working dir changes
|
||||
* [x] support committing
|
||||
* [ ] popup centered
|
||||
* [x] popup centered
|
||||
* [ ] crash: adding a pic to index crashes
|
||||
* [ ] crash: renamed files cannot be added to index
|
||||
* [ ] allow selecting/diff index items
|
||||
|
BIN
assets/main.jpg
BIN
assets/main.jpg
Binary file not shown.
Before Width: | Height: | Size: 189 KiB After Width: | Height: | Size: 166 KiB |
@ -186,7 +186,7 @@ impl App {
|
||||
.block(Block::default().title("Commit").borders(Borders::ALL))
|
||||
.alignment(Alignment::Left),
|
||||
)
|
||||
.render(f, Rect::new(20, 0, 100, 10));
|
||||
.render(f, git_utils::centered_rect(60, 20, f.size()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
use git2::{DiffFormat, DiffOptions, Repository};
|
||||
use std::path::Path;
|
||||
use tui::layout::{Constraint, Direction, Layout, Rect};
|
||||
|
||||
///
|
||||
#[derive(Copy, Clone, PartialEq)]
|
||||
@ -103,3 +104,31 @@ pub fn commit(msg: &String) {
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
/// use layouts to create a rects that
|
||||
/// centers inside `r` and sizes `percent_x`/`percent_x` of `r`
|
||||
pub fn centered_rect(percent_x: u16, percent_y: u16, r: Rect) -> Rect {
|
||||
let popup_layout = Layout::default()
|
||||
.direction(Direction::Vertical)
|
||||
.constraints(
|
||||
[
|
||||
Constraint::Percentage((100 - percent_y) / 2),
|
||||
Constraint::Percentage(percent_y),
|
||||
Constraint::Percentage((100 - percent_y) / 2),
|
||||
]
|
||||
.as_ref(),
|
||||
)
|
||||
.split(r);
|
||||
|
||||
Layout::default()
|
||||
.direction(Direction::Horizontal)
|
||||
.constraints(
|
||||
[
|
||||
Constraint::Percentage((100 - percent_x) / 2),
|
||||
Constraint::Percentage(percent_x),
|
||||
Constraint::Percentage((100 - percent_x) / 2),
|
||||
]
|
||||
.as_ref(),
|
||||
)
|
||||
.split(popup_layout[1])[1]
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user