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

Minimise the need to batch operations in PlainEditor #192

Merged
merged 5 commits into from
Dec 5, 2024
Merged
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
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ This release has an [MSRV] of 1.75.

- `Generation` on `PlainEditor` to help implement lazy drawing. ([#143] by [@xorgy])

### Changed

### Parley

- Breaking change: `PlainEditor`'s semantics are no longer transactional ([#192][] by [@DJMcNab][])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may also want to say support for IME preedit composing text is is introduced into PlainEditor.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in #197. Sorry for missing this!


## [0.2.0] - 2024-10-10

Expand Down Expand Up @@ -76,6 +81,7 @@ This release has an [MSRV] of 1.70.
[MSRV]: README.md#minimum-supported-rust-version-msrv

[@dfrg]: https://github.com/dfrg
[@DJMcNab]: https://github.com/DJMcNab
[@nicoburns]: https://github.com/nicoburns
[@waywardmonkeys]: https://github.com/waywardmonkeys
[@xorgy]: https://github.com/xorgy
Expand All @@ -93,6 +99,7 @@ This release has an [MSRV] of 1.70.
[#126]: https://github.com/linebender/parley/pull/126
[#129]: https://github.com/linebender/parley/pull/129
[#143]: https://github.com/linebender/parley/pull/143
[#192]: https://github.com/linebender/parley/pull/192

[Unreleased]: https://github.com/linebender/parley/compare/v0.2.0...HEAD
[0.2.0]: https://github.com/linebender/parley/releases/tag/v0.2.0
Expand Down
25 changes: 7 additions & 18 deletions examples/vello_editor/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ mod access_ids;
use access_ids::{TEXT_INPUT_ID, WINDOW_ID};

mod text;
use parley::{GenericFamily, StyleProperty};

const WINDOW_TITLE: &str = "Vello Text Editor";

Expand Down Expand Up @@ -114,15 +113,10 @@ impl ApplicationHandler<accesskit_winit::Event> for SimpleVelloApp<'_> {
let access_adapter =
accesskit_winit::Adapter::with_event_loop_proxy(&window, self.event_loop_proxy.clone());
window.set_visible(true);
window.set_ime_allowed(true);

let size = window.inner_size();

self.editor.transact(|txn| {
txn.set_scale(1.0);
txn.set_width(Some(size.width as f32 - 2f32 * text::INSET));
txn.set_text(text::LOREM);
});

// Create a vello Surface
let surface_future = {
let surface = self
Expand Down Expand Up @@ -236,15 +230,9 @@ impl ApplicationHandler<accesskit_winit::Event> for SimpleVelloApp<'_> {
WindowEvent::Resized(size) => {
self.context
.resize_surface(&mut render_state.surface, size.width, size.height);
self.editor.transact(|txn| {
txn.set_scale(1.0);
txn.set_width(Some(size.width as f32 - 2f32 * text::INSET));
txn.set_default_style(Arc::new([
StyleProperty::FontSize(32.0),
StyleProperty::LineHeight(1.2),
GenericFamily::SystemUi.into(),
]));
});
let editor = self.editor.editor();
editor.set_scale(1.0);
editor.set_width(Some(size.width as f32 - 2f32 * text::INSET));
render_state.window.request_redraw();
}

Expand Down Expand Up @@ -352,7 +340,7 @@ fn main() -> Result<()> {
renderers: vec![],
state: RenderState::Suspended(None),
scene: Scene::new(),
editor: text::Editor::default(),
editor: text::Editor::new(text::LOREM),
last_drawn_generation: Default::default(),
event_loop_proxy: event_loop.create_proxy(),
};
Expand All @@ -361,7 +349,8 @@ fn main() -> Result<()> {
event_loop
.run_app(&mut app)
.expect("Couldn't run event loop");
print!("{}", app.editor.text());
let text = app.editor.text();
print!("{text}");
Ok(())
}

Expand Down
Loading
Loading