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>2018-05-14 15:46:37 +0300
committerCampbell Barton <ideasman42@gmail.com>2018-05-14 15:47:52 +0300
commit9e4709e9a556eb2717c7e3c8eafd8dc50ffa801b (patch)
tree00e0569eca64a478298bdb63bdd6447faa86a407 /source/blender/editors/manipulator_library
parente5b53fb28cab9f39f888b7ec1c128b990d3b7a36 (diff)
Manipulator: fix 2D icon buttons in the 3D view
Diffstat (limited to 'source/blender/editors/manipulator_library')
-rw-r--r--source/blender/editors/manipulator_library/manipulator_types/button2d_manipulator.c41
1 files changed, 33 insertions, 8 deletions
diff --git a/source/blender/editors/manipulator_library/manipulator_types/button2d_manipulator.c b/source/blender/editors/manipulator_library/manipulator_types/button2d_manipulator.c
index 73520d1801d..fbf783c31f7 100644
--- a/source/blender/editors/manipulator_library/manipulator_types/button2d_manipulator.c
+++ b/source/blender/editors/manipulator_library/manipulator_types/button2d_manipulator.c
@@ -98,7 +98,7 @@ static void button2d_geom_draw_backdrop(
}
static void button2d_draw_intern(
- const bContext *UNUSED(C), wmManipulator *mpr,
+ const bContext *C, wmManipulator *mpr,
const bool select, const bool highlight)
{
ButtonManipulator2D *button = (ButtonManipulator2D *)mpr;
@@ -131,7 +131,23 @@ static void button2d_draw_intern(
gpuPushMatrix();
gpuMultMatrix(matrix_final);
- if (select == false) {
+ bool is_3d = (mpr->parent_mgroup->type->flag & WM_MANIPULATORGROUPTYPE_3D) != 0;
+ if (is_3d) {
+ RegionView3D *rv3d = CTX_wm_region_view3d(C);
+ float matrix_align[4][4];
+ float matrix_final_unit[4][4];
+ normalize_m4_m4(matrix_final_unit, matrix_final);
+ mul_m4_m4m4(matrix_align, rv3d->viewmat, matrix_final_unit);
+ zero_v3(matrix_align[3]);
+ transpose_m4(matrix_align);
+ gpuMultMatrix(matrix_align);
+ }
+
+ if (select) {
+ BLI_assert(is_3d);
+ button2d_geom_draw_backdrop(mpr, color, select);
+ }
+ else {
glEnable(GL_BLEND);
if (button->shape_batch[0] != NULL) {
glEnable(GL_LINE_SMOOTH);
@@ -150,12 +166,21 @@ static void button2d_draw_intern(
}
else if (button->icon != ICON_NONE) {
button2d_geom_draw_backdrop(mpr, color, select);
- gpuPopMatrix();
- need_to_pop = false;
- UI_icon_draw(
- mpr->matrix_basis[3][0] - (ICON_DEFAULT_WIDTH / 2.0) * UI_DPI_FAC,
- mpr->matrix_basis[3][1] - (ICON_DEFAULT_HEIGHT / 2.0) * UI_DPI_FAC,
- button->icon);
+ float size[2];
+ if (is_3d) {
+ const float fac = 2.0f;
+ gpuTranslate2f(-(fac / 2), -(fac / 2));
+ gpuScale2f(fac / (ICON_DEFAULT_WIDTH * UI_DPI_FAC), fac / (ICON_DEFAULT_HEIGHT * UI_DPI_FAC));
+ size[0] = 1.0f;
+ size[1] = 1.0f;
+ }
+ else {
+ size[0] = mpr->matrix_basis[3][0] - (ICON_DEFAULT_WIDTH / 2.0) * UI_DPI_FAC;
+ size[1] = mpr->matrix_basis[3][1] - (ICON_DEFAULT_HEIGHT / 2.0) * UI_DPI_FAC;
+ gpuPopMatrix();
+ need_to_pop = false;
+ }
+ UI_icon_draw(size[0], size[1], button->icon);
}
glDisable(GL_BLEND);
}