forked from bartvdbraak/blender
UI:
* Finished fixing the layer UI template. It's now used in the 3dview header rather than the custom layer grid.
This commit is contained in:
parent
7c21fa3b72
commit
46e1abeda7
@ -1878,6 +1878,25 @@ void uiTemplateTriColorSet(uiLayout *layout, PointerRNA *ptr, char *propname)
|
||||
|
||||
/********************* Layer Buttons Template ************************/
|
||||
|
||||
static void handle_layer_buttons(bContext *C, void *arg1, void *arg2)
|
||||
{
|
||||
uiBut *but = arg1;
|
||||
int cur = GET_INT_FROM_POINTER(arg2);
|
||||
wmWindow *win= CTX_wm_window(C);
|
||||
int i, tot, shift= win->eventstate->shift;
|
||||
|
||||
if(!shift) {
|
||||
tot= RNA_property_array_length(&but->rnapoin, but->rnaprop);
|
||||
|
||||
/* Normally clicking only selects one layer */
|
||||
RNA_property_boolean_set_index(&but->rnapoin, but->rnaprop, cur, 1);
|
||||
for(i = 0; i < tot; ++i) {
|
||||
if(i != cur)
|
||||
RNA_property_boolean_set_index(&but->rnapoin, but->rnaprop, i, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO:
|
||||
// - for now, grouping of layers is determined by dividing up the length of
|
||||
// the array of layer bitflags
|
||||
@ -1890,12 +1909,15 @@ void uiTemplateLayers(uiLayout *layout, PointerRNA *ptr, char *propname,
|
||||
int groups, cols, layers;
|
||||
int group, col, layer, row;
|
||||
int cols_per_group = 5;
|
||||
const char *desc;
|
||||
|
||||
prop= RNA_struct_find_property(ptr, propname);
|
||||
if (!prop) {
|
||||
printf("uiTemplateLayer: layers property not found: %s\n", propname);
|
||||
return;
|
||||
}
|
||||
|
||||
desc= RNA_property_description(prop);
|
||||
|
||||
/* the number of layers determines the way we group them
|
||||
* - we want 2 rows only (for now)
|
||||
@ -1924,19 +1946,26 @@ void uiTemplateLayers(uiLayout *layout, PointerRNA *ptr, char *propname,
|
||||
uCol= uiLayoutColumn(layout, 1);
|
||||
|
||||
for (row= 0; row < 2; row++) {
|
||||
uiBlock *block;
|
||||
uiBut *but;
|
||||
|
||||
uRow= uiLayoutRow(uCol, 1);
|
||||
block= uiLayoutGetBlock(uRow);
|
||||
layer= groups*cols_per_group*row + cols_per_group*group;
|
||||
|
||||
/* add layers as toggle buts */
|
||||
for (col= 0; (col < cols_per_group) && (layer < layers); col++, layer++) {
|
||||
int icon = 0;
|
||||
int butlay = 1 << layer;
|
||||
|
||||
if(active_layer & butlay)
|
||||
icon = ICON_LAYER_ACTIVE;
|
||||
else if(used_prop && RNA_property_boolean_get_index(used_ptr, used_prop, layer))
|
||||
icon = ICON_LAYER_USED;
|
||||
|
||||
uiItemFullR(uRow, "", icon, ptr, prop, layer, 0, UI_ITEM_R_TOGGLE);
|
||||
but= uiDefAutoButR(block, ptr, prop, layer, "", icon, 0, 0, 10, 10);
|
||||
uiButSetFunc(but, handle_layer_buttons, but, SET_INT_IN_POINTER(layer));
|
||||
but->type= TOG;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2004,32 +2004,11 @@ void uiTemplateHeader3D(uiLayout *layout, struct bContext *C)
|
||||
MEM_freeN(str_menu);
|
||||
}
|
||||
|
||||
/* LAYERS */
|
||||
if(obedit==NULL && v3d->localvd==NULL) {
|
||||
int ob_lay = ob ? ob->lay : 0;
|
||||
int a, xco = 0, yco = 0;
|
||||
|
||||
block= uiLayoutAbsoluteBlock(layout);
|
||||
uiBlockSetHandleFunc(block, do_view3d_header_buttons, NULL);
|
||||
|
||||
uiBlockBeginAlign(block);
|
||||
for(a=0; a<5; a++) {
|
||||
uiDefIconButBitI(block, TOG, 1<<a, B_LAY+a, view3d_layer_icon(1<<a, ob_lay, v3d->lay_used), (short)(xco+a*(XIC/2)), yco+(short)(YIC/2),(short)(XIC/2),(short)(YIC/2), &(v3d->lay), 0, 0, 0, 0, "Toggles Layer visibility (Alt Num, Alt Shift Num)");
|
||||
}
|
||||
for(a=0; a<5; a++) {
|
||||
uiDefIconButBitI(block, TOG, 1<<(a+10), B_LAY+10+a, view3d_layer_icon(1<<(a+10), ob_lay, v3d->lay_used), (short)(xco+a*(XIC/2)), yco, XIC/2, (YIC)/2, &(v3d->lay), 0, 0, 0, 0, "Toggles Layer visibility (Alt Num, Alt Shift Num)");
|
||||
}
|
||||
xco+= 5;
|
||||
uiBlockBeginAlign(block);
|
||||
for(a=5; a<10; a++) {
|
||||
uiDefIconButBitI(block, TOG, 1<<a, B_LAY+a, view3d_layer_icon(1<<a, ob_lay, v3d->lay_used), (short)(xco+a*(XIC/2)), yco+(short)(YIC/2),(short)(XIC/2),(short)(YIC/2), &(v3d->lay), 0, 0, 0, 0, "Toggles Layer visibility (Alt Num, Alt Shift Num)");
|
||||
}
|
||||
for(a=5; a<10; a++) {
|
||||
uiDefIconButBitI(block, TOG, 1<<(a+10), B_LAY+10+a, view3d_layer_icon(1<<(a+10), ob_lay, v3d->lay_used), (short)(xco+a*(XIC/2)), yco, XIC/2, (YIC)/2, &(v3d->lay), 0, 0, 0, 0, "Toggles Layer visibility (Alt Num, Alt Shift Num)");
|
||||
}
|
||||
uiBlockEndAlign(block);
|
||||
|
||||
xco+= (a-2)*(XIC/2)+3;
|
||||
/* Layers */
|
||||
uiTemplateLayers(layout, &sceneptr, "visible_layers", &v3dptr, "used_layers", ob_lay);
|
||||
|
||||
/* Scene lock */
|
||||
uiItemR(layout, "", 0, &v3dptr, "lock_camera_and_layers", UI_ITEM_R_ICON_ONLY);
|
||||
|
Loading…
Reference in New Issue
Block a user