Repository: godotengine/godot
File: editor/plugins/canvas_item_editor_plugin.cpp (C++)

Code before:
	}
	selected_from_canvas = false;
}

void CanvasItemEditor::edit(CanvasItem *p_canvas_item) {
	Array selection = editor_selection->get_selected_nodes();
	if (selection.size() != 1 || (Node *)selection[0] != p_canvas_item) {
		drag_type = DRAG_NONE;

		// Clear the selection
		editor_selection->clear(); //_clear_canvas_items();
		editor_selection->add_node(p_canvas_item);
	}
}

void CanvasItemEditor::_update_scrollbars() {
	updating_scroll = true;

	// Move the zoom buttons.
	Point2 controls_vb_begin = Point2(5, 5);
	controls_vb_begin += (show_rulers) ? Point2(RULER_WIDTH, RULER_WIDTH) : Point2();
	controls_vb->set_begin(controls_vb_begin);

	Size2 hmin = h_scroll->get_minimum_size();
	Size2 vmin = v_scroll->get_minimum_size();

	// Get the visible frame.
	Size2 screen_rect = Size2(ProjectSettings::get_singleton()->get("display/window/size/width"), ProjectSettings::get_singleton()->get("display/window/size/height"));
	Rect2 local_rect = Rect2(Point2(), viewport->get_size() - Size2(vmin.width, hmin.height));

	// Calculate scrollable area.
	Rect2 canvas_item_rect = Rect2(Point2(), screen_rect);
	if (editor->is_inside_tree() && editor->get_edited_scene()) {
		Rect2 content_rect = _get_encompassing_rect(editor->get_edited_scene());
		canvas_item_rect.expand_to(content_rect.position);
		canvas_item_rect.expand_to(content_rect.position + content_rect.size);
	}
	canvas_item_rect.size += screen_rect * 2;
	canvas_item_rect.position -= screen_rect;

	// Constraints the view offset and updates the scrollbars.
	Size2 size = viewport->get_size();
	Point2 begin = canvas_item_rect.position;
	Point2 end = canvas_item_rect.position + canvas_item_rect.size - local_rect.size / zoom;
	bool constrain_editor_view = bool(EditorSettings::get_singleton()->get("editors/2d/constrain_editor_view"));

	if (canvas_item_rect.size.height <= (local_rect.size.y / zoom)) {
		float centered = -(size.y / 2) / zoom + screen_rect.y / 2;
		if (constrain_editor_view && ABS(centered - previous_update_view_offset.y) < ABS(centered - view_offset.y)) {
			view_offset.y = previous_update_view_offset.y;
		}

Review comment (suggestion):
```suggestion
	Color accent_color = EditorNode::get_singleton()->get_gui_base()->get_theme_color("accent_color", "Editor")
	context_menu_stylebox->set_bg_color(accent_color * Color(1, 1, 1, 0.1));
	// Add an underline to the StyleBox, but prevent its minimum vertical size from changing.
	context_menu_stylebox->set_border_color(accent_color, "Editor"));
```

Code after:

	if (!selected_from_canvas) {
		drag_type = DRAG_NONE;
	}
	selected_from_canvas = false;
}

void CanvasItemEditor::edit(CanvasItem *p_canvas_item) {
	Array selection = editor_selection->get_selected_nodes();
	if (selection.size() != 1 || (Node *)selection[0] != p_canvas_item) {
		drag_type = DRAG_NONE;

		// Clear the selection
		editor_selection->clear(); //_clear_canvas_items();
		editor_selection->add_node(p_canvas_item);
	}
}

void CanvasItemEditor::_update_context_menu_stylebox() {
	// This must be called when the theme changes to follow the new accent color.
	Ref<StyleBoxFlat> context_menu_stylebox = memnew(StyleBoxFlat);
	const Color accent_color = EditorNode::get_singleton()->get_gui_base()->get_theme_color("accent_color", "Editor");
	context_menu_stylebox->set_bg_color(accent_color * Color(1, 1, 1, 0.1));
	// Add an underline to the StyleBox, but prevent its minimum vertical size from changing.
	context_menu_stylebox->set_border_color(accent_color);
	context_menu_stylebox->set_border_width(SIDE_BOTTOM, Math::round(2 * EDSCALE));
	context_menu_stylebox->set_default_margin(SIDE_BOTTOM, 0);
	context_menu_container->add_theme_style_override("panel", context_menu_stylebox);
}

void CanvasItemEditor::_update_scrollbars() {
	updating_scroll = true;

	// Move the zoom buttons.
	Point2 controls_vb_begin = Point2(5, 5);
	controls_vb_begin += (show_rulers) ? Point2(RULER_WIDTH, RULER_WIDTH) : Point2();
	controls_vb->set_begin(controls_vb_begin);

	Size2 hmin = h_scroll->get_minimum_size();
	Size2 vmin = v_scroll->get_minimum_size();

	// Get the visible frame.
	Size2 screen_rect = Size2(ProjectSettings::get_singleton()->get("display/window/size/width"), ProjectSettings::get_singleton()->get("display/window/size/height"));
	Rect2 local_rect = Rect2(Point2(), viewport->get_size() - Size2(vmin.width, hmin.height));

	// Calculate scrollable area.
	Rect2 canvas_item_rect = Rect2(Point2(), screen_rect);
	if (editor->is_inside_tree() && editor->get_edited_scene()) {
		Rect2 content_rect = _get_encompassing_rect(editor->get_edited_scene());
		canvas_item_rect.expand_to(content_rect.position);
		canvas_item_rect.expand_to(content_rect.position + content_rect.size);