fix horizontal scroll bar style

pull/16/head
Takayuki Maeda 3 years ago
parent a86183916a
commit 4f27c79bf7

@ -302,6 +302,19 @@ impl DrawableComponent for TableComponent {
}, },
); );
let column_width = area.width.saturating_pow(10);
self.horizontal_scroll.update(
if self.headers.is_empty() {
0
} else {
column_width
.saturating_mul(self.headers[..self.column_index].len() as u16)
.saturating_add(1) as usize
},
column_width.saturating_mul(self.headers.len() as u16) as usize,
area.width.saturating_sub(2) as usize,
);
TableValueComponent::new(self.selected_cell().unwrap_or_default()) TableValueComponent::new(self.selected_cell().unwrap_or_default())
.draw(f, layout[0], focused)?; .draw(f, layout[0], focused)?;
@ -315,18 +328,6 @@ impl DrawableComponent for TableComponent {
Style::default() Style::default()
}) })
}); });
let column_width = area.width.saturating_pow(10);
self.horizontal_scroll.update(
if self.headers.is_empty() {
0
} else {
column_width
.saturating_mul(self.headers[..self.column_index].len() as u16)
.saturating_add(1) as usize
},
column_width.saturating_mul(self.headers.len() as u16) as usize,
area.width.saturating_sub(2) as usize,
);
let header = Row::new(header_cells).height(1).bottom_margin(1); let header = Row::new(header_cells).height(1).bottom_margin(1);
let rows = rows.iter().enumerate().map(|(row_index, item)| { let rows = rows.iter().enumerate().map(|(row_index, item)| {
let height = item let height = item

@ -4,7 +4,7 @@ use tui::{
backend::Backend, backend::Backend,
buffer::Buffer, buffer::Buffer,
layout::{Margin, Rect}, layout::{Margin, Rect},
style::Style, style::{Color, Modifier, Style},
symbols::{ symbols::{
block::FULL, block::FULL,
line::{DOUBLE_HORIZONTAL, DOUBLE_VERTICAL}, line::{DOUBLE_HORIZONTAL, DOUBLE_VERTICAL},
@ -97,7 +97,12 @@ impl Widget for Scrollbar {
if self.vertical { if self.vertical {
buf.set_string(right, bar_top + pos, FULL, self.style_pos); buf.set_string(right, bar_top + pos, FULL, self.style_pos);
} else { } else {
buf.set_string(bar_top + pos, bottom, "▆", self.style_pos); buf.set_string(
bar_top + pos,
bottom,
"\u{2212}",
self.style_pos.add_modifier(Modifier::BOLD),
);
} }
} }
} }
@ -110,6 +115,6 @@ pub fn draw_scrollbar<B: Backend>(
vertical: bool, vertical: bool,
) { ) {
let mut widget = Scrollbar::new(max, pos, vertical); let mut widget = Scrollbar::new(max, pos, vertical);
widget.style_pos = Style::default(); widget.style_pos = Style::default().fg(Color::Blue);
f.render_widget(widget, r); f.render_widget(widget, r);
} }

Loading…
Cancel
Save