Patch T37363: Highlight bone layers with active bones (as for Object Layers)

Patch by Jose Molina Garcia (sentinel), with style fixes by myself.
This commit is contained in:
Joshua Leung 2013-11-18 16:06:31 +13:00
parent 0ff70d942f
commit 4ea79fcdda
1 changed files with 29 additions and 4 deletions

View File

@ -54,6 +54,8 @@
#include "UI_interface.h"
#include "ED_armature.h"
#include "WM_api.h"
#include "WM_types.h"
@ -375,6 +377,7 @@ static void ui_item_array(uiLayout *layout, uiBlock *block, const char *name, in
int cols = (len >= 20) ? 2 : 1;
const unsigned int colbuts = len / (2 * cols);
unsigned int layer_used = 0;
unsigned int layer_active = 0;
uiBlockSetCurLayout(block, uiLayoutAbsolute(layout, FALSE));
@ -384,7 +387,15 @@ static void ui_item_array(uiLayout *layout, uiBlock *block, const char *name, in
if (ptr->type == &RNA_Armature) {
bArmature *arm = (bArmature *)ptr->data;
layer_used = arm->layer_used;
if (arm->edbo && arm->act_edbone) {
layer_active |= arm->act_edbone->layer;
}
else if (arm->act_bone) {
layer_active |= arm->act_bone->layer;
}
}
for (b = 0; b < cols; b++) {
@ -394,8 +405,15 @@ static void ui_item_array(uiLayout *layout, uiBlock *block, const char *name, in
int layer_num = a + b * colbuts;
int layer_flag = 1 << layer_num;
if (layer_used & layer_flag) icon = ICON_LAYER_USED;
else icon = ICON_BLANK1;
if (layer_used & layer_flag) {
if (layer_active & layer_flag)
icon = ICON_LAYER_ACTIVE;
else
icon = ICON_LAYER_USED;
}
else {
icon = ICON_BLANK1;
}
but = uiDefAutoButR(block, ptr, prop, layer_num, "", icon, x + butw * a, y + buth, butw, buth);
if (subtype == PROP_LAYER_MEMBER)
@ -405,8 +423,15 @@ static void ui_item_array(uiLayout *layout, uiBlock *block, const char *name, in
int layer_num = a + len / 2 + b * colbuts;
int layer_flag = 1 << layer_num;
if (layer_used & layer_flag) icon = ICON_LAYER_USED;
else icon = ICON_BLANK1;
if (layer_used & layer_flag) {
if (layer_active & layer_flag)
icon = ICON_LAYER_ACTIVE;
else
icon = ICON_LAYER_USED;
}
else {
icon = ICON_BLANK1;
}
but = uiDefAutoButR(block, ptr, prop, layer_num, "", icon, x + butw * a, y, butw, buth);
if (subtype == PROP_LAYER_MEMBER)