This commit is contained in:
2025-12-07 00:32:38 -05:00
parent 62aa02847a
commit 38266debb6
7 changed files with 68 additions and 32 deletions

View File

@@ -180,3 +180,17 @@ impl<const LEN: usize, Wa: WidgetArrLike<LEN, Tag>, Tag> SpanBuilder<LEN, Wa, Ta
self
}
}
impl std::ops::Deref for Span {
type Target = Vec<WidgetId>;
fn deref(&self) -> &Self::Target {
&self.children
}
}
impl std::ops::DerefMut for Span {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.children
}
}

View File

@@ -12,7 +12,7 @@ pub struct TextBuilder<O = TextOutput, H: WidgetOption = ()> {
impl<O, H: WidgetOption> TextBuilder<O, H> {
pub fn size(mut self, size: impl UiNum) -> Self {
self.attrs.font_size = size.to_f32();
self.attrs.line_height = self.attrs.font_size * 1.1;
self.attrs.line_height = self.attrs.font_size * LINE_HEIGHT_MULT;
self
}
pub fn color(mut self, color: UiColor) -> Self {
@@ -31,6 +31,10 @@ impl<O, H: WidgetOption> TextBuilder<O, H> {
self.attrs.align = align.into();
self
}
pub fn center_text(mut self) -> Self {
self.attrs.align = Align::CENTER;
self
}
pub fn wrap(mut self, wrap: bool) -> Self {
self.attrs.wrap = wrap;
self

View File

@@ -1,6 +1,9 @@
use super::*;
use crate::prelude::*;
// these methods should "not require any context" (require unit) because they're in core
event_ctx!(());
pub trait CoreWidget<W, Tag> {
fn pad(self, padding: impl Into<Padding>) -> impl WidgetFn<Pad>;
fn align(self, align: impl Into<Align>) -> impl WidgetFn<Aligned>;
@@ -100,8 +103,6 @@ impl<W: WidgetLike<Tag>, Tag> CoreWidget<W::Widget, Tag> for W {
}
fn scroll(self) -> impl WidgetIdFn<Scroll> {
event_ctx!(());
move |ui| {
Scroll::new(self.add(ui).any(), Axis::Y)
.on(CursorSense::Scroll, |ctx| {