Skip to content

Commit 8cc0bd2

Browse files
committed
reformat
1 parent 3c84e1a commit 8cc0bd2

File tree

5 files changed

+58
-14
lines changed

5 files changed

+58
-14
lines changed

druid/src/contexts.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,6 @@ impl_context_trait!(
321321
}
322322
);
323323

324-
325324
// methods on everyone
326325
impl_context_method!(
327326
EventCtx<'_, '_>,

druid/src/core.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414

1515
//! The fundamental druid types.
1616
17+
use druid::contexts::CommandCtx;
1718
use std::collections::VecDeque;
1819
use tracing::{trace, trace_span, warn};
19-
use druid::contexts::CommandCtx;
2020

2121
use crate::bloom::Bloom;
2222
use crate::command::sys::{CLOSE_WINDOW, SUB_WINDOW_HOST_TO_PARENT, SUB_WINDOW_PARENT_TO_HOST};
@@ -273,7 +273,13 @@ impl<T, W: Widget<T>> WidgetPod<T, W> {
273273
/// [`LifeCycle::Size`]: enum.LifeCycle.html#variant.Size
274274
//TODO: we are using CommandCtx because it allows every context but paint, but it might be a
275275
// confusing name.
276-
pub fn set_origin<'a>(&mut self, ctx: &mut impl CommandCtx<'a>, _data: &T, _env: &Env, origin: Point) {
276+
pub fn set_origin<'a>(
277+
&mut self,
278+
ctx: &mut impl CommandCtx<'a>,
279+
_data: &T,
280+
_env: &Env,
281+
origin: Point,
282+
) {
277283
//TODO: decide whether we should keep data and env for compatibility or do a breaking change
278284
self.state.is_expecting_set_origin_call = false;
279285

druid/src/widget/clip_box.rs

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@
1313
// limitations under the License.
1414

1515
use crate::commands::SCROLL_TO_VIEW;
16+
use crate::contexts::CommandCtx;
1617
use crate::debug_state::DebugState;
1718
use crate::kurbo::{Point, Rect, Size, Vec2};
1819
use crate::widget::prelude::*;
1920
use crate::widget::Axis;
2021
use crate::{Data, InternalLifeCycle, WidgetPod};
2122
use tracing::{info, instrument, trace, warn};
22-
use crate::contexts::CommandCtx;
2323

2424
/// Represents the size and position of a rectangular "viewport" into a larger area.
2525
#[derive(Clone, Copy, Default, Debug, PartialEq)]
@@ -362,7 +362,13 @@ impl<T, W: Widget<T>> ClipBox<T, W> {
362362
/// Pans by `delta` units.
363363
///
364364
/// Returns `true` if the scroll offset has changed.
365-
pub fn pan_by<'a, C: CommandCtx<'a>>(&mut self, ctx: &mut C, data: &T, env: &Env, delta: Vec2) -> bool {
365+
pub fn pan_by<'a, C: CommandCtx<'a>>(
366+
&mut self,
367+
ctx: &mut C,
368+
data: &T,
369+
env: &Env,
370+
delta: Vec2,
371+
) -> bool {
366372
self.with_port(ctx, data, env, |_, port| {
367373
port.pan_by(delta);
368374
})
@@ -372,7 +378,13 @@ impl<T, W: Widget<T>> ClipBox<T, W> {
372378
///
373379
/// If the target region is larger than the viewport, we will display the
374380
/// portion that fits, prioritizing the portion closest to the origin.
375-
pub fn pan_to_visible<'a, C: CommandCtx<'a>>(&mut self, ctx: &mut C, data: &T, env: &Env, region: Rect) -> bool {
381+
pub fn pan_to_visible<'a, C: CommandCtx<'a>>(
382+
&mut self,
383+
ctx: &mut C,
384+
data: &T,
385+
env: &Env,
386+
region: Rect,
387+
) -> bool {
376388
self.with_port(ctx, data, env, |_, port| {
377389
port.pan_to_visible(region);
378390
})
@@ -381,7 +393,14 @@ impl<T, W: Widget<T>> ClipBox<T, W> {
381393
/// Pan to this position on a particular axis.
382394
///
383395
/// Returns `true` if the scroll offset has changed.
384-
pub fn pan_to_on_axis<'a, C: CommandCtx<'a>>(&mut self, ctx: &mut C, data: &T, env: &Env, axis: Axis, position: f64) -> bool {
396+
pub fn pan_to_on_axis<'a, C: CommandCtx<'a>>(
397+
&mut self,
398+
ctx: &mut C,
399+
data: &T,
400+
env: &Env,
401+
axis: Axis,
402+
position: f64,
403+
) -> bool {
385404
self.with_port(ctx, data, env, |_, port| {
386405
port.pan_to_on_axis(axis, position);
387406
})
@@ -421,7 +440,7 @@ impl<T: Data, W: Widget<T>> Widget<T> for ClipBox<T, W> {
421440
// prevent unexpected behaviour, by clipping SCROLL_TO_VIEW notifications
422441
// to this ClipBox's viewport.
423442
ctx.set_handled();
424-
self.with_port(ctx, data, env,|ctx, port| {
443+
self.with_port(ctx, data, env, |ctx, port| {
425444
port.fixed_scroll_to_view_handling(
426445
ctx,
427446
*global_highlight_rect,

druid/src/widget/scroll.rs

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@
1515
//! A container that scrolls its contents.
1616
1717
use crate::commands::SCROLL_TO_VIEW;
18+
use crate::contexts::CommandCtx;
1819
use crate::debug_state::DebugState;
1920
use crate::widget::prelude::*;
2021
use crate::widget::{Axis, ClipBox};
2122
use crate::{scroll_component::*, Data, Rect, Vec2};
2223
use tracing::{instrument, trace};
23-
use crate::contexts::CommandCtx;
2424

2525
/// A container that scrolls its contents.
2626
///
@@ -55,22 +55,41 @@ impl<T, W: Widget<T>> Scroll<T, W> {
5555
/// Scroll by `delta` units.
5656
///
5757
/// Returns `true` if the scroll offset has changed.
58-
pub fn scroll_by<'a, C: CommandCtx<'a>>(&mut self, ctx: &mut C, data: &T, env: &Env, delta: Vec2) -> bool {
58+
pub fn scroll_by<'a, C: CommandCtx<'a>>(
59+
&mut self,
60+
ctx: &mut C,
61+
data: &T,
62+
env: &Env,
63+
delta: Vec2,
64+
) -> bool {
5965
self.clip.pan_by(ctx, data, env, delta)
6066
}
6167

6268
/// Scroll the minimal distance to show the target rect.
6369
///
6470
/// If the target region is larger than the viewport, we will display the
6571
/// portion that fits, prioritizing the portion closest to the origin.
66-
pub fn scroll_to<'a, C: CommandCtx<'a>>(&mut self, ctx: &mut C, data: &T, env: &Env, region: Rect) -> bool {
72+
pub fn scroll_to<'a, C: CommandCtx<'a>>(
73+
&mut self,
74+
ctx: &mut C,
75+
data: &T,
76+
env: &Env,
77+
region: Rect,
78+
) -> bool {
6779
self.clip.pan_to_visible(ctx, data, env, region)
6880
}
6981

7082
/// Scroll to this position on a particular axis.
7183
///
7284
/// Returns `true` if the scroll offset has changed.
73-
pub fn scroll_to_on_axis<'a, C: CommandCtx<'a>>(&mut self, ctx: &mut C, data: &T, env: &Env, axis: Axis, position: f64) -> bool {
85+
pub fn scroll_to_on_axis<'a, C: CommandCtx<'a>>(
86+
&mut self,
87+
ctx: &mut C,
88+
data: &T,
89+
env: &Env,
90+
axis: Axis,
91+
position: f64,
92+
) -> bool {
7493
self.clip.pan_to_on_axis(ctx, data, env, axis, position)
7594
}
7695
}

druid/src/widget/textbox.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use std::time::Duration;
1818
use tracing::{instrument, trace};
1919

20+
use crate::contexts::CommandCtx;
2021
use crate::debug_state::DebugState;
2122
use crate::kurbo::Insets;
2223
use crate::piet::TextLayout as _;
@@ -29,7 +30,6 @@ use crate::{
2930
theme, ArcStr, Color, Command, FontDescriptor, HotKey, KeyEvent, KeyOrValue, Point, Rect,
3031
SysMods, TextAlignment, TimerToken, Vec2,
3132
};
32-
use crate::contexts::CommandCtx;
3333

3434
use super::LabelText;
3535

@@ -343,7 +343,8 @@ impl<T: TextStorage + EditableText> TextBox<T> {
343343
let is_visible =
344344
view_rect.contains(rect.origin()) && view_rect.contains(Point::new(rect.x1, rect.y1));
345345
if !is_visible {
346-
self.inner.scroll_to(ctx, data, env, rect + SCROLL_TO_INSETS);
346+
self.inner
347+
.scroll_to(ctx, data, env, rect + SCROLL_TO_INSETS);
347348
}
348349
}
349350

0 commit comments

Comments
 (0)