Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2019-12-19 08:36:54 +0300
committerCampbell Barton <ideasman42@gmail.com>2019-12-19 08:48:45 +0300
commit0971f56bac242e983db4e089f11b2fd818a0b904 (patch)
treecfd1c5c519343996267204c45b93bcc960ae8851 /source/blender/editors/transform/transform.c
parentc14e352d2ceb62288349bfc7afa4453d6cf38646 (diff)
UI: use DPI scale for transform cursors
Diffstat (limited to 'source/blender/editors/transform/transform.c')
-rw-r--r--source/blender/editors/transform/transform.c38
1 files changed, 26 insertions, 12 deletions
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c
index 42adf1ee456..719064ba1d6 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -1700,6 +1700,10 @@ static void drawArrow(ArrowDirection d, short offset, short length, short size)
{
immBegin(GPU_PRIM_LINES, 6);
+ offset = round_fl_to_short(UI_DPI_FAC * offset);
+ length = round_fl_to_short(UI_DPI_FAC * length);
+ size = round_fl_to_short(UI_DPI_FAC * size);
+
switch (d) {
case LEFT:
offset = -offset;
@@ -1735,6 +1739,8 @@ static void drawArrow(ArrowDirection d, short offset, short length, short size)
static void drawArrowHead(ArrowDirection d, short size)
{
+ size = round_fl_to_short(UI_DPI_FAC * size);
+
immBegin(GPU_PRIM_LINES, 4);
switch (d) {
@@ -1762,8 +1768,10 @@ static void drawArrowHead(ArrowDirection d, short size)
immEnd();
}
-static void drawArc(float size, float angle_start, float angle_end, int segments)
+static void drawArc(float angle_start, float angle_end, int segments, float size)
{
+ segments = round_fl_to_int(segments * UI_DPI_FAC);
+
float delta = (angle_end - angle_start) / segments;
float angle;
int a;
@@ -1816,6 +1824,9 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata)
tmval[i] += offset[i];
}
+ GPU_line_smooth(true);
+ GPU_blend(true);
+
GPU_matrix_push();
/* Dashed lines first. */
@@ -1835,8 +1846,8 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata)
immUniform2f("viewport_size", viewport_size[2], viewport_size[3]);
immUniform1i("colors_len", 0); /* "simple" mode */
- immUniformThemeColor(TH_VIEW_OVERLAY);
- immUniform1f("dash_width", 6.0f);
+ immUniformThemeColor3(TH_VIEW_OVERLAY);
+ immUniform1f("dash_width", 6.0f * UI_DPI_FAC);
immUniform1f("dash_factor", 0.5f);
immBegin(GPU_PRIM_LINES, 2);
@@ -1855,7 +1866,7 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata)
switch (t->helpline) {
case HLP_SPRING:
- immUniformThemeColor(TH_VIEW_OVERLAY);
+ immUniformThemeColor3(TH_VIEW_OVERLAY);
GPU_matrix_translate_3fv(mval);
GPU_matrix_rotate_axis(-RAD2DEGF(atan2f(cent[0] - tmval[0], cent[1] - tmval[1])), 'Z');
@@ -1865,7 +1876,7 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata)
drawArrow(DOWN, 5, 10, 5);
break;
case HLP_HARROW:
- immUniformThemeColor(TH_VIEW_OVERLAY);
+ immUniformThemeColor3(TH_VIEW_OVERLAY);
GPU_matrix_translate_3fv(mval);
GPU_line_width(3.0f);
@@ -1873,7 +1884,7 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata)
drawArrow(LEFT, 5, 10, 5);
break;
case HLP_VARROW:
- immUniformThemeColor(TH_VIEW_OVERLAY);
+ immUniformThemeColor3(TH_VIEW_OVERLAY);
GPU_matrix_translate_3fv(mval);
@@ -1883,7 +1894,7 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata)
break;
case HLP_CARROW: {
/* Draw arrow based on direction defined by custom-points. */
- immUniformThemeColor(TH_VIEW_OVERLAY);
+ immUniformThemeColor3(TH_VIEW_OVERLAY);
GPU_matrix_translate_3fv(mval);
@@ -1907,16 +1918,16 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata)
float dx = tmval[0] - cent[0], dy = tmval[1] - cent[1];
float angle = atan2f(dy, dx);
float dist = hypotf(dx, dy);
- float delta_angle = min_ff(15.0f / dist, (float)M_PI / 4.0f);
- float spacing_angle = min_ff(5.0f / dist, (float)M_PI / 12.0f);
+ float delta_angle = min_ff(15.0f / (dist / UI_DPI_FAC), (float)M_PI / 4.0f);
+ float spacing_angle = min_ff(5.0f / (dist / UI_DPI_FAC), (float)M_PI / 12.0f);
- immUniformThemeColor(TH_VIEW_OVERLAY);
+ immUniformThemeColor3(TH_VIEW_OVERLAY);
GPU_matrix_translate_3f(cent[0] - tmval[0] + mval[0], cent[1] - tmval[1] + mval[1], 0);
GPU_line_width(3.0f);
- drawArc(dist, angle - delta_angle, angle - spacing_angle, 10);
- drawArc(dist, angle + spacing_angle, angle + delta_angle, 10);
+ drawArc(angle - delta_angle, angle - spacing_angle, 10, dist);
+ drawArc(angle + spacing_angle, angle + delta_angle, 10, dist);
GPU_matrix_push();
@@ -1960,6 +1971,9 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata)
immUnbindProgram();
GPU_matrix_pop();
+
+ GPU_line_smooth(false);
+ GPU_blend(false);
}
}