From 6baea955bf562399caa9c6186601815af29b584d Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 27 Sep 2018 19:15:18 +0200 Subject: UI: use new 3D viewport navigation icons and image icon in add menu. I had to make the viewport navigation icons a bit smaller in the SVG since the edges were being clipped off, we only support 16x16 icons currently. They are a bit blurry because of this. --- .../gizmo_library/gizmo_types/button2d_gizmo.c | 20 +++-- source/blender/editors/include/ED_gizmo_library.h | 3 +- source/blender/editors/include/UI_icons.h | 2 +- .../editors/space_view3d/view3d_gizmo_navigate.c | 86 ++++------------------ 4 files changed, 31 insertions(+), 80 deletions(-) (limited to 'source') diff --git a/source/blender/editors/gizmo_library/gizmo_types/button2d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/button2d_gizmo.c index 6ba85037b8b..e16deb71304 100644 --- a/source/blender/editors/gizmo_library/gizmo_types/button2d_gizmo.c +++ b/source/blender/editors/gizmo_library/gizmo_types/button2d_gizmo.c @@ -192,22 +192,27 @@ static void button2d_draw_intern( GPU_polygon_smooth(true); } else if (button->icon != ICON_NONE) { - button2d_geom_draw_backdrop(gz, color, select); - float size[2]; + if (draw_options & ED_GIZMO_BUTTON_SHOW_BACKDROP) { + button2d_geom_draw_backdrop(gz, color, select); + } + + float pos[2]; if (is_3d) { const float fac = 2.0f; GPU_matrix_translate_2f(-(fac / 2), -(fac / 2)); GPU_matrix_scale_2f(fac / (ICON_DEFAULT_WIDTH * UI_DPI_FAC), fac / (ICON_DEFAULT_HEIGHT * UI_DPI_FAC)); - size[0] = 1.0f; - size[1] = 1.0f; + pos[0] = 1.0f; + pos[1] = 1.0f; } else { - size[0] = gz->matrix_basis[3][0] - (ICON_DEFAULT_WIDTH / 2.0) * UI_DPI_FAC; - size[1] = gz->matrix_basis[3][1] - (ICON_DEFAULT_HEIGHT / 2.0) * UI_DPI_FAC; + pos[0] = gz->matrix_basis[3][0] - (ICON_DEFAULT_WIDTH / 2.0) * UI_DPI_FAC; + pos[1] = gz->matrix_basis[3][1] - (ICON_DEFAULT_HEIGHT / 2.0) * UI_DPI_FAC; GPU_matrix_pop(); need_to_pop = false; } - UI_icon_draw(size[0], size[1], button->icon); + + float alpha = (highlight) ? 1.0f : 0.8f; + UI_icon_draw_alpha(pos[0], pos[1], button->icon, alpha); } GPU_blend(false); } @@ -299,6 +304,7 @@ static void GIZMO_GT_button_2d(wmGizmoType *gzt) /* rna */ static EnumPropertyItem rna_enum_draw_options[] = { {ED_GIZMO_BUTTON_SHOW_OUTLINE, "OUTLINE", 0, "Outline", ""}, + {ED_GIZMO_BUTTON_SHOW_BACKDROP, "BACKDROP", 0, "Backdrop", ""}, {ED_GIZMO_BUTTON_SHOW_HELPLINE, "HELPLINE", 0, "Help Line", ""}, {0, NULL, 0, NULL, NULL} }; diff --git a/source/blender/editors/include/ED_gizmo_library.h b/source/blender/editors/include/ED_gizmo_library.h index 983f3b89771..45ada740c1c 100644 --- a/source/blender/editors/include/ED_gizmo_library.h +++ b/source/blender/editors/include/ED_gizmo_library.h @@ -215,11 +215,12 @@ enum { enum { ED_GIZMO_BUTTON_SHOW_OUTLINE = (1 << 0), + ED_GIZMO_BUTTON_SHOW_BACKDROP = (1 << 1), /** * Draw a line from the origin to the offset (similar to an arrow) * sometimes needed to show what the button edits. */ - ED_GIZMO_BUTTON_SHOW_HELPLINE = (1 << 1), + ED_GIZMO_BUTTON_SHOW_HELPLINE = (1 << 2), }; diff --git a/source/blender/editors/include/UI_icons.h b/source/blender/editors/include/UI_icons.h index 89f14bba5c7..45cc1046932 100644 --- a/source/blender/editors/include/UI_icons.h +++ b/source/blender/editors/include/UI_icons.h @@ -299,7 +299,7 @@ DEF_ICON(OUTLINER_OB_FORCE_FIELD) DEF_ICON(OUTLINER_OB_GROUP_INSTANCE) DEF_ICON(OUTLINER_OB_GREASEPENCIL) DEF_ICON(OUTLINER_OB_LIGHTPROBE) -DEF_ICON_BLANK(124) +DEF_ICON(OUTLINER_OB_IMAGE) DEF_ICON_BLANK(125) DEF_ICON(RESTRICT_COLOR_OFF) DEF_ICON(RESTRICT_COLOR_ON) diff --git a/source/blender/editors/space_view3d/view3d_gizmo_navigate.c b/source/blender/editors/space_view3d/view3d_gizmo_navigate.c index 66faac49304..4eee7251022 100644 --- a/source/blender/editors/space_view3d/view3d_gizmo_navigate.c +++ b/source/blender/editors/space_view3d/view3d_gizmo_navigate.c @@ -51,13 +51,13 @@ * \{ */ /* Offset from screen edge. */ -#define GIZMO_OFFSET_FAC 1.2f +#define GIZMO_OFFSET_FAC 1.1f /* Size of main icon. */ #define GIZMO_SIZE 80 -/* Factor for size of smaller button. */ -#define GIZMO_MINI_FAC 0.35f +/* Size of the smaller icons. */ +#define GIZMO_ICON_SIZE 20 /* How much mini buttons offset from the primary. */ -#define GIZMO_MINI_OFFSET_FAC 0.42f +#define GIZMO_MINI_OFFSET_FAC 0.32f enum { @@ -74,94 +74,40 @@ enum { MPR_TOTAL = 6, }; -/* Vector icons compatible with 'GPU_batch_from_poly_2d_encoded' */ -static const uchar shape_camera[] = { - 0xa3, 0x19, 0x78, 0x55, 0x4d, 0x19, 0x4f, 0x0a, 0x7f, 0x00, 0xb0, 0x0a, 0xa9, 0x19, - 0xa9, 0x19, 0x25, 0xda, 0x0a, 0xb0, 0x00, 0x7f, 0x0a, 0x4f, 0x25, 0x25, 0x4f, 0x0a, - 0x4d, 0x19, 0x47, 0x19, 0x65, 0x55, 0x41, 0x55, 0x41, 0x9e, 0x43, 0xa8, 0x38, 0xb3, - 0x34, 0xc3, 0x38, 0xd2, 0x43, 0xdd, 0x53, 0xe1, 0x62, 0xdd, 0x6d, 0xd2, 0x72, 0xc3, - 0x78, 0xc3, 0x7c, 0xd2, 0x87, 0xdd, 0x96, 0xe1, 0xa6, 0xdd, 0xb1, 0xd2, 0xb5, 0xc3, - 0xb1, 0xb3, 0xa6, 0xa8, 0xa9, 0x9e, 0xa9, 0x8c, 0xbb, 0x8c, 0xbb, 0x86, 0xc7, 0x86, - 0xe0, 0x9e, 0xe0, 0x55, 0xc7, 0x6d, 0xbb, 0x6d, 0xbb, 0x67, 0xa9, 0x67, 0xa9, 0x55, - 0x8a, 0x55, 0xa9, 0x19, 0xb0, 0x0a, 0xda, 0x25, 0xf5, 0x4f, 0xff, 0x80, 0xf5, 0xb0, - 0xda, 0xda, 0xb0, 0xf5, 0x80, 0xff, 0x4f, 0xf5, 0x4f, 0xf5, 0x7c, 0xb3, 0x78, 0xc3, - 0x72, 0xc3, 0x6d, 0xb3, 0x62, 0xa8, 0x53, 0xa4, 0x43, 0xa8, 0x41, 0x9e, 0xa9, 0x9e, - 0xa6, 0xa8, 0x96, 0xa4, 0x87, 0xa8, 0x87, 0xa8, -}; -static const uchar shape_ortho[] = { - 0x85, 0x15, 0x85, 0x7c, 0xde, 0xb3, 0xde, 0xb8, 0xd9, 0xba, 0x80, 0x85, 0x27, 0xba, - 0x22, 0xb8, 0x22, 0xb3, 0x7b, 0x7c, 0x7b, 0x15, 0x80, 0x12, 0x80, 0x12, 0x1d, 0xba, - 0x80, 0xf2, 0x80, 0xff, 0x4f, 0xf5, 0x25, 0xda, 0x0a, 0xb0, 0x00, 0x7f, 0x0a, 0x4f, - 0x25, 0x25, 0x4f, 0x0a, 0x7f, 0x00, 0x80, 0x0d, 0x1d, 0x45, 0x1d, 0x45, 0xb0, 0x0a, - 0xda, 0x25, 0xf5, 0x4f, 0xff, 0x80, 0xf5, 0xb0, 0xda, 0xda, 0xb0, 0xf5, 0x80, 0xff, - 0x80, 0xf2, 0xe3, 0xba, 0xe3, 0x45, 0x80, 0x0d, 0x7f, 0x00, 0x7f, 0x00, -}; -static const uchar shape_pan[] = { - 0xbf, 0x4c, 0xbf, 0x66, 0x99, 0x66, 0x99, 0x40, 0xb2, 0x40, 0x7f, 0x0d, 0x7f, 0x00, - 0xb0, 0x0a, 0xda, 0x25, 0xf5, 0x4f, 0xff, 0x80, 0xf5, 0xb0, 0xda, 0xda, 0xb0, 0xf5, - 0x80, 0xff, 0x80, 0xf2, 0xb3, 0xbf, 0x99, 0xbf, 0x99, 0x99, 0xbf, 0x99, 0xbf, 0xb2, - 0xf2, 0x7f, 0xf2, 0x7f, 0x40, 0xb3, 0x40, 0x99, 0x66, 0x99, 0x66, 0xbf, 0x4d, 0xbf, - 0x80, 0xf2, 0x80, 0xff, 0x4f, 0xf5, 0x25, 0xda, 0x0a, 0xb0, 0x00, 0x7f, 0x0a, 0x4f, - 0x25, 0x25, 0x4f, 0x0a, 0x7f, 0x00, 0x7f, 0x0d, 0x4c, 0x40, 0x66, 0x40, 0x66, 0x66, - 0x40, 0x66, 0x40, 0x4d, 0x0d, 0x80, 0x0d, 0x80, -}; -static const uchar shape_persp[] = { - 0xda, 0xda, 0xb0, 0xf5, 0x80, 0xff, 0x4f, 0xf5, 0x25, 0xda, 0x0a, 0xb0, 0x00, 0x7f, - 0x0a, 0x4f, 0x25, 0x25, 0x4f, 0x0a, 0x7f, 0x00, 0x80, 0x07, 0x30, 0x50, 0x18, 0xbd, - 0x80, 0xdb, 0xe8, 0xbd, 0xf5, 0xb0, 0xf5, 0xb0, 0x83, 0x0f, 0x87, 0x7b, 0xe2, 0xb7, - 0xe3, 0xba, 0xe0, 0xbb, 0x80, 0x87, 0x20, 0xbb, 0x1d, 0xba, 0x1d, 0xb7, 0x78, 0x7b, - 0x7d, 0x0f, 0x80, 0x0c, 0x80, 0x0c, 0xd0, 0x50, 0x80, 0x07, 0x7f, 0x00, 0xb0, 0x0a, - 0xda, 0x25, 0xf5, 0x4f, 0xff, 0x80, 0xf5, 0xb0, 0xe8, 0xbd, 0xe8, 0xbd, -}; -static const uchar shape_zoom[] = { - 0xad, 0x7f, 0xf1, 0x7f, 0xff, 0x80, 0xf5, 0xb0, 0xda, 0xda, 0xb0, 0xf5, 0x80, 0xff, - 0x4f, 0xf5, 0x25, 0xda, 0x0a, 0xb0, 0x00, 0x7f, 0x0d, 0x7f, 0x52, 0x7f, 0x69, 0xb7, - 0x48, 0xb7, 0x80, 0xd8, 0xb8, 0xb7, 0x96, 0xb7, 0x96, 0xb7, 0x7f, 0x2f, 0x0d, 0x7f, - 0x00, 0x7f, 0x0a, 0x4f, 0x25, 0x25, 0x4f, 0x0a, 0x7f, 0x00, 0xb0, 0x0a, 0xda, 0x25, - 0xf5, 0x4f, 0xff, 0x80, 0xf1, 0x7f, 0xf1, 0x7f, -}; - - struct NavigateGizmoInfo { const char *opname; const char *gizmo; - const unsigned char *shape; - uint shape_size; + uint icon; }; -#define SHAPE_VARS(shape_id) shape = shape_id, .shape_size = ARRAY_SIZE(shape_id) - static struct NavigateGizmoInfo g_navigate_params[MPR_TOTAL] = { { .opname = "VIEW3D_OT_move", .gizmo = "GIZMO_GT_button_2d", - .SHAPE_VARS(shape_pan), + ICON_VIEW_PAN, }, { .opname = "VIEW3D_OT_rotate", .gizmo = "VIEW3D_GT_navigate_rotate", - .shape = NULL, - .shape_size = 0, + 0, }, { .opname = "VIEW3D_OT_zoom", .gizmo = "GIZMO_GT_button_2d", - .SHAPE_VARS(shape_zoom), + ICON_VIEW_ZOOM, }, { .opname = "VIEW3D_OT_view_persportho", .gizmo = "GIZMO_GT_button_2d", - .SHAPE_VARS(shape_persp), + ICON_VIEW_PERSPECTIVE, }, { .opname = "VIEW3D_OT_view_persportho", .gizmo = "GIZMO_GT_button_2d", - .SHAPE_VARS(shape_ortho), + ICON_VIEW_ORTHO, }, { .opname = "VIEW3D_OT_view_camera", .gizmo = "GIZMO_GT_button_2d", - .SHAPE_VARS(shape_camera), + ICON_VIEW_CAMERA, }, }; -#undef SHAPE_VARS - struct NavigateWidgetGroup { wmGizmo *gz_array[MPR_TOTAL]; /* Store the view state to check for changes. */ @@ -216,12 +162,10 @@ static void WIDGETGROUP_navigate_setup(const bContext *UNUSED(C), wmGizmoGroup * /* may be overwritten later */ - gz->scale_basis = (GIZMO_SIZE * GIZMO_MINI_FAC) / 2; - if (info->shape != NULL) { - PropertyRNA *prop = RNA_struct_find_property(gz->ptr, "shape"); - RNA_property_string_set_bytes( - gz->ptr, prop, - (const char *)info->shape, info->shape_size); + gz->scale_basis = (GIZMO_ICON_SIZE) / 2; + if (info->icon != 0) { + PropertyRNA *prop = RNA_struct_find_property(gz->ptr, "icon"); + RNA_property_enum_set(gz->ptr, prop, info->icon); RNA_enum_set(gz->ptr, "draw_options", ED_GIZMO_BUTTON_SHOW_OUTLINE); } -- cgit v1.2.3