Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
godot
Project
Overview
Details
Activity
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
community
godot
Commits
00b86b29
Commit
00b86b29
authored
Oct 10, 2019
by
qarmin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Validate array indexes in StyleBox
parent
02d75f99
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
0 deletions
+21
-0
style_box.cpp
scene/resources/style_box.cpp
+21
-0
No files found.
scene/resources/style_box.cpp
View file @
00b86b29
...
...
@@ -40,16 +40,22 @@ bool StyleBox::test_mask(const Point2 &p_point, const Rect2 &p_rect) const {
void
StyleBox
::
set_default_margin
(
Margin
p_margin
,
float
p_value
)
{
ERR_FAIL_INDEX
((
int
)
p_margin
,
4
);
margin
[
p_margin
]
=
p_value
;
emit_changed
();
}
float
StyleBox
::
get_default_margin
(
Margin
p_margin
)
const
{
ERR_FAIL_INDEX_V
((
int
)
p_margin
,
4
,
0.0
);
return
margin
[
p_margin
];
}
float
StyleBox
::
get_margin
(
Margin
p_margin
)
const
{
ERR_FAIL_INDEX_V
((
int
)
p_margin
,
4
,
0.0
);
if
(
margin
[
p_margin
]
<
0
)
return
get_style_margin
(
p_margin
);
else
...
...
@@ -157,11 +163,15 @@ void StyleBoxTexture::set_margin_size(Margin p_margin, float p_size) {
}
float
StyleBoxTexture
::
get_margin_size
(
Margin
p_margin
)
const
{
ERR_FAIL_INDEX_V
((
int
)
p_margin
,
4
,
0.0
);
return
margin
[
p_margin
];
}
float
StyleBoxTexture
::
get_style_margin
(
Margin
p_margin
)
const
{
ERR_FAIL_INDEX_V
((
int
)
p_margin
,
4
,
0.0
);
return
margin
[
p_margin
];
}
...
...
@@ -250,6 +260,7 @@ Rect2 StyleBoxTexture::get_region_rect() const {
void
StyleBoxTexture
::
set_h_axis_stretch_mode
(
AxisStretchMode
p_mode
)
{
ERR_FAIL_INDEX
((
int
)
p_mode
,
3
);
axis_h
=
p_mode
;
emit_changed
();
}
...
...
@@ -261,6 +272,7 @@ StyleBoxTexture::AxisStretchMode StyleBoxTexture::get_h_axis_stretch_mode() cons
void
StyleBoxTexture
::
set_v_axis_stretch_mode
(
AxisStretchMode
p_mode
)
{
ERR_FAIL_INDEX
((
int
)
p_mode
,
3
);
axis_v
=
p_mode
;
emit_changed
();
}
...
...
@@ -391,11 +403,13 @@ int StyleBoxFlat::get_border_width_min() const {
}
void
StyleBoxFlat
::
set_border_width
(
Margin
p_margin
,
int
p_width
)
{
ERR_FAIL_INDEX
((
int
)
p_margin
,
4
);
border_width
[
p_margin
]
=
p_width
;
emit_changed
();
}
int
StyleBoxFlat
::
get_border_width
(
Margin
p_margin
)
const
{
ERR_FAIL_INDEX_V
((
int
)
p_margin
,
4
,
0
);
return
border_width
[
p_margin
];
}
...
...
@@ -437,15 +451,19 @@ int StyleBoxFlat::get_corner_radius_min() const {
void
StyleBoxFlat
::
set_corner_radius
(
const
Corner
p_corner
,
const
int
radius
)
{
ERR_FAIL_INDEX
((
int
)
p_corner
,
4
);
corner_radius
[
p_corner
]
=
radius
;
emit_changed
();
}
int
StyleBoxFlat
::
get_corner_radius
(
const
Corner
p_corner
)
const
{
ERR_FAIL_INDEX_V
((
int
)
p_corner
,
4
,
0
);
return
corner_radius
[
p_corner
];
}
void
StyleBoxFlat
::
set_expand_margin_size
(
Margin
p_expand_margin
,
float
p_size
)
{
ERR_FAIL_INDEX
((
int
)
p_expand_margin
,
4
);
expand_margin
[
p_expand_margin
]
=
p_size
;
emit_changed
();
}
...
...
@@ -468,6 +486,7 @@ void StyleBoxFlat::set_expand_margin_size_all(float p_expand_margin_size) {
float
StyleBoxFlat
::
get_expand_margin_size
(
Margin
p_expand_margin
)
const
{
ERR_FAIL_INDEX_V
((
int
)
p_expand_margin
,
4
,
0.0
);
return
expand_margin
[
p_expand_margin
];
}
void
StyleBoxFlat
::
set_draw_center
(
bool
p_enabled
)
{
...
...
@@ -814,6 +833,7 @@ void StyleBoxFlat::draw(RID p_canvas_item, const Rect2 &p_rect) const {
}
float
StyleBoxFlat
::
get_style_margin
(
Margin
p_margin
)
const
{
ERR_FAIL_INDEX_V
((
int
)
p_margin
,
4
,
0.0
);
return
border_width
[
p_margin
];
}
void
StyleBoxFlat
::
_bind_methods
()
{
...
...
@@ -997,6 +1017,7 @@ void StyleBoxLine::_bind_methods() {
ADD_PROPERTY
(
PropertyInfo
(
Variant
::
BOOL
,
"vertical"
),
"set_vertical"
,
"is_vertical"
);
}
float
StyleBoxLine
::
get_style_margin
(
Margin
p_margin
)
const
{
ERR_FAIL_INDEX_V
((
int
)
p_margin
,
4
,
thickness
);
return
thickness
;
}
Size2
StyleBoxLine
::
get_center_size
()
const
{
...
...
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