mirror of
https://github.com/danbulant/cushy
synced 2026-07-05 03:00:43 +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),
|
Lp::points(300)..Lp::points(600),
|
||||||
Stack::rows(username_row.and(password_row).and(buttons)),
|
Stack::rows(username_row.and(password_row).and(buttons)),
|
||||||
)
|
)
|
||||||
|
.scroll()
|
||||||
.centered()
|
.centered()
|
||||||
.expand()
|
.expand()
|
||||||
.run()
|
.run()
|
||||||
|
|
|
||||||
|
|
@ -5,5 +5,6 @@ use gooey::Run;
|
||||||
fn main() -> gooey::Result {
|
fn main() -> gooey::Result {
|
||||||
Label::new(include_str!("../src/widgets/scroll.rs"))
|
Label::new(include_str!("../src/widgets/scroll.rs"))
|
||||||
.scroll()
|
.scroll()
|
||||||
|
.expand()
|
||||||
.run()
|
.run()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -126,22 +126,17 @@ impl Widget for Scroll {
|
||||||
|
|
||||||
fn redraw(&mut self, context: &mut crate::context::GraphicsContext<'_, '_, '_, '_, '_>) {
|
fn redraw(&mut self, context: &mut crate::context::GraphicsContext<'_, '_, '_, '_, '_>) {
|
||||||
context.redraw_when_changed(&self.scrollbar_opacity);
|
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());
|
let managed = self.contents.mounted(&mut context.as_event_context());
|
||||||
context.for_other(&managed).redraw();
|
context.for_other(&managed).redraw();
|
||||||
|
|
||||||
|
let size = context.gfx.region().size;
|
||||||
|
|
||||||
if self.horizontal_bar.amount_hidden > 0 {
|
if self.horizontal_bar.amount_hidden > 0 {
|
||||||
context.gfx.draw_shape(
|
context.gfx.draw_shape(
|
||||||
&Shape::filled_rect(
|
&Shape::filled_rect(
|
||||||
Rect::new(
|
Rect::new(
|
||||||
Point::new(
|
Point::new(self.horizontal_bar.offset, size.height - self.bar_width),
|
||||||
self.horizontal_bar.offset,
|
|
||||||
self.control_size.height - self.bar_width,
|
|
||||||
),
|
|
||||||
Size::new(self.horizontal_bar.size, 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()),
|
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(
|
context.gfx.draw_shape(
|
||||||
&Shape::filled_rect(
|
&Shape::filled_rect(
|
||||||
Rect::new(
|
Rect::new(
|
||||||
Point::new(
|
Point::new(size.width - self.bar_width, self.vertical_bar.offset),
|
||||||
visible_bottom_right.x - self.bar_width,
|
|
||||||
self.vertical_bar.offset,
|
|
||||||
),
|
|
||||||
Size::new(self.bar_width, self.vertical_bar.size),
|
Size::new(self.bar_width, self.vertical_bar.size),
|
||||||
),
|
),
|
||||||
Color::new_f32(1.0, 1.0, 1.0, *self.scrollbar_opacity.get()),
|
Color::new_f32(1.0, 1.0, 1.0, *self.scrollbar_opacity.get()),
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue