Toggle navigation
Toggle navigation
This project
Loading...
Sign in
flutter_package
/
dart_pdf
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
David PHAM-VAN
2019-07-20 12:51:28 -0400
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
11d8dcc17556b0c6732b7a6076d3d7a182e029f9
11d8dcc1
1 parent
beaa8599
Add Transform.rotateBox constructor
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
72 additions
and
0 deletions
pdf/CHANGELOG.md
pdf/lib/widgets/basic.dart
pdf/test/widget_basic_test.dart
pdf/CHANGELOG.md
View file @
11d8dcc
...
...
@@ -4,6 +4,7 @@
*
Add better debugPaint on Align Widget
*
Fix Transform placement when Alignment and Origin are Null
*
Add Transform.rotateBox constructor
## 1.3.15
...
...
pdf/lib/widgets/basic.dart
View file @
11d8dcc
...
...
@@ -128,6 +128,7 @@ class Transform extends SingleChildWidget {
this
.
alignment
,
Widget
child
,
})
:
assert
(
transform
!=
null
),
_relayout
=
false
,
super
(
child:
child
);
/// Creates a widget that transforms its child using a rotation around the
...
...
@@ -138,6 +139,18 @@ class Transform extends SingleChildWidget {
this
.
alignment
=
Alignment
.
center
,
Widget
child
,
})
:
transform
=
Matrix4
.
rotationZ
(
angle
),
_relayout
=
false
,
super
(
child:
child
);
/// Creates a widget that transforms its child using a rotation around the
/// center and relayout the bounding box.
Transform
.
rotateBox
({
@required
double
angle
,
Widget
child
,
})
:
transform
=
Matrix4
.
rotationZ
(
angle
),
_relayout
=
true
,
alignment
=
null
,
origin
=
null
,
super
(
child:
child
);
/// Creates a widget that transforms its child using a translation.
...
...
@@ -147,6 +160,7 @@ class Transform extends SingleChildWidget {
})
:
transform
=
Matrix4
.
translationValues
(
offset
.
x
,
offset
.
y
,
0
),
origin
=
null
,
alignment
=
null
,
_relayout
=
false
,
super
(
child:
child
);
/// Creates a widget that scales its child uniformly.
...
...
@@ -156,6 +170,7 @@ class Transform extends SingleChildWidget {
this
.
alignment
=
Alignment
.
center
,
Widget
child
,
})
:
transform
=
Matrix4
.
diagonal3Values
(
scale
,
scale
,
1
),
_relayout
=
false
,
super
(
child:
child
);
/// The matrix to transform the child by during painting.
...
...
@@ -167,6 +182,8 @@ class Transform extends SingleChildWidget {
/// The alignment of the origin, relative to the size of the box.
final
Alignment
alignment
;
final
bool
_relayout
;
Matrix4
get
_effectiveTransform
{
final
Matrix4
result
=
Matrix4
.
identity
();
if
(
origin
!=
null
)
{
...
...
@@ -189,6 +206,50 @@ class Transform extends SingleChildWidget {
}
@override
void
layout
(
Context
context
,
BoxConstraints
constraints
,
{
bool
parentUsesSize
=
false
})
{
if
(!
_relayout
)
{
return
super
.
layout
(
context
,
constraints
,
parentUsesSize:
parentUsesSize
);
}
if
(
child
!=
null
)
{
child
.
layout
(
context
,
constraints
,
parentUsesSize:
parentUsesSize
);
assert
(
child
.
box
!=
null
);
box
=
child
.
box
;
final
Matrix4
mat
=
transform
;
final
List
<
double
>
values
=
mat
.
applyToVector3Array
(<
double
>[
child
.
box
.
left
,
child
.
box
.
top
,
0
,
child
.
box
.
right
,
child
.
box
.
top
,
0
,
child
.
box
.
right
,
child
.
box
.
bottom
,
0
,
child
.
box
.
left
,
child
.
box
.
bottom
,
0
,
]);
box
=
PdfRect
.
fromLTRB
(
math
.
min
(
math
.
min
(
math
.
min
(
values
[
0
],
values
[
3
]),
values
[
6
]),
values
[
9
]),
math
.
min
(
math
.
min
(
math
.
min
(
values
[
1
],
values
[
4
]),
values
[
7
]),
values
[
10
]),
math
.
max
(
math
.
max
(
math
.
max
(
values
[
0
],
values
[
3
]),
values
[
6
]),
values
[
9
]),
math
.
max
(
math
.
max
(
math
.
max
(
values
[
1
],
values
[
4
]),
values
[
7
]),
values
[
10
]),
);
transform
.
leftTranslate
(-
box
.
x
,
-
box
.
y
);
}
else
{
box
=
PdfRect
.
fromPoints
(
PdfPoint
.
zero
,
constraints
.
smallest
);
}
}
@override
void
paint
(
Context
context
)
{
super
.
paint
(
context
);
...
...
pdf/test/widget_basic_test.dart
View file @
11d8dcc
...
...
@@ -191,6 +191,16 @@ void main() {
)));
});
test
(
'Basic Widgets Transform rotateBox'
,
()
{
pdf
.
addPage
(
Page
(
build:
(
Context
context
)
=>
Center
(
child:
Transform
.
rotateBox
(
angle:
3.1416
/
2
,
child:
Text
(
'Hello'
),
),
)));
});
tearDownAll
(()
{
final
File
file
=
File
(
'widgets-basic.pdf'
);
file
.
writeAsBytesSync
(
pdf
.
save
());
...
...
Please
register
or
login
to post a comment