Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
53369b10
Commit
53369b10
authored
Jul 31, 2015
by
Adam Barth
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #421 from abarth/rounded_border
Support borders with borderRadius
parents
ea541955
14c0b187
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
46 additions
and
9 deletions
+46
-9
block_viewport.dart
packages/flutter/example/widgets/block_viewport.dart
+1
-1
sector.dart
packages/flutter/example/widgets/sector.dart
+1
-1
box_painter.dart
packages/flutter/lib/painting/box_painter.dart
+44
-7
No files found.
packages/flutter/example/widgets/block_viewport.dart
View file @
53369b10
...
@@ -91,7 +91,7 @@ class BlockViewportApp extends App {
...
@@ -91,7 +91,7 @@ class BlockViewportApp extends App {
child:
new
Container
(
child:
new
Container
(
margin:
new
EdgeDims
.
all
(
8.0
),
margin:
new
EdgeDims
.
all
(
8.0
),
decoration:
new
BoxDecoration
(
decoration:
new
BoxDecoration
(
border:
new
Border
.
all
(
new
BorderSide
(
color:
new
Color
(
0xFF000000
)
))
border:
new
Border
.
all
(
color:
new
Color
(
0xFF000000
))
),
),
padding:
new
EdgeDims
.
all
(
16.0
),
padding:
new
EdgeDims
.
all
(
16.0
),
child:
new
BlockViewport
(
child:
new
BlockViewport
(
...
...
packages/flutter/example/widgets/sector.dart
View file @
53369b10
...
@@ -114,7 +114,7 @@ class SectorApp extends App {
...
@@ -114,7 +114,7 @@ class SectorApp extends App {
child:
new
Container
(
child:
new
Container
(
margin:
new
EdgeDims
.
all
(
8.0
),
margin:
new
EdgeDims
.
all
(
8.0
),
decoration:
new
BoxDecoration
(
decoration:
new
BoxDecoration
(
border:
new
Border
.
all
(
new
BorderSide
(
color:
new
Color
(
0xFF000000
)
))
border:
new
Border
.
all
(
color:
new
Color
(
0xFF000000
))
),
),
padding:
new
EdgeDims
.
all
(
8.0
),
padding:
new
EdgeDims
.
all
(
8.0
),
child:
new
WidgetToRenderBoxAdapter
(
sectors
)
child:
new
WidgetToRenderBoxAdapter
(
sectors
)
...
...
packages/flutter/lib/painting/box_painter.dart
View file @
53369b10
...
@@ -37,11 +37,13 @@ class Border {
...
@@ -37,11 +37,13 @@ class Border {
this
.
left
:
BorderSide
.
none
this
.
left
:
BorderSide
.
none
});
});
const
Border
.
all
(
BorderSide
side
)
:
factory
Border
.
all
({
top
=
side
,
Color
color:
const
Color
(
0xFF000000
),
right
=
side
,
double
width:
1.0
bottom
=
side
,
})
{
left
=
side
;
BorderSide
side
=
new
BorderSide
(
color:
color
,
width:
width
);
return
new
Border
(
top:
side
,
right:
side
,
bottom:
side
,
left:
side
);
}
final
BorderSide
top
;
final
BorderSide
top
;
final
BorderSide
right
;
final
BorderSide
right
;
...
@@ -323,6 +325,25 @@ class BoxPainter {
...
@@ -323,6 +325,25 @@ class BoxPainter {
return
_cachedBackgroundPaint
;
return
_cachedBackgroundPaint
;
}
}
bool
get
_hasUniformBorder
{
Color
color
=
_decoration
.
border
.
top
.
color
;
bool
hasUniformColor
=
_decoration
.
border
.
right
.
color
==
color
&&
_decoration
.
border
.
bottom
.
color
==
color
&&
_decoration
.
border
.
left
.
color
==
color
;
if
(!
hasUniformColor
)
return
false
;
double
width
=
_decoration
.
border
.
top
.
width
;
bool
hasUniformWidth
=
_decoration
.
border
.
right
.
width
==
width
&&
_decoration
.
border
.
bottom
.
width
==
width
&&
_decoration
.
border
.
left
.
width
==
width
;
return
hasUniformWidth
;
}
void
_paintBackgroundColor
(
sky
.
Canvas
canvas
,
Rect
rect
)
{
void
_paintBackgroundColor
(
sky
.
Canvas
canvas
,
Rect
rect
)
{
if
(
_decoration
.
backgroundColor
!=
null
||
_decoration
.
boxShadow
!=
null
||
if
(
_decoration
.
backgroundColor
!=
null
||
_decoration
.
boxShadow
!=
null
||
_decoration
.
gradient
!=
null
)
{
_decoration
.
gradient
!=
null
)
{
...
@@ -397,8 +418,13 @@ class BoxPainter {
...
@@ -397,8 +418,13 @@ class BoxPainter {
if
(
_decoration
.
border
==
null
)
if
(
_decoration
.
border
==
null
)
return
;
return
;
assert
(
_decoration
.
borderRadius
==
null
);
// TODO(abarth): Implement borders with border radius.
if
(
_hasUniformBorder
&&
_decoration
.
borderRadius
!=
null
)
{
assert
(
_decoration
.
shape
==
Shape
.
rectangle
);
// TODO(ianh): Implement borders on circles.
_paintBorderWithRadius
(
canvas
,
rect
);
return
;
}
assert
(
_decoration
.
borderRadius
==
null
);
// TODO(abarth): Support non-uniform rounded borders.
assert
(
_decoration
.
shape
==
Shape
.
rectangle
);
// TODO(ianh): Support borders on circles.
assert
(
_decoration
.
border
.
top
!=
null
);
assert
(
_decoration
.
border
.
top
!=
null
);
assert
(
_decoration
.
border
.
right
!=
null
);
assert
(
_decoration
.
border
.
right
!=
null
);
...
@@ -445,6 +471,17 @@ class BoxPainter {
...
@@ -445,6 +471,17 @@ class BoxPainter {
canvas
.
drawPath
(
path
,
paint
);
canvas
.
drawPath
(
path
,
paint
);
}
}
void
_paintBorderWithRadius
(
sky
.
Canvas
canvas
,
Rect
rect
)
{
assert
(
_hasUniformBorder
);
Color
color
=
_decoration
.
border
.
top
.
color
;
double
width
=
_decoration
.
border
.
top
.
width
;
double
radius
=
_decoration
.
borderRadius
;
sky
.
RRect
outer
=
new
sky
.
RRect
()..
setRectXY
(
rect
,
radius
,
radius
);
sky
.
RRect
inner
=
new
sky
.
RRect
()..
setRectXY
(
rect
.
deflate
(
width
),
radius
-
width
,
radius
-
width
);
canvas
.
drawDRRect
(
outer
,
inner
,
new
Paint
()..
color
=
color
);
}
void
paint
(
sky
.
Canvas
canvas
,
Rect
rect
)
{
void
paint
(
sky
.
Canvas
canvas
,
Rect
rect
)
{
_paintBackgroundColor
(
canvas
,
rect
);
_paintBackgroundColor
(
canvas
,
rect
);
_paintBackgroundImage
(
canvas
,
rect
);
_paintBackgroundImage
(
canvas
,
rect
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment