Merge pull request #31399 from Calinou/box-selection-add-borders

Add an outline to box selection rectangles for better visibility
This commit is contained in:
Rémi Verschelde 2019-08-17 11:26:05 +02:00 committed by GitHub
commit be42f1bf6c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 33 additions and 15 deletions

View File

@ -5050,10 +5050,9 @@ float AnimationTrackEditor::get_moving_selection_offset() const {
void AnimationTrackEditor::_box_selection_draw() {
Color color = get_color("accent_color", "Editor");
color.a = 0.2;
Rect2 rect = Rect2(Point2(), box_selection->get_size());
box_selection->draw_rect(rect, color);
const Rect2 selection_rect = Rect2(Point2(), box_selection->get_size());
box_selection->draw_rect(selection_rect, get_color("box_selection_fill_color", "Editor"));
box_selection->draw_rect(selection_rect, get_color("box_selection_stroke_color", "Editor"), false, Math::round(EDSCALE));
}
void AnimationTrackEditor::_scroll_input(const Ref<InputEvent> &p_event) {

View File

@ -351,6 +351,8 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
theme->set_color("dark_color_3", "Editor", dark_color_3);
theme->set_color("contrast_color_1", "Editor", contrast_color_1);
theme->set_color("contrast_color_2", "Editor", contrast_color_2);
theme->set_color("box_selection_fill_color", "Editor", accent_color * Color(1, 1, 1, 0.3));
theme->set_color("box_selection_stroke_color", "Editor", accent_color * Color(1, 1, 1, 0.8));
theme->set_color("font_color", "Editor", font_color);
theme->set_color("highlighted_font_color", "Editor", font_color_hl);

View File

@ -2918,10 +2918,15 @@ void CanvasItemEditor::_draw_selection() {
Point2 bsfrom = transform.xform(drag_from);
Point2 bsto = transform.xform(box_selecting_to);
VisualServer::get_singleton()->canvas_item_add_rect(
ci,
viewport->draw_rect(
Rect2(bsfrom, bsto - bsfrom),
get_color("accent_color", "Editor") * Color(1, 1, 1, 0.375));
get_color("box_selection_fill_color", "Editor"));
viewport->draw_rect(
Rect2(bsfrom, bsto - bsfrom),
get_color("box_selection_stroke_color", "Editor"),
false,
Math::round(EDSCALE));
}
if (drag_type == DRAG_ROTATE) {

View File

@ -2373,16 +2373,22 @@ void SpatialEditorViewport::_draw() {
get_stylebox("Focus", "EditorStyles")->draw(surface->get_canvas_item(), r);
}
RID ci = surface->get_canvas_item();
if (cursor.region_select) {
const Rect2 selection_rect = Rect2(cursor.region_begin, cursor.region_end - cursor.region_begin);
VisualServer::get_singleton()->canvas_item_add_rect(
ci,
Rect2(cursor.region_begin, cursor.region_end - cursor.region_begin),
get_color("accent_color", "Editor") * Color(1, 1, 1, 0.375));
surface->draw_rect(
selection_rect,
get_color("box_selection_fill_color", "Editor"));
surface->draw_rect(
selection_rect,
get_color("box_selection_stroke_color", "Editor"),
false,
Math::round(EDSCALE));
}
RID ci = surface->get_canvas_item();
if (message_time > 0) {
Ref<Font> font = get_font("font", "Label");
Point2 msgpos = Point2(5, get_size().y - 20);

View File

@ -776,10 +776,16 @@ void GraphEdit::_top_layer_draw() {
_draw_cos_line(top_layer, pos, topos, col, col);
}
if (box_selecting)
if (box_selecting) {
top_layer->draw_rect(
box_selecting_rect,
get_color("accent_color", "Editor") * Color(1, 1, 1, 0.375));
get_color("box_selection_fill_color", "Editor"));
top_layer->draw_rect(
box_selecting_rect,
get_color("box_selection_stroke_color", "Editor"),
false);
}
}
void GraphEdit::set_selected(Node *p_child) {