summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2020-01-09 07:27:49 +0100
committerGitHub <noreply@github.com>2020-01-09 07:27:49 +0100
commit8ece49bf04c8d12683db717c3419d90ff88c0b57 (patch)
tree828aa0b378a5678e5c3dd67f81c5abce47901044
parente7b7dc57fc8ecab198695d9bf6a4d694fb5a72a8 (diff)
parent93aa3a01261f38553171312a691a8c123573b370 (diff)
Merge pull request #34942 from timothyqiu/texture-region-handle
Fixes TextureRegion editor drag handle for HiDPI
-rw-r--r--editor/plugins/texture_region_editor_plugin.cpp24
1 files changed, 14 insertions, 10 deletions
diff --git a/editor/plugins/texture_region_editor_plugin.cpp b/editor/plugins/texture_region_editor_plugin.cpp
index 294bedd598..13faeb0edb 100644
--- a/editor/plugins/texture_region_editor_plugin.cpp
+++ b/editor/plugins/texture_region_editor_plugin.cpp
@@ -233,15 +233,19 @@ void TextureRegionEditor::_region_input(const Ref<InputEvent> &p_input) {
mtx.elements[2] = -draw_ofs * draw_zoom;
mtx.scale_basis(Vector2(draw_zoom, draw_zoom));
- Vector2 endpoints[8] = {
- mtx.xform(rect.position) + Vector2(-4, -4),
- mtx.xform(rect.position + Vector2(rect.size.x / 2, 0)) + Vector2(0, -4),
- mtx.xform(rect.position + Vector2(rect.size.x, 0)) + Vector2(4, -4),
- mtx.xform(rect.position + Vector2(rect.size.x, rect.size.y / 2)) + Vector2(4, 0),
- mtx.xform(rect.position + rect.size) + Vector2(4, 4),
- mtx.xform(rect.position + Vector2(rect.size.x / 2, rect.size.y)) + Vector2(0, 4),
- mtx.xform(rect.position + Vector2(0, rect.size.y)) + Vector2(-4, 4),
- mtx.xform(rect.position + Vector2(0, rect.size.y / 2)) + Vector2(-4, 0)
+ const real_t handle_radius = 8 * EDSCALE;
+ const real_t handle_offset = 4 * EDSCALE;
+
+ // Position of selection handles.
+ const Vector2 endpoints[8] = {
+ mtx.xform(rect.position) + Vector2(-handle_offset, -handle_offset),
+ mtx.xform(rect.position + Vector2(rect.size.x / 2, 0)) + Vector2(0, -handle_offset),
+ mtx.xform(rect.position + Vector2(rect.size.x, 0)) + Vector2(handle_offset, -handle_offset),
+ mtx.xform(rect.position + Vector2(rect.size.x, rect.size.y / 2)) + Vector2(handle_offset, 0),
+ mtx.xform(rect.position + rect.size) + Vector2(handle_offset, handle_offset),
+ mtx.xform(rect.position + Vector2(rect.size.x / 2, rect.size.y)) + Vector2(0, handle_offset),
+ mtx.xform(rect.position + Vector2(0, rect.size.y)) + Vector2(-handle_offset, handle_offset),
+ mtx.xform(rect.position + Vector2(0, rect.size.y / 2)) + Vector2(-handle_offset, 0)
};
Ref<InputEventMouseButton> mb = p_input;
@@ -354,7 +358,7 @@ void TextureRegionEditor::_region_input(const Ref<InputEvent> &p_input) {
for (int i = 0; i < 8; i++) {
Vector2 tuv = endpoints[i];
- if (tuv.distance_to(Vector2(mb->get_position().x, mb->get_position().y)) < 8) {
+ if (tuv.distance_to(Vector2(mb->get_position().x, mb->get_position().y)) < handle_radius) {
drag_index = i;
}
}