Skip to content

Commit

Permalink
also fix a bug with margins in battery
Browse files Browse the repository at this point in the history
  • Loading branch information
ClementTsang committed Dec 23, 2024
1 parent 0895171 commit f4769a0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
3 changes: 1 addition & 2 deletions src/canvas/components/data_table/draw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,10 @@ where
&mut self, f: &mut Frame<'_>, draw_info: &DrawInfo, widget: Option<&mut BottomWidget>,
painter: &Painter,
) {
let draw_horizontal = !self.props.is_basic || draw_info.is_on_widget();
let draw_loc = draw_info.loc;
let margined_draw_loc = Layout::default()
.constraints([Constraint::Percentage(100)])
.horizontal_margin(u16::from(!draw_horizontal))
.horizontal_margin(u16::from(self.props.is_basic && !draw_info.is_on_widget()))
.direction(Direction::Horizontal)
.split(draw_loc)[0];

Expand Down
8 changes: 4 additions & 4 deletions src/canvas/widgets/battery_display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ impl Painter {
.widget_states
.get_mut(&widget_id)
{
let is_on_widget = widget_id == app_state.current_widget.widget_id;
let border_style = if is_on_widget {
let is_selected = widget_id == app_state.current_widget.widget_id;
let border_style = if is_selected {
self.styles.highlighted_border_style
} else {
self.styles.border_style
Expand All @@ -42,7 +42,7 @@ impl Painter {
let block = {
let mut block = widget_block(
app_state.app_config_fields.use_basic_mode,
is_on_widget,
is_selected,
self.styles.border_type,
)
.border_style(border_style)
Expand Down Expand Up @@ -113,7 +113,7 @@ impl Painter {

let margined_draw_loc = Layout::default()
.constraints([Constraint::Percentage(100)])
.horizontal_margin(u16::from(!(is_on_widget || is_basic)))
.horizontal_margin(u16::from(is_basic && !is_selected))
.direction(Direction::Horizontal)
.split(draw_loc)[0];

Expand Down

0 comments on commit f4769a0

Please sign in to comment.