Skip to content

Commit

Permalink
Refactor ScrollBars to their own widget
Browse files Browse the repository at this point in the history
Closes #181
  • Loading branch information
ecton committed Oct 19, 2024
1 parent 5adb37d commit 171cf3f
Show file tree
Hide file tree
Showing 14 changed files with 693 additions and 438 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `MakeWidgetList::into_layers` -> `IntoWidgetList::into_layers`
- `MakeWidgetList::into_wrap` -> `IntoWidgetList::into_wrap`
- `MakeWidgetList::into_list` -> `IntoWidgetList::into_list`
- `ConstraintLimit::fit_measured` and `FitMeasuredSize::fit_measured` now accept
either a `Px` or `UPx` measurement, and does not perform scaling adjustments.
To convert `Lp` use `into_upx()` first.

### Changed

Expand Down Expand Up @@ -115,6 +118,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
allow overdrawing the widget's bounds. This was noticable in the
nested-scroll.rs example when reducing the height of the window below 6
inches.
- `Scroll` now uses the new `ScrollBar` widget for its bars rather than manually
drawing them. By making this change, the bars now have input priority over the
contents. This means that the scroll bars are now clickable even in areas
where interactive widgets are beneath them.

### Added

Expand Down Expand Up @@ -252,6 +259,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `Scroll` now exposes its scroll amount, maximum scroll, and more information
that allows completely customizing a scroll view's behavior. Thanks to
@danbulant for helping with this change!
- `ScrollBar` is a new widget that renders a scroll bar meant to scroll through
a large container.


[139]: https://github.com/khonsulabs/cushy/issues/139
Expand Down
107 changes: 52 additions & 55 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion examples/nested-scroll.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use cushy::figures::units::Lp;
use cushy::kludgine::cosmic_text::FamilyOwned;
use cushy::styles::components::FontFamily;
use cushy::styles::FontFamilyList;
use cushy::styles::{Edges, FontFamilyList};
use cushy::widget::MakeWidget;
use cushy::Run;

Expand All @@ -17,6 +17,7 @@ fn main() -> cushy::Result {
.height(Lp::inches(3)),
)
.into_rows()
.pad_by(Edges::default().with_right(Lp::points(7)))
.vertical_scroll()
.expand()
.run()
Expand Down
9 changes: 3 additions & 6 deletions examples/tilemap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,15 @@ use std::cmp::Ordering;
use std::time::Duration;

use cushy::figures::units::Px;
use cushy::figures::FloatConversion;
use cushy::figures::{Point, Rect, Size};
use cushy::kludgine::app::winit::keyboard::Key;
use cushy::kludgine::app::winit::keyboard::NamedKey;
use cushy::figures::{FloatConversion, Point, Rect, Size};
use cushy::kludgine::app::winit::keyboard::{Key, NamedKey};
use cushy::kludgine::drawing::Renderer;
use cushy::kludgine::shapes::Shape;
use cushy::kludgine::sprite::{Sprite, SpriteSource};
use cushy::kludgine::tilemap::{
DebugGrid, Object, ObjectLayer, TileArray, TileKind, TileMapFocus, TILE_SIZE,
};
use cushy::kludgine::Color;
use cushy::kludgine::{include_aseprite_sprite, DrawableExt};
use cushy::kludgine::{include_aseprite_sprite, Color, DrawableExt};
use cushy::value::{Destination, Dynamic};
use cushy::widgets::TileMap;
use cushy::{Run, Tick};
Expand Down
Loading

0 comments on commit 171cf3f

Please sign in to comment.