summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2019-07-09 22:06:16 +0200
committerGitHub <noreply@github.com>2019-07-09 22:06:16 +0200
commit9d47e3b975eb5013e125be0b3c169e1173d90d3b (patch)
tree77c1891c15fb4ce45c528aa3388ee1766c709e9e /editor
parentd2e620b8fcd21aaca2cbf8716edea550d3f02537 (diff)
parent2491c87f8658696509c58985c3c075d32e585305 (diff)
Merge pull request #30461 from Calinou/draw-rect-width-antialiased
Add `width` and `antialiased` parameters to CanvasItem `draw_rect()`
Diffstat (limited to 'editor')
-rw-r--r--editor/plugins/curve_editor_plugin.cpp19
-rw-r--r--editor/plugins/curve_editor_plugin.h2
-rw-r--r--editor/plugins/spatial_editor_plugin.cpp21
3 files changed, 3 insertions, 39 deletions
diff --git a/editor/plugins/curve_editor_plugin.cpp b/editor/plugins/curve_editor_plugin.cpp
index d2d2b8f130..33f685892c 100644
--- a/editor/plugins/curve_editor_plugin.cpp
+++ b/editor/plugins/curve_editor_plugin.cpp
@@ -715,7 +715,7 @@ void CurveEditor::_draw() {
if (_hover_point != -1) {
const Color hover_color = line_color;
Vector2 pos = curve.get_point_position(_hover_point);
- stroke_rect(Rect2(get_view_pos(pos), Vector2(1, 1)).grow(_hover_radius), hover_color);
+ draw_rect(Rect2(get_view_pos(pos), Vector2(1, 1)).grow(_hover_radius), hover_color, false, Math::round(EDSCALE));
}
// Help text
@@ -726,23 +726,6 @@ void CurveEditor::_draw() {
}
}
-// TODO That should be part of the drawing API...
-void CurveEditor::stroke_rect(Rect2 rect, Color color) {
-
- // a---b
- // | |
- // c---d
- Vector2 a(rect.position);
- Vector2 b(rect.position.x + rect.size.x, rect.position.y);
- Vector2 c(rect.position.x, rect.position.y + rect.size.y);
- Vector2 d(rect.position + rect.size);
-
- draw_line(a, b, color, Math::round(EDSCALE));
- draw_line(b, d, color, Math::round(EDSCALE));
- draw_line(d, c, color, Math::round(EDSCALE));
- draw_line(c, a, color, Math::round(EDSCALE));
-}
-
void CurveEditor::_bind_methods() {
ClassDB::bind_method(D_METHOD("_gui_input"), &CurveEditor::on_gui_input);
ClassDB::bind_method(D_METHOD("_on_preset_item_selected"), &CurveEditor::on_preset_item_selected);
diff --git a/editor/plugins/curve_editor_plugin.h b/editor/plugins/curve_editor_plugin.h
index be774a9696..2e2bf1c26f 100644
--- a/editor/plugins/curve_editor_plugin.h
+++ b/editor/plugins/curve_editor_plugin.h
@@ -97,8 +97,6 @@ private:
void _draw();
- void stroke_rect(Rect2 rect, Color color);
-
private:
Transform2D _world_to_view;
diff --git a/editor/plugins/spatial_editor_plugin.cpp b/editor/plugins/spatial_editor_plugin.cpp
index fc72f25b04..66663d0cd9 100644
--- a/editor/plugins/spatial_editor_plugin.cpp
+++ b/editor/plugins/spatial_editor_plugin.cpp
@@ -2348,23 +2348,6 @@ void SpatialEditorViewport::_notification(int p_what) {
}
}
-// TODO That should be part of the drawing API...
-static void stroke_rect(CanvasItem &ci, Rect2 rect, Color color, real_t width = 1.0) {
-
- // a---b
- // | |
- // c---d
- Vector2 a(rect.position);
- Vector2 b(rect.position.x + rect.size.x, rect.position.y);
- Vector2 c(rect.position.x, rect.position.y + rect.size.y);
- Vector2 d(rect.position + rect.size);
-
- ci.draw_line(a, b, color, width);
- ci.draw_line(b, d, color, width);
- ci.draw_line(d, c, color, width);
- ci.draw_line(c, a, color, width);
-}
-
static void draw_indicator_bar(Control &surface, real_t fill, Ref<Texture> icon) {
// Adjust bar size from control height
@@ -2379,7 +2362,7 @@ static void draw_indicator_bar(Control &surface, real_t fill, Ref<Texture> icon)
// Draw both neutral dark and bright colors to account this
surface.draw_rect(r, Color(1, 1, 1, 0.2));
surface.draw_rect(Rect2(r.position.x, r.position.y + r.size.y - sy, r.size.x, sy), Color(1, 1, 1, 0.6));
- stroke_rect(surface, r.grow(1), Color(0, 0, 0, 0.7));
+ surface.draw_rect(r.grow(1), Color(0, 0, 0, 0.7), false, Math::round(EDSCALE));
Vector2 icon_size = icon->get_size();
Vector2 icon_pos = Vector2(r.position.x - (icon_size.x - r.size.x) / 2, r.position.y + r.size.y + 2);
@@ -2460,7 +2443,7 @@ void SpatialEditorViewport::_draw() {
draw_rect = Rect2(Vector2(), s).clip(draw_rect);
- stroke_rect(*surface, draw_rect, Color(0.6, 0.6, 0.1, 0.5), 2.0);
+ surface->draw_rect(draw_rect, Color(0.6, 0.6, 0.1, 0.5), false, Math::round(2 * EDSCALE));
} else {