Fix rendering of horizontal scrollbar, related to #59
This commit is contained in:
parent
55e89579ad
commit
fe280423b8
1 changed files with 12 additions and 7 deletions
|
|
@ -622,17 +622,17 @@ where
|
||||||
);
|
);
|
||||||
state.scrollbar_v_rect.set(rect);
|
state.scrollbar_v_rect.set(rect);
|
||||||
|
|
||||||
if (image_w as f32) < max_line_width {
|
let (buffer_w, buffer_h) = buffer.size();
|
||||||
|
let scrollbar_h_width = image_w as f32 / scale_factor - scrollbar_w as f32;
|
||||||
|
if buffer_w < max_line_width {
|
||||||
let rect = Rectangle::new(
|
let rect = Rectangle::new(
|
||||||
[
|
[
|
||||||
(scroll_x as f32 / max_line_width as f32) * image_w as f32
|
(buffer.scroll().horizontal / max_line_width) * scrollbar_h_width,
|
||||||
/ scale_factor,
|
buffer_h / scale_factor - scrollbar_w as f32,
|
||||||
image_h as f32 / scale_factor - scrollbar_w as f32,
|
|
||||||
]
|
]
|
||||||
.into(),
|
.into(),
|
||||||
Size::new(
|
Size::new(
|
||||||
(image_w as f32 / max_line_width as f32) * image_w as f32
|
(buffer_w / max_line_width) * scrollbar_h_width,
|
||||||
/ scale_factor,
|
|
||||||
scrollbar_w as f32,
|
scrollbar_w as f32,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
@ -765,6 +765,7 @@ where
|
||||||
// Draw horizontal scrollbar
|
// Draw horizontal scrollbar
|
||||||
//TODO: reduce repitition
|
//TODO: reduce repitition
|
||||||
if let Some(scrollbar_h_rect) = state.scrollbar_h_rect.get() {
|
if let Some(scrollbar_h_rect) = state.scrollbar_h_rect.get() {
|
||||||
|
/*TODO: horizontal scrollbar track?
|
||||||
// neutral_3, 0.7
|
// neutral_3, 0.7
|
||||||
let track_color = cosmic_theme
|
let track_color = cosmic_theme
|
||||||
.palette
|
.palette
|
||||||
|
|
@ -777,7 +778,10 @@ where
|
||||||
Quad {
|
Quad {
|
||||||
bounds: Rectangle::new(
|
bounds: Rectangle::new(
|
||||||
Point::new(image_position.x, image_position.y + scrollbar_h_rect.y),
|
Point::new(image_position.x, image_position.y + scrollbar_h_rect.y),
|
||||||
Size::new(layout.bounds().width, scrollbar_h_rect.height),
|
Size::new(
|
||||||
|
layout.bounds().width - scrollbar_w as f32,
|
||||||
|
scrollbar_h_rect.height,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
border: Border {
|
border: Border {
|
||||||
radius: (scrollbar_h_rect.height / 2.0).into(),
|
radius: (scrollbar_h_rect.height / 2.0).into(),
|
||||||
|
|
@ -788,6 +792,7 @@ where
|
||||||
},
|
},
|
||||||
Color::from(track_color),
|
Color::from(track_color),
|
||||||
);
|
);
|
||||||
|
*/
|
||||||
|
|
||||||
let pressed = matches!(&state.dragging, Some(Dragging::ScrollbarH { .. }));
|
let pressed = matches!(&state.dragging, Some(Dragging::ScrollbarH { .. }));
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue