Skip to content

Commit

Permalink
lib: Rename pane group
Browse files Browse the repository at this point in the history
  • Loading branch information
erak committed Dec 11, 2024
1 parent fc19c2a commit d774d21
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
18 changes: 9 additions & 9 deletions bin/commands/patch/select/imui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use ratatui::Frame;
use radicle_tui as tui;

use tui::ui::im;
use tui::ui::im::widget::{GroupState, TableState, TextEditState, TextViewState, Window};
use tui::ui::im::widget::{PanesState, TableState, TextEditState, TextViewState, Window};
use tui::ui::im::Borders;
use tui::ui::im::Show;
use tui::ui::{BufferedValue, Column};
Expand Down Expand Up @@ -59,7 +59,7 @@ pub enum Message<'a> {
state: TableState,
},
MainGroupChanged {
state: GroupState,
state: PanesState,
},
PageChanged {
page: Page,
Expand Down Expand Up @@ -92,7 +92,7 @@ pub struct App<'a> {
storage: Storage,
mode: Mode,
page: Page,
main_group: GroupState,
main_group: PanesState,
patches: TableState,
search: BufferedValue<TextEditState>,
show_search: bool,
Expand Down Expand Up @@ -125,7 +125,7 @@ impl<'a> TryFrom<&Context> for App<'a> {
},
mode: context.mode.clone(),
page: Page::Main,
main_group: GroupState::new(3, Some(0)),
main_group: PanesState::new(3, Some(0)),
patches: TableState::new(Some(0)),
search: BufferedValue::new(TextEditState {
text: search.clone(),
Expand Down Expand Up @@ -180,12 +180,12 @@ impl<'a> store::Update<Message<'a>> for App<'a> {
None
}
Message::ShowSearch => {
self.main_group = GroupState::new(3, None);
self.main_group = PanesState::new(3, None);
self.show_search = true;
None
}
Message::HideSearch { apply } => {
self.main_group = GroupState::new(3, Some(0));
self.main_group = PanesState::new(3, Some(0));
self.show_search = false;

if apply {
Expand Down Expand Up @@ -223,11 +223,11 @@ impl<'a> Show<Message<'a>> for App<'a> {
let mut page_focus = if show_search { Some(1) } else { Some(0) };
let mut group_focus = self.main_group.focus();

ui.group(
ui.panes(
Layout::vertical([Constraint::Fill(1), Constraint::Length(2)]),
&mut page_focus,
|ui| {
let group = ui.group(
let group = ui.panes(
im::Layout::Expandable3 { left_only: true },
&mut group_focus,
|ui| {
Expand All @@ -249,7 +249,7 @@ impl<'a> Show<Message<'a>> for App<'a> {
);
if group.response.changed {
ui.send_message(Message::MainGroupChanged {
state: GroupState::new(3, group_focus),
state: PanesState::new(3, group_focus),
});
}

Expand Down
4 changes: 2 additions & 2 deletions src/ui/im.rs
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ impl<M> Ui<M>
where
M: Clone,
{
pub fn group<R>(
pub fn panes<R>(
&mut self,
layout: impl Into<Layout>,
focus: &mut Option<usize>,
Expand All @@ -470,7 +470,7 @@ where
..self.child_ui(area, layout)
};

widget::Group::new(len, focus).show(&mut child_ui, add_contents)
widget::Panes::new(len, focus).show(&mut child_ui, add_contents)
}

pub fn composite<R>(
Expand Down
10 changes: 5 additions & 5 deletions src/ui/im/widget.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,12 @@ impl Window {
}

#[derive(Clone, Debug)]
pub struct GroupState {
pub struct PanesState {
len: usize,
focus: Option<usize>,
}

impl GroupState {
impl PanesState {
pub fn new(len: usize, focus: Option<usize>) -> Self {
Self { len, focus }
}
Expand Down Expand Up @@ -94,12 +94,12 @@ impl GroupState {
}
}

pub struct Group<'a> {
pub struct Panes<'a> {
focus: &'a mut Option<usize>,
len: usize,
}

impl<'a> Group<'a> {
impl<'a> Panes<'a> {
pub fn new(len: usize, focus: &'a mut Option<usize>) -> Self {
Self { len, focus }
}
Expand All @@ -125,7 +125,7 @@ impl<'a> Group<'a> {
{
let mut response = Response::default();

let mut state = GroupState {
let mut state = PanesState {
focus: *self.focus,
len: self.len,
};
Expand Down

0 comments on commit d774d21

Please sign in to comment.