Skip to content

Commit

Permalink
Implement changes from code reviews
Browse files Browse the repository at this point in the history
  • Loading branch information
PoignardAzur committed Aug 30, 2024
1 parent 443ef28 commit 7f359c8
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
5 changes: 5 additions & 0 deletions masonry/src/passes/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,11 @@ pub(crate) fn run_update_disabled_pass(root: &mut RenderRoot) {

// ----------------

// This pass will update scroll positions in cases where a widget has requested to be
// scrolled into view (usually a textbox getting text events).
// Each parent that implements scrolling will update its scroll position to ensure the
// child is visible. (If the target area is larger than the parent, the parent will try
// to show the top left of that area.)
pub(crate) fn run_update_scroll_pass(root: &mut RenderRoot) {
let _span = info_span!("update_scroll").entered();

Expand Down
7 changes: 1 addition & 6 deletions masonry/src/widget/portal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,7 @@ impl<W: Widget> Portal<W> {
// Note - Rect is in child coordinates
// TODO - Merge with pan_viewport_to
// Right now these functions are just different enough to be a pain to merge.
pub fn pan_viewport_to_raw(
&mut self,
portal_size: Size,
content_size: Size,
target: Rect,
) -> bool {
fn pan_viewport_to_raw(&mut self, portal_size: Size, content_size: Size, target: Rect) -> bool {
let viewport = Rect::from_origin_size(self.viewport_pos, portal_size);

let new_pos_x = compute_pan_range(
Expand Down
10 changes: 7 additions & 3 deletions masonry/src/widget/textbox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use vello::{
peniko::{BlendMode, Color},
Scene,
};
use winit::event::Ime;

use crate::widget::{LineBreaking, WidgetMut};
use crate::{
Expand Down Expand Up @@ -205,10 +206,13 @@ impl Widget for Textbox {

fn on_text_event(&mut self, ctx: &mut EventCtx, event: &TextEvent) {
let result = self.editor.text_event(ctx, event);
// If focused on a link and enter pressed, follow it?
if result.is_handled() {
// TODO - Use request_scroll_to with cursor rect
ctx.request_scroll_to_this();
// Some platforms will send a lot of spurious Preedit events.
// We only want to request a scroll on user input.
if !matches!(event, TextEvent::Ime(Ime::Preedit(..))) {
// TODO - Use request_scroll_to with cursor rect
ctx.request_scroll_to_this();
}
ctx.set_handled();
// TODO: only some handlers need this repaint
ctx.request_layout();
Expand Down

0 comments on commit 7f359c8

Please sign in to comment.