core: Use `swf::Matrix::translate` in more places
Replace direct instatiations of `swf::Matrix` where only `tx` and `ty` are specified, and other fields are default. This results in a slightly more shorter, readable code.
This commit is contained in:
parent
60a1dbfb07
commit
cec9850a33
|
@ -1621,11 +1621,7 @@ impl<'gc> TDisplayObject<'gc> for EditText<'gc> {
|
||||||
|
|
||||||
let edit_text = self.0.read();
|
let edit_text = self.0.read();
|
||||||
context.transform_stack.push(&Transform {
|
context.transform_stack.push(&Transform {
|
||||||
matrix: Matrix {
|
matrix: Matrix::translate(edit_text.bounds.x_min, edit_text.bounds.y_min),
|
||||||
tx: edit_text.bounds.x_min,
|
|
||||||
ty: edit_text.bounds.y_min,
|
|
||||||
..Default::default()
|
|
||||||
},
|
|
||||||
..Default::default()
|
..Default::default()
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1659,12 +1655,10 @@ impl<'gc> TDisplayObject<'gc> for EditText<'gc> {
|
||||||
// TODO: Where does this come from? How is this different than INTERNAL_PADDING? Does this apply to y as well?
|
// TODO: Where does this come from? How is this different than INTERNAL_PADDING? Does this apply to y as well?
|
||||||
// If this is actually right, offset the border in `redraw_border` instead of doing an extra push.
|
// If this is actually right, offset the border in `redraw_border` instead of doing an extra push.
|
||||||
context.transform_stack.push(&Transform {
|
context.transform_stack.push(&Transform {
|
||||||
matrix: Matrix {
|
matrix: Matrix::translate(
|
||||||
tx: Twips::from_pixels(Self::INTERNAL_PADDING)
|
Twips::from_pixels(Self::INTERNAL_PADDING) - Twips::from_pixels(edit_text.hscroll),
|
||||||
- Twips::from_pixels(edit_text.hscroll),
|
Twips::from_pixels(Self::INTERNAL_PADDING) - scroll_offset,
|
||||||
ty: Twips::from_pixels(Self::INTERNAL_PADDING) - scroll_offset,
|
),
|
||||||
..Default::default()
|
|
||||||
},
|
|
||||||
..Default::default()
|
..Default::default()
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -15,14 +15,7 @@ pub struct Transform {
|
||||||
impl From<Position<Twips>> for Transform {
|
impl From<Position<Twips>> for Transform {
|
||||||
fn from(pos: Position<Twips>) -> Self {
|
fn from(pos: Position<Twips>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
matrix: Matrix {
|
matrix: Matrix::translate(pos.x(), pos.y()),
|
||||||
a: 1.0,
|
|
||||||
b: 0.0,
|
|
||||||
c: 0.0,
|
|
||||||
d: 1.0,
|
|
||||||
tx: pos.x(),
|
|
||||||
ty: pos.y(),
|
|
||||||
},
|
|
||||||
color_transform: Default::default(),
|
color_transform: Default::default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue