Manipulator: vector icons for 3D view navigation
Use different icons for perspective/ortho state (previous icon was place-holder).
This commit is contained in:
parent
6acfef6ef1
commit
72cb7e2726
|
@ -54,7 +54,7 @@
|
|||
/* Size of main icon. */
|
||||
#define MANIPULATOR_SIZE 64
|
||||
/* Factor for size of smaller button. */
|
||||
#define MANIPULATOR_MINI_FAC 0.4
|
||||
#define MANIPULATOR_MINI_FAC 0.5
|
||||
/* How much mini buttons offset from the primary. */
|
||||
#define MANIPULATOR_MINI_OFFSET_FAC 0.6666f
|
||||
|
||||
|
@ -63,46 +63,107 @@ enum {
|
|||
MPR_MOVE = 0,
|
||||
MPR_ROTATE = 1,
|
||||
MPR_ZOOM = 2,
|
||||
/* just buttons */
|
||||
MPR_PERSP_ORTHO = 3,
|
||||
MPR_CAMERA = 4,
|
||||
|
||||
MPR_TOTAL = 5,
|
||||
/* just buttons */
|
||||
/* overlaps MPR_ORTHO (switch between) */
|
||||
MPR_PERSP = 3,
|
||||
MPR_ORTHO = 4,
|
||||
MPR_CAMERA = 5,
|
||||
|
||||
MPR_TOTAL = 6,
|
||||
};
|
||||
|
||||
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 NavigateManipulatorInfo {
|
||||
const char *opname;
|
||||
const char *manipulator;
|
||||
int icon;
|
||||
const unsigned char *shape;
|
||||
uint shape_size;
|
||||
};
|
||||
|
||||
#define SHAPE_VARS(shape_id) shape = shape_id, .shape_size = ARRAY_SIZE(shape_id)
|
||||
|
||||
struct NavigateManipulatorInfo g_navigate_params[MPR_TOTAL] = {
|
||||
{
|
||||
.opname = "VIEW3D_OT_move",
|
||||
.manipulator = "MANIPULATOR_WT_button_2d",
|
||||
.icon = ICON_HAND,
|
||||
.SHAPE_VARS(shape_pan),
|
||||
}, {
|
||||
.opname = "VIEW3D_OT_rotate",
|
||||
.manipulator = "VIEW3D_WT_navigate_rotate",
|
||||
.icon = ICON_NONE,
|
||||
.shape = NULL,
|
||||
.shape_size = 0,
|
||||
}, {
|
||||
.opname = "VIEW3D_OT_zoom",
|
||||
.manipulator = "MANIPULATOR_WT_button_2d",
|
||||
.icon = ICON_VIEWZOOM,
|
||||
.SHAPE_VARS(shape_zoom),
|
||||
}, {
|
||||
.opname = "VIEW3D_OT_view_persportho",
|
||||
.manipulator = "MANIPULATOR_WT_button_2d",
|
||||
.icon = ICON_MESH_CUBE,
|
||||
.SHAPE_VARS(shape_persp),
|
||||
}, {
|
||||
.opname = "VIEW3D_OT_view_persportho",
|
||||
.manipulator = "MANIPULATOR_WT_button_2d",
|
||||
.SHAPE_VARS(shape_ortho),
|
||||
}, {
|
||||
.opname = "VIEW3D_OT_viewnumpad",
|
||||
.manipulator = "MANIPULATOR_WT_button_2d",
|
||||
.icon = ICON_OUTLINER_OB_CAMERA,
|
||||
.SHAPE_VARS(shape_camera),
|
||||
},
|
||||
};
|
||||
|
||||
#undef SHAPE_VARS
|
||||
|
||||
struct NavigateWidgetGroup {
|
||||
wmManipulator *mpr_array[MPR_TOTAL];
|
||||
int region_size[2];
|
||||
bool is_persp;
|
||||
};
|
||||
|
||||
static bool WIDGETGROUP_navigate_poll(const bContext *UNUSED(C), wmManipulatorGroupType *UNUSED(wgt))
|
||||
|
@ -133,8 +194,13 @@ static void WIDGETGROUP_navigate_setup(const bContext *UNUSED(C), wmManipulatorG
|
|||
|
||||
/* may be overwritten later */
|
||||
mpr->scale_basis = (MANIPULATOR_SIZE * MANIPULATOR_MINI_FAC) / 2;
|
||||
if (info->icon != ICON_NONE) {
|
||||
RNA_enum_set(mpr->ptr, "icon", info->icon);
|
||||
if (info->shape != NULL) {
|
||||
PropertyRNA *prop = RNA_struct_find_property(mpr->ptr, "shape");
|
||||
RNA_property_string_set_bytes(
|
||||
mpr->ptr, prop,
|
||||
(const char *)info->shape, info->shape_size);
|
||||
/* don't fade icons so much */
|
||||
mpr->color[3] = 0.5f;
|
||||
}
|
||||
|
||||
wmOperatorType *ot = WM_operatortype_find(info->opname, true);
|
||||
|
@ -182,13 +248,16 @@ static void WIDGETGROUP_navigate_draw_prepare(const bContext *C, wmManipulatorGr
|
|||
}
|
||||
|
||||
if ((navgroup->region_size[0] == ar->winx) &&
|
||||
(navgroup->region_size[1] == ar->winy))
|
||||
(navgroup->region_size[1] == ar->winy) &&
|
||||
(navgroup->is_persp == rv3d->is_persp))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
navgroup->region_size[0] = ar->winx;
|
||||
navgroup->region_size[1] = ar->winy;
|
||||
navgroup->is_persp = rv3d->is_persp;
|
||||
|
||||
|
||||
const float icon_size = MANIPULATOR_SIZE;
|
||||
const float icon_offset = (icon_size / 2.0) * MANIPULATOR_OFFSET_FAC * U.ui_scale;
|
||||
|
@ -208,7 +277,18 @@ static void WIDGETGROUP_navigate_draw_prepare(const bContext *C, wmManipulatorGr
|
|||
mpr->matrix_basis[3][0] = co[0] - icon_offset_mini;
|
||||
mpr->matrix_basis[3][1] = co[1] - icon_offset_mini;
|
||||
|
||||
mpr = navgroup->mpr_array[MPR_PERSP_ORTHO];
|
||||
if (rv3d->is_persp) {
|
||||
mpr = navgroup->mpr_array[MPR_PERSP];
|
||||
WM_manipulator_set_flag(mpr, WM_MANIPULATOR_HIDDEN, true);
|
||||
mpr = navgroup->mpr_array[MPR_ORTHO];
|
||||
WM_manipulator_set_flag(mpr, WM_MANIPULATOR_HIDDEN, false);
|
||||
}
|
||||
else {
|
||||
mpr = navgroup->mpr_array[MPR_ORTHO];
|
||||
WM_manipulator_set_flag(mpr, WM_MANIPULATOR_HIDDEN, true);
|
||||
mpr = navgroup->mpr_array[MPR_PERSP];
|
||||
WM_manipulator_set_flag(mpr, WM_MANIPULATOR_HIDDEN, false);
|
||||
}
|
||||
mpr->matrix_basis[3][0] = co[0] + icon_offset_mini;
|
||||
mpr->matrix_basis[3][1] = co[1] + icon_offset_mini;
|
||||
|
||||
|
|
Loading…
Reference in New Issue