Skip to content

Commit dc69fde

Browse files
authored
Merge pull request #2916 from iced-rs/feature/float-widget
`float` widget and other cool stuff
2 parents 420ac0b + acde7ea commit dc69fde

File tree

52 files changed

+789
-446
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+789
-446
lines changed

beacon/src/client.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ pub enum Event {
4848
MessageLogged { number: usize, message: String },
4949
CommandsSpawned(usize),
5050
SubscriptionsTracked(usize),
51+
LayersRendered(usize),
5152
}
5253

5354
impl Client {

beacon/src/lib.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ pub fn run() -> impl Stream<Item = Event> {
127127
let mut last_tasks = 0;
128128
let mut last_subscriptions = 0;
129129
let mut last_present_window = None;
130+
let mut last_present_layers = 0;
130131

131132
drop(task::spawn(async move {
132133
let mut last_message_number = None;
@@ -199,6 +200,9 @@ pub fn run() -> impl Stream<Item = Event> {
199200
) => {
200201
last_tasks = commands;
201202
}
203+
client::Event::LayersRendered(layers) => {
204+
last_present_layers = layers;
205+
}
202206
client::Event::SpanStarted(
203207
span::Stage::Update,
204208
) => {
@@ -264,7 +268,10 @@ pub fn run() -> impl Stream<Item = Event> {
264268
}
265269
}
266270
span::Stage::Present(window) => {
267-
Span::Present { window }
271+
Span::Present {
272+
window,
273+
layers: last_present_layers,
274+
}
268275
}
269276
span::Stage::Custom(name) => {
270277
Span::Custom { name }

beacon/src/span.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ pub enum Span {
3333
},
3434
Present {
3535
window: window::Id,
36+
layers: usize,
3637
},
3738
Custom {
3839
name: String,
@@ -70,7 +71,7 @@ impl Span {
7071
Span::Draw { window } => Stage::Draw(*window),
7172
Span::Prepare { primitive, .. } => Stage::Prepare(*primitive),
7273
Span::Render { primitive, .. } => Stage::Render(*primitive),
73-
Span::Present { window } => Stage::Present(*window),
74+
Span::Present { window, .. } => Stage::Present(*window),
7475
Span::Custom { name, .. } => Stage::Custom(name.clone()),
7576
}
7677
}

benches/wgpu.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,9 +179,10 @@ fn scene<'a, Message: 'a>(n: usize) -> Element<'a, Message, Theme, Renderer> {
179179
size: Pixels::from(16),
180180
line_height: text::LineHeight::default(),
181181
font: Font::DEFAULT,
182-
align_x: alignment::Horizontal::Left,
182+
align_x: text::Alignment::Left,
183183
align_y: alignment::Vertical::Top,
184184
shaping: text::Shaping::Basic,
185+
max_width: f32::INFINITY,
185186
});
186187
}
187188
})]

core/src/element.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ where
366366
fn overlay<'b>(
367367
&'b mut self,
368368
tree: &'b mut Tree,
369-
layout: Layout<'_>,
369+
layout: Layout<'b>,
370370
renderer: &Renderer,
371371
viewport: &Rectangle,
372372
translation: Vector,
@@ -518,7 +518,7 @@ where
518518
fn overlay<'b>(
519519
&'b mut self,
520520
state: &'b mut Tree,
521-
layout: Layout<'_>,
521+
layout: Layout<'b>,
522522
renderer: &Renderer,
523523
viewport: &Rectangle,
524524
translation: Vector,

core/src/overlay.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ where
120120
pub fn from_children<'a, Message, Theme, Renderer>(
121121
children: &'a mut [crate::Element<'_, Message, Theme, Renderer>],
122122
tree: &'a mut Tree,
123-
layout: Layout<'_>,
123+
layout: Layout<'a>,
124124
renderer: &Renderer,
125125
viewport: &Rectangle,
126126
translation: Vector,

core/src/transformation.rs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,27 @@ impl Transformation {
1313

1414
/// Creates an orthographic projection.
1515
#[rustfmt::skip]
16-
pub fn orthographic(width: u32, height: u32) -> Transformation {
17-
Transformation(Mat4::orthographic_rh_gl(
16+
pub fn orthographic(width: u32, height: u32) -> Self{
17+
Self(Mat4::orthographic_rh_gl(
1818
0.0, width as f32,
1919
height as f32, 0.0,
2020
-1.0, 1.0
2121
))
2222
}
2323

2424
/// Creates a translate transformation.
25-
pub fn translate(x: f32, y: f32) -> Transformation {
26-
Transformation(Mat4::from_translation(Vec3::new(x, y, 0.0)))
25+
pub fn translate(x: f32, y: f32) -> Self {
26+
Self(Mat4::from_translation(Vec3::new(x, y, 0.0)))
2727
}
2828

2929
/// Creates a uniform scaling transformation.
30-
pub fn scale(scaling: f32) -> Transformation {
31-
Transformation(Mat4::from_scale(Vec3::new(scaling, scaling, 1.0)))
30+
pub fn scale(scaling: f32) -> Self {
31+
Self(Mat4::from_scale(Vec3::new(scaling, scaling, 1.0)))
32+
}
33+
34+
/// Returns the inverse of the [`Transformation`].
35+
pub fn inverse(self) -> Self {
36+
Self(self.0.inverse())
3237
}
3338

3439
/// Returns the scale factor of the [`Transformation`].
@@ -52,7 +57,7 @@ impl Mul for Transformation {
5257
type Output = Self;
5358

5459
fn mul(self, rhs: Self) -> Self {
55-
Transformation(self.0 * rhs.0)
60+
Self(self.0 * rhs.0)
5661
}
5762
}
5863

core/src/widget.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ where
144144
fn overlay<'a>(
145145
&'a mut self,
146146
_state: &'a mut Tree,
147-
_layout: Layout<'_>,
147+
_layout: Layout<'a>,
148148
_renderer: &Renderer,
149149
_viewport: &Rectangle,
150150
_translation: Vector,

debug/src/lib.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,15 @@ pub fn theme_changed(f: impl FnOnce() -> Option<theme::Palette>) {
4343
}
4444

4545
pub fn tasks_spawned(amount: usize) {
46-
internal::tasks_spawned(amount)
46+
internal::tasks_spawned(amount);
4747
}
4848

4949
pub fn subscriptions_tracked(amount: usize) {
50-
internal::subscriptions_tracked(amount)
50+
internal::subscriptions_tracked(amount);
51+
}
52+
53+
pub fn layers_rendered(amount: impl FnOnce() -> usize) {
54+
internal::layers_rendered(amount);
5155
}
5256

5357
pub fn boot() -> Span {
@@ -157,6 +161,10 @@ mod internal {
157161
log(client::Event::SubscriptionsTracked(amount));
158162
}
159163

164+
pub fn layers_rendered(amount: impl FnOnce() -> usize) {
165+
log(client::Event::LayersRendered(amount()));
166+
}
167+
160168
pub fn boot() -> Span {
161169
span(span::Stage::Boot)
162170
}
@@ -300,8 +308,6 @@ mod internal {
300308
use crate::futures::Subscription;
301309
use crate::{Command, Primitive};
302310

303-
use std::io;
304-
305311
pub fn enable() {}
306312
pub fn disable() {}
307313

@@ -317,6 +323,8 @@ mod internal {
317323

318324
pub fn subscriptions_tracked(_amount: usize) {}
319325

326+
pub fn layers_rendered(_amount: impl FnOnce() -> usize) {}
327+
320328
pub fn boot() -> Span {
321329
Span
322330
}

devtools/src/comet.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::runtime::Task;
44
use std::process;
55

66
pub const COMPATIBLE_REVISION: &str =
7-
"69dd2283886dccdaa1ee6e1c274af62f7250bc38";
7+
"63f30c779a72315598255703f35af44f8ec3e583";
88

99
pub fn launch() -> Task<launch::Result> {
1010
executor::try_spawn_blocking(|mut sender| {

0 commit comments

Comments
 (0)