mirror of
https://github.com/danbulant/cushy
synced 2026-06-18 05:51:20 +00:00
Scroll fixes
This commit is contained in:
parent
eb4b24f4a9
commit
68339dfb62
3 changed files with 6 additions and 12 deletions
|
|
@ -46,6 +46,7 @@ fn main() -> gooey::Result {
|
|||
Lp::points(300)..Lp::points(600),
|
||||
Stack::rows(username_row.and(password_row).and(buttons)),
|
||||
)
|
||||
.scroll()
|
||||
.centered()
|
||||
.expand()
|
||||
.run()
|
||||
|
|
|
|||
|
|
@ -5,5 +5,6 @@ use gooey::Run;
|
|||
fn main() -> gooey::Result {
|
||||
Label::new(include_str!("../src/widgets/scroll.rs"))
|
||||
.scroll()
|
||||
.expand()
|
||||
.run()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -126,22 +126,17 @@ impl Widget for Scroll {
|
|||
|
||||
fn redraw(&mut self, context: &mut crate::context::GraphicsContext<'_, '_, '_, '_, '_>) {
|
||||
context.redraw_when_changed(&self.scrollbar_opacity);
|
||||
let Some(visible_rect) = context.gfx.visible_rect() else {
|
||||
return;
|
||||
};
|
||||
let visible_bottom_right = visible_rect.into_signed().extent();
|
||||
|
||||
let managed = self.contents.mounted(&mut context.as_event_context());
|
||||
context.for_other(&managed).redraw();
|
||||
|
||||
let size = context.gfx.region().size;
|
||||
|
||||
if self.horizontal_bar.amount_hidden > 0 {
|
||||
context.gfx.draw_shape(
|
||||
&Shape::filled_rect(
|
||||
Rect::new(
|
||||
Point::new(
|
||||
self.horizontal_bar.offset,
|
||||
self.control_size.height - self.bar_width,
|
||||
),
|
||||
Point::new(self.horizontal_bar.offset, size.height - self.bar_width),
|
||||
Size::new(self.horizontal_bar.size, self.bar_width),
|
||||
),
|
||||
Color::new_f32(1.0, 1.0, 1.0, *self.scrollbar_opacity.get()),
|
||||
|
|
@ -156,10 +151,7 @@ impl Widget for Scroll {
|
|||
context.gfx.draw_shape(
|
||||
&Shape::filled_rect(
|
||||
Rect::new(
|
||||
Point::new(
|
||||
visible_bottom_right.x - self.bar_width,
|
||||
self.vertical_bar.offset,
|
||||
),
|
||||
Point::new(size.width - self.bar_width, self.vertical_bar.offset),
|
||||
Size::new(self.bar_width, self.vertical_bar.size),
|
||||
),
|
||||
Color::new_f32(1.0, 1.0, 1.0, *self.scrollbar_opacity.get()),
|
||||
|
|
|
|||
Loading…
Reference in a new issue