Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Text handling refactor #625

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
218 changes: 6 additions & 212 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ xilem_core = { version = "0.1.0", path = "xilem_core" }
vello = "0.2.1"
wgpu = "0.20.1"
kurbo = "0.11.0"
parley = "0.1.0"
parley = { version = "0.1.0", git = "https://github.com/linebender/parley", branch = "main" }
peniko = "0.1.1"
winit = "0.30.4"
tracing = { version = "0.1.40", default-features = false }
Expand Down
7 changes: 4 additions & 3 deletions masonry/examples/custom_widget.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,13 @@ impl Widget for CustomWidget {
text_layout_builder.push_default(&StyleProperty::FontSize(24.0));
text_layout_builder.push_default(&StyleProperty::Brush(Brush::Solid(fill_color).into()));

let mut text_layout = text_layout_builder.build();
text_layout.break_all_lines(None, Alignment::Start);
let mut text_layout = text_layout_builder.build(&self.0);
text_layout.break_all_lines(None);
text_layout.align(None, Alignment::Start);

let mut scratch_scene = Scene::new();
// We can pass a transform matrix to rotate the text we render
masonry::text_helpers::render_text(
masonry::text::render_text(
scene,
&mut scratch_scene,
Affine::rotate(std::f64::consts::FRAC_PI_4).then_translate((80.0, 40.0).into()),
Expand Down
11 changes: 0 additions & 11 deletions masonry/src/contexts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ use crate::action::Action;
use crate::passes::layout::run_layout_on;
use crate::render_root::{MutateCallback, RenderRootSignal, RenderRootState};
use crate::text::TextBrush;
use crate::text_helpers::ImeChangeSignal;
use crate::tree_arena::{ArenaMutChildren, ArenaRefChildren};
use crate::widget::{WidgetMut, WidgetRef, WidgetState};
use crate::{
Expand Down Expand Up @@ -550,16 +549,6 @@ impl_context_method!(MutateCtx<'_>, EventCtx<'_>, LifeCycleCtx<'_>, {
self.widget_state.needs_update_disabled = true;
self.widget_state.is_explicitly_disabled = disabled;
}

#[allow(unused)]
/// Indicate that text input state has changed.
///
/// A widget that accepts text input should call this anytime input state
/// (such as the text or the selection) changes as a result of a non text-input
/// event.
pub fn invalidate_text_input(&mut self, event: ImeChangeSignal) {
todo!("invalidate_text_input");
}
});

// --- MARK: OTHER METHODS ---
Expand Down
4 changes: 1 addition & 3 deletions masonry/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,6 @@ mod event;
pub mod paint_scene_helpers;
pub mod render_root;
pub mod testing;
// mod text;
pub mod text_helpers;
pub mod theme;
pub mod widget;

Expand Down Expand Up @@ -151,4 +149,4 @@ pub use vello::peniko::{Color, Gradient};
pub use widget::widget::{AllowRawMut, Widget, WidgetId};
pub use widget::{WidgetPod, WidgetState};

pub use text_helpers::ArcStr;
pub use text::ArcStr;
Loading
Loading