Skip to content

Commit 9c9dc9b

Browse files
authored
Merge pull request #595 from kas-gui/push-yormommnwkxl
Use Viewport in ScrollRegion
2 parents 3ac4d4d + f2a99f9 commit 9c9dc9b

File tree

11 files changed

+376
-171
lines changed

11 files changed

+376
-171
lines changed

crates/kas-core/src/theme/flat_theme.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ where
265265
}
266266

267267
fn colors(&self) -> &ColorsLinear {
268-
&self.cols
268+
self.cols
269269
}
270270

271271
fn draw_rounded(&mut self) -> Option<&mut dyn DrawRounded> {

crates/kas-core/src/theme/simple_theme.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ where
214214
}
215215

216216
fn colors(&self) -> &ColorsLinear {
217-
&self.cols
217+
self.cols
218218
}
219219

220220
fn draw_rounded(&mut self) -> Option<&mut dyn DrawRounded> {

crates/kas-macros/src/lib.rs

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -424,11 +424,28 @@ pub fn layout(_: TokenStream, item: TokenStream) -> TokenStream {
424424
///
425425
/// ```ignore
426426
/// #[impl_self]
427-
/// mod ScrollBarRegion {
428-
/// #[autoimpl(Deref, DerefMut using self.0)]
429-
/// #[derive(Clone, Default)]
427+
/// mod Align {
428+
/// /// Apply an alignment hint
430429
/// #[derive_widget]
431-
/// pub struct ScrollBarRegion<W: Widget>(#[widget] ScrollBars<ScrollRegion<W>>);
430+
/// pub struct Align<W: Widget> {
431+
/// #[widget]
432+
/// pub inner: W,
433+
/// hints: AlignHints,
434+
/// }
435+
///
436+
/// impl Self {
437+
/// /// Construct
438+
/// #[inline]
439+
/// pub fn new(inner: W, hints: AlignHints) -> Self {
440+
/// Align { inner, hints }
441+
/// }
442+
/// }
443+
///
444+
/// impl Layout for Self {
445+
/// fn set_rect(&mut self, cx: &mut SizeCx, rect: Rect, hints: AlignHints) {
446+
/// self.inner.set_rect(cx, rect, self.hints.combine(hints));
447+
/// }
448+
/// }
432449
/// }
433450
/// ```
434451
///

crates/kas-macros/src/make_layout.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,7 @@ impl Layout {
614614
// Note that try_probe_recurse fails on non-widget fields though these might still
615615
// be valid layout targets; if not then the requirement for an explicit fn probe
616616
// may be confusing without this error.
617-
if !fields.iter().any(|ident| *ident == expr.member) {
617+
if !fields.contains(&expr.member) {
618618
emit_error!(expr, "not a field of self")
619619
}
620620
}

crates/kas-wgpu/src/shaded_theme.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ where
183183
}
184184

185185
fn colors(&self) -> &ColorsLinear {
186-
&self.cols
186+
self.cols
187187
}
188188

189189
fn draw_rounded(&mut self) -> Option<&mut dyn DrawRounded> {

crates/kas-widgets/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
//! ## Container widgets
2323
//!
2424
//! - [`Frame`]: a frame around content
25-
//! - [`ScrollRegion`], [`ScrollBarRegion`]: larger on the inside
25+
//! - [`ClipRegion`], [`ScrollRegion`]: larger on the inside
2626
//! - [`Stack`], [`TabStack`]: a stack of widgets in the same rect
2727
//! - [`List`]: a row / column of children
2828
//! - [`Splitter`]: like [`List`] but with resizing handles
@@ -104,8 +104,8 @@ pub use grip::{GripMsg, GripPart};
104104
pub use list::*;
105105
pub use progress::ProgressBar;
106106
pub use radio_box::{RadioBox, RadioButton};
107-
pub use scroll::ScrollRegion;
108-
pub use scroll_bar::{ScrollBar, ScrollBarMode, ScrollBarRegion, ScrollBars, ScrollMsg};
107+
pub use scroll::{ClipRegion, ScrollRegion};
108+
pub use scroll_bar::{ScrollBar, ScrollBarMode, ScrollBars, ScrollMsg};
109109
pub use scroll_label::{ScrollLabel, ScrollText, SelectableLabel, SelectableText};
110110
pub use separator::Separator;
111111
pub use slider::{Slider, SliderValue};

0 commit comments

Comments
 (0)