Skip to content

Commit f3d0ccf

Browse files
Pure implementation update
1 parent df8aa54 commit f3d0ccf

Some content is hidden

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

71 files changed

+744
-1910
lines changed

Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ name = "animate"
2222
features = ["dox"]
2323

2424
[features]
25+
pure = []
2526
dox = ["ffi/dox", "glib/dox", "glib-sys/dox", "gobject-sys/dox", "ux-dx/dox"]
2627

2728
[dependencies]
@@ -37,9 +38,10 @@ tiny-skia = "0.5"
3738
rand = "0.8"
3839
x11 = "2.18.2"
3940
once_cell = "1.7.2"
41+
fontdue = "0.5.0"
4042

4143
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
42-
ux-dx = "0.1"
44+
ux-dx = { version = "0.1" }
4345
libc = "0.2"
4446
bitflags = "1.0"
4547
glib-sys = "0.10"

src/prelude.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,3 @@ pub use crate::AdvancedShapesExt;
1515

1616
#[cfg(not(target_arch = "wasm32"))]
1717
pub use crate::legacy::traits::*;
18-
19-
pub trait Object: std::fmt::Debug + Clone + 'static {}
20-
pub trait Is<T: Object>: AsRef<T> + 'static {}

src/pure/action.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
use crate::prelude::*;
2-
// use super::ActorMeta;
2+
use super::ActorMeta;
33
use std::fmt;
44

5-
// * ClutterAction:
5+
// * Action:
66
// *
7-
// * The #ClutterAction structure contains only private data and
7+
// * The #Action structure contains only private data and
88
// * should be accessed using the provided API.
99
// *
1010

1111
// It should be Trait
12-
// extends ActorMeta
1312
#[derive(Debug, Clone)]
1413
pub struct Action {
15-
// parent_instance: ClutterActorMeta,
14+
inner: ActorMeta,
1615
}
1716

1817
impl Action {
@@ -28,6 +27,12 @@ impl AsRef<Action> for Action {
2827
}
2928
}
3029

30+
impl AsRef<ActorMeta> for Action {
31+
fn as_ref(&self) -> &ActorMeta {
32+
&self.inner
33+
}
34+
}
35+
3136
impl fmt::Display for Action {
3237
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
3338
write!(f, "Action")

src/pure/actor.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
use super::{
22
Action, ActorAlign, ActorBox, ActorFlags, AllocationFlags, AnimationMode, ButtonEvent,
3-
Constraint, Content, ContentGravity, ContentRepeat, CrossingEvent, Effect, Event, InternalRect,
3+
Constraint, Content, ContentGravity, ContentRepeat, CrossingEvent, Effect, Event,
44
KeyEvent, LayoutManager, Margin, Matrix, MotionEvent, OffscreenRedirect, Orientation,
55
PaintVolume, RequestMode, RotateAxis, ScalingFilter, ScrollEvent, Stage, TextDirection,
66
Transition, Vertex,
77
};
88
use crate::prelude::*;
9-
use crate::Color;
9+
use crate::{Color, Rect};
1010
use glib::signal::SignalHandlerId;
1111
use std::fmt;
1212

@@ -2397,7 +2397,7 @@ pub trait ActorExt: 'static {
23972397
///
23982398
/// Setting this property will change the `Actor:has-clip`
23992399
/// property as a side effect.
2400-
fn get_property_clip_rect(&self) -> Option<InternalRect>;
2400+
fn get_property_clip_rect(&self) -> Option<Rect<f32>>;
24012401

24022402
/// The visible region of the actor, in actor-relative coordinates,
24032403
/// expressed as a `Rect`.
@@ -2406,7 +2406,7 @@ pub trait ActorExt: 'static {
24062406
///
24072407
/// Setting this property will change the `Actor:has-clip`
24082408
/// property as a side effect.
2409-
fn set_property_clip_rect(&self, clip_rect: Option<&InternalRect>);
2409+
fn set_property_clip_rect(&self, clip_rect: Option<&Rect<f32>>);
24102410

24112411
/// Adds a `Constraint` to the actor
24122412
fn set_property_constraints<P: Is<Constraint>>(&self, constraints: Option<&P>);
@@ -3366,7 +3366,7 @@ impl<O: Is<Actor>> ActorExt for O {
33663366
// // >(
33673367
// // item: *mut gobject_sys::GObject,
33683368
// // user_data: glib_sys::gpointer,
3369-
// // ) -> *mut ffi::ClutterActor {
3369+
// // ) -> *mut ffi::Actor {
33703370
// // let item = from_glib_borrow(item);
33713371
// // let callback: &Q = &*(user_data as *mut _);
33723372
// // let res = (*callback)(&item);
@@ -3522,7 +3522,7 @@ impl<O: Is<Actor>> ActorExt for O {
35223522

35233523
fn get_background_color(&self) -> Color {
35243524
// unsafe {
3525-
// let mut color = InternalColor::uninitialized();
3525+
// let mut color = Color::uninitialized();
35263526
// ffi::clutter_actor_get_background_color(
35273527
// self.as_ref().to_glib_none().0,
35283528
// color.to_glib_none_mut().0,
@@ -4565,7 +4565,7 @@ impl<O: Is<Actor>> ActorExt for O {
45654565
// blue,
45664566
// alpha,
45674567
// } = value.into();
4568-
// Some(InternalColor::new(red, green, blue, alpha))
4568+
// Some(Color::new(red, green, blue, alpha))
45694569
// }
45704570
// None => None,
45714571
// };
@@ -5056,9 +5056,9 @@ impl<O: Is<Actor>> ActorExt for O {
50565056
unimplemented!()
50575057
}
50585058

5059-
fn get_property_clip_rect(&self) -> Option<InternalRect> {
5059+
fn get_property_clip_rect(&self) -> Option<Rect<f32>> {
50605060
// unsafe {
5061-
// let mut value = Value::from_type(<InternalRect as StaticType>::static_type());
5061+
// let mut value = Value::from_type(<Rect as StaticType>::static_type());
50625062
// gobject_sys::g_object_get_property(
50635063
// self.to_glib_none().0 as *mut gobject_sys::GObject,
50645064
// b"clip-rect\0".as_ptr() as *const _,
@@ -5071,7 +5071,7 @@ impl<O: Is<Actor>> ActorExt for O {
50715071
unimplemented!()
50725072
}
50735073

5074-
fn set_property_clip_rect(&self, clip_rect: Option<&InternalRect>) {
5074+
fn set_property_clip_rect(&self, clip_rect: Option<&Rect<f32>>) {
50755075
// unsafe {
50765076
// gobject_sys::g_object_set_property(
50775077
// self.to_glib_none().0 as *mut gobject_sys::GObject,

src/pure/actor_box.rs

Lines changed: 57 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use super::Vertex;
22

3-
// * ClutterActorBox:
3+
// * ActorBox:
44
// * @x1: X coordinate of the top left corner
55
// * @y1: Y coordinate of the top left corner
66
// * @x2: X coordinate of the bottom right corner
@@ -82,66 +82,65 @@ impl ActorBox {
8282
}
8383

8484
pub fn from_vertices(&mut self, verts: &[Vertex; 4]) {
85-
// // 4-way min/max
86-
// let mut x1 = verts[0].x;
87-
// let mut y1 = verts[0].y;
85+
// 4-way min/max
86+
let mut x1 = verts[0].x;
87+
let mut y1 = verts[0].y;
8888

89-
// if verts[1].x < x1 {
90-
// x1 = verts[1].x;
91-
// }
89+
if verts[1].x < x1 {
90+
x1 = verts[1].x;
91+
}
9292

93-
// if verts[2].x < x1 {
94-
// x1 = verts[2].x;
95-
// }
93+
if verts[2].x < x1 {
94+
x1 = verts[2].x;
95+
}
9696

97-
// if verts[3].x < x1 {
98-
// x1 = verts[3].x;
99-
// }
97+
if verts[3].x < x1 {
98+
x1 = verts[3].x;
99+
}
100100

101-
// if verts[1].y < y1 {
102-
// y1 = verts[1].y;
103-
// }
101+
if verts[1].y < y1 {
102+
y1 = verts[1].y;
103+
}
104104

105-
// if verts[2].y < y1 {
106-
// y1 = verts[2].y;
107-
// }
105+
if verts[2].y < y1 {
106+
y1 = verts[2].y;
107+
}
108108

109-
// if verts[3].y < y1 {
110-
// y1 = verts[3].y;
111-
// }
109+
if verts[3].y < y1 {
110+
y1 = verts[3].y;
111+
}
112112

113-
// let mut x2 = verts[0].x;
114-
// let mut y2 = verts[0].y;
113+
let mut x2 = verts[0].x;
114+
let mut y2 = verts[0].y;
115115

116-
// if verts[1].x > x2 {
117-
// x2 = verts[1].x;
118-
// }
116+
if verts[1].x > x2 {
117+
x2 = verts[1].x;
118+
}
119119

120-
// if verts[2].x > x2 {
121-
// x2 = verts[2].x;
122-
// }
120+
if verts[2].x > x2 {
121+
x2 = verts[2].x;
122+
}
123123

124-
// if verts[3].x > x2 {
125-
// x2 = verts[3].x;
126-
// }
124+
if verts[3].x > x2 {
125+
x2 = verts[3].x;
126+
}
127127

128-
// if verts[1].y > y2 {
129-
// y2 = verts[1].y;
130-
// }
128+
if verts[1].y > y2 {
129+
y2 = verts[1].y;
130+
}
131131

132-
// if verts[2].y > y2 {
133-
// y2 = verts[2].y;
134-
// }
132+
if verts[2].y > y2 {
133+
y2 = verts[2].y;
134+
}
135135

136-
// if verts[3].y > y2 {
137-
// y2 = verts[3].y;
138-
// }
136+
if verts[3].y > y2 {
137+
y2 = verts[3].y;
138+
}
139139

140-
// self.x1 = x1;
141-
// self.x2 = x2;
142-
// self.y1 = y1;
143-
// self.y2 = y2;
144-
unimplemented!()
140+
self.x1 = x1;
141+
self.x2 = x2;
142+
self.y1 = y1;
143+
self.y2 = y2;
145144
}
146145

147146
/// Retrieves the area of `self`
@@ -234,19 +233,18 @@ impl ActorBox {
234233
/// the interpolation progress
235234
/// ## `result`
236235
/// return location for the interpolation
237-
pub fn interpolate(&self, dest: &ActorBox, progress: f64) -> Self {
238-
// let x1 = self.x1 + (dest.x1 - self.x1) * progress;
239-
// let y1 = self.y1 + (dest.y1 - self.y1) * progress;
240-
// let x2 = self.x2 + (dest.x2 - self.x2) * progress;
241-
// let y2 = self.y2 + (dest.y2 - self.y2) * progress;
236+
pub fn interpolate(&self, dest: &ActorBox, progress: f32) -> Self {
237+
let x1 = self.x1 + (dest.x1 - self.x1) * progress;
238+
let y1 = self.y1 + (dest.y1 - self.y1) * progress;
239+
let x2 = self.x2 + (dest.x2 - self.x2) * progress;
240+
let y2 = self.y2 + (dest.y2 - self.y2) * progress;
242241

243-
// Self {
244-
// x1,
245-
// y1,
246-
// x2,
247-
// y2,
248-
// }
249-
unimplemented!()
242+
Self {
243+
x1,
244+
y1,
245+
x2,
246+
y2,
247+
}
250248
}
251249

252250
/// Changes the origin of `self`, maintaining the size of the `ActorBox`.

src/pure/actor_canvas.rs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,37 +4,36 @@ use glib::signal::SignalHandlerId;
44
use std::fmt;
55
// use cairo::Context;
66

7-
// * ClutterCanvas:
7+
// * Canvas:
88
// *
9-
// * The #ClutterCanvas structure contains
9+
// * The #Canvas structure contains
1010
// * private data and should only be accessed using the provided
1111
// * API.
12-
// * @Title: ClutterCanvas
12+
// * @Title: Canvas
1313
// * @Short_Description: Content for 2D painting
14-
// * @See_Also: #ClutterContent
14+
// * @See_Also: #Content
1515
// *
16-
// * The #ClutterCanvas class is a #ClutterContent implementation that allows
16+
// * The #Canvas class is a #Content implementation that allows
1717
// * drawing using the Cairo API on a 2D surface.
1818
// *
19-
// * In order to draw on a #ClutterCanvas, you should connect a handler to the
20-
// * #ClutterCanvas::draw signal; the signal will receive a #cairo_t context
21-
// * that can be used to draw. #ClutterCanvas will emit the #ClutterCanvas::draw
19+
// * In order to draw on a #Canvas, you should connect a handler to the
20+
// * #Canvas::draw signal; the signal will receive a #cairo_t context
21+
// * that can be used to draw. #Canvas will emit the #Canvas::draw
2222
// * signal when invalidated using clutter_content_invalidate().
2323
// *
2424
// * See [canvas.c](https://git.gnome.org/browse/clutter/tree/examples/canvas.c?h=clutter-1.18)
25-
// * for an example of how to use #ClutterCanvas.
25+
// * for an example of how to use #Canvas.
2626
// @implements Content
27-
#[derive(Debug, Clone)]
2827
pub struct ActorCanvas {
2928
cr: cairo::Context,
3029

3130
width: u32,
3231
height: u32,
3332

34-
texture: dx::Texture,
33+
texture: dx::pure::Texture,
3534
dirty: bool,
3635

37-
buffer: dx::Bitmap,
36+
buffer: dx::pure::Bitmap,
3837

3938
scale_factor: u32,
4039
scale_factor_set: bool,

src/pure/align_constraint.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ use super::{Actor, AlignAxis};
22
use crate::prelude::*;
33
use std::fmt;
44

5-
// * ClutterAlignConstraint:
5+
// * AlignConstraint:
66
// *
7-
// * #ClutterAlignConstraint is an opaque structure
7+
// * #AlignConstraint is an opaque structure
88
// * whose members cannot be directly accesses
99
// * @Short_Description: A constraint aligning the position of an actor
1010
// *
11-
// * #ClutterAlignConstraint is a #ClutterConstraint that aligns the position
12-
// * of the #ClutterActor to which it is applied to the size of another
13-
// * #ClutterActor using an alignment factor
11+
// * #AlignConstraint is a #Constraint that aligns the position
12+
// * of the #Actor to which it is applied to the size of another
13+
// * #Actor using an alignment factor
1414
// @extends Constraint, ActorMeta,
1515
#[derive(Debug, Clone)]
1616
pub struct AlignConstraint {

0 commit comments

Comments
 (0)