Exemplo n.º 1
0
static void uiblock_layer_pass_arrow_buttons(uiLayout *layout, RenderResult *rr, ImageUser *iuser, short *render_slot)
{
	uiBlock *block = uiLayoutGetBlock(layout);
	uiLayout *row;
	uiBut *but;
	const float dpi_fac = UI_DPI_FAC;
	
	row = uiLayoutRow(layout, TRUE);

	if (rr == NULL || iuser == NULL)
		return;
	if (rr->layers.first == NULL) {
		uiItemL(row, IFACE_("No Layers in Render Result"), ICON_NONE);
		return;
	}

	/* decrease, increase arrows */
	but = uiDefIconBut(block, BUT, 0, ICON_TRIA_LEFT,   0, 0, 0.85f * UI_UNIT_X, UI_UNIT_Y, NULL, 0, 0, 0, 0, TIP_("Previous Layer"));
	uiButSetFunc(but, image_multi_declay_cb, rr, iuser);
	but = uiDefIconBut(block, BUT, 0, ICON_TRIA_RIGHT,  0, 0, 0.90f * UI_UNIT_X, UI_UNIT_Y, NULL, 0, 0, 0, 0, TIP_("Next Layer"));
	uiButSetFunc(but, image_multi_inclay_cb, rr, iuser);

	uiblock_layer_pass_buttons(row, rr, iuser, 230 * dpi_fac, render_slot);

	/* decrease, increase arrows */
	but = uiDefIconBut(block, BUT, 0, ICON_TRIA_LEFT,   0, 0, 0.85f * UI_UNIT_X, UI_UNIT_Y, NULL, 0, 0, 0, 0, TIP_("Previous Pass"));
	uiButSetFunc(but, image_multi_decpass_cb, rr, iuser);
	but = uiDefIconBut(block, BUT, 0, ICON_TRIA_RIGHT,  0, 0, 0.90f * UI_UNIT_X, UI_UNIT_Y, NULL, 0, 0, 0, 0, TIP_("Next Pass"));
	uiButSetFunc(but, image_multi_incpass_cb, rr, iuser);

	uiBlockEndAlign(block);
}
Exemplo n.º 2
0
void uiTemplateTextureShow(uiLayout *layout, bContext *C, PointerRNA *ptr, PropertyRNA *prop)
{
    /* button to quickly show texture in texture tab */
    SpaceButs *sbuts = CTX_wm_space_buts(C);
    ButsContextTexture *ct = (sbuts) ? sbuts->texuser : NULL;
    ButsTextureUser *user;

    /* only show button in other tabs in properties editor */
    if (!ct || sbuts->mainb == BCONTEXT_TEXTURE)
        return;

    /* find corresponding texture user */
    for (user = ct->users.first; user; user = user->next)
        if (user->ptr.data == ptr->data && user->prop == prop)
            break;

    /* draw button */
    if (user) {
        uiBlock *block = uiLayoutGetBlock(layout);
        uiBut *but;

        but = uiDefIconBut(block, BUT, 0, ICON_BUTS, 0, 0, UI_UNIT_X, UI_UNIT_Y,
                           NULL, 0.0, 0.0, 0.0, 0.0, "Show texture in texture tab");
        uiButSetFunc(but, template_texture_show, user->ptr.data, user->prop);
    }
}
Exemplo n.º 3
0
/* draw settings for envelope modifier */
static void draw_modifier__envelope(uiLayout *layout, ID *id, FModifier *fcm, short UNUSED(width))
{
	FMod_Envelope *env = (FMod_Envelope *)fcm->data;
	FCM_EnvelopeData *fed;
	uiLayout *col, *row;
	uiBlock *block;
	uiBut *but;
	PointerRNA ptr;
	int i;
	
	/* init the RNA-pointer */
	RNA_pointer_create(id, &RNA_FModifierEnvelope, fcm, &ptr);
	
	/* general settings */
	col = uiLayoutColumn(layout, TRUE);
	uiItemL(col, IFACE_("Envelope:"), ICON_NONE);
	uiItemR(col, &ptr, "reference_value", 0, NULL, ICON_NONE);

	row = uiLayoutRow(col, TRUE);
	uiItemR(row, &ptr, "default_min", 0, IFACE_("Min"), ICON_NONE);
	uiItemR(row, &ptr, "default_max", 0, IFACE_("Max"), ICON_NONE);

	/* control points header */
	/* TODO: move this control-point control stuff to using the new special widgets for lists
	 * the current way is far too cramped */
	row = uiLayoutRow(layout, FALSE);
	block = uiLayoutGetBlock(row);
		
	uiDefBut(block, LABEL, 1, IFACE_("Control Points:"), 0, 0, 7.5 * UI_UNIT_X, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, "");
		
	but = uiDefBut(block, BUT, B_FMODIFIER_REDRAW, IFACE_("Add Point"), 0, 0, 7.5 * UI_UNIT_X, UI_UNIT_Y,
	               NULL, 0, 0, 0, 0, TIP_("Add a new control-point to the envelope on the current frame"));
	uiButSetFunc(but, fmod_envelope_addpoint_cb, env, NULL);
		
	/* control points list */
	for (i = 0, fed = env->data; i < env->totvert; i++, fed++) {
		/* get a new row to operate on */
		row = uiLayoutRow(layout, TRUE);
		block = uiLayoutGetBlock(row);
		
		uiBlockBeginAlign(block);
		but = uiDefButF(block, NUM, B_FMODIFIER_REDRAW, IFACE_("Fra:"), 0, 0, 4.5 * UI_UNIT_X, UI_UNIT_Y,
		                &fed->time, -MAXFRAMEF, MAXFRAMEF, 10, 1, TIP_("Frame that envelope point occurs"));
		uiButSetFunc(but, validate_fmodifier_cb, fcm, NULL);
			
		uiDefButF(block, NUM, B_FMODIFIER_REDRAW, IFACE_("Min:"), 0, 0, 5 * UI_UNIT_X, UI_UNIT_Y,
		          &fed->min, -UI_FLT_MAX, UI_FLT_MAX, 10, 2, TIP_("Minimum bound of envelope at this point"));
		uiDefButF(block, NUM, B_FMODIFIER_REDRAW, IFACE_("Max:"), 0, 0, 5 * UI_UNIT_X, UI_UNIT_Y,
		          &fed->max, -UI_FLT_MAX, UI_FLT_MAX, 10, 2, TIP_("Maximum bound of envelope at this point"));

		but = uiDefIconBut(block, BUT, B_FMODIFIER_REDRAW, ICON_X, 0, 0, 0.9 * UI_UNIT_X, UI_UNIT_Y,
		                   NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Delete envelope control point"));
		uiButSetFunc(but, fmod_envelope_deletepoint_cb, env, SET_INT_IN_POINTER(i));
		uiBlockBeginAlign(block);
	}
}
Exemplo n.º 4
0
static void file_draw_icon(uiBlock *block, char *path, int sx, int sy, int icon, int width, int height)
{
	uiBut *but;
	int x, y;
	// float alpha = 1.0f;
	
	x = sx;
	y = sy - height;
	
	/*if (icon == ICON_FILE_BLANK) alpha = 0.375f;*/

	but = uiDefIconBut(block, LABEL, 0, icon, x, y, width, height, NULL, 0.0f, 0.0f, 0.0f, 0.0f, "");
	uiButSetDragPath(but, path);
}
Exemplo n.º 5
0
static void file_draw_icon(uiBlock *block, const char *path, int sx, int sy, int icon, int width, int height, bool drag)
{
	uiBut *but;
	int x, y;
	// float alpha = 1.0f;
	
	x = sx;
	y = sy - height;
	
	/*if (icon == ICON_FILE_BLANK) alpha = 0.375f;*/

	but = uiDefIconBut(block, UI_BTYPE_LABEL, 0, icon, x, y, width, height, NULL, 0.0f, 0.0f, 0.0f, 0.0f, "");

	if (drag) {
		UI_but_drag_set_path(but, path, false);
	}
}
Exemplo n.º 6
0
void ANIM_uiTemplate_fmodifier_draw(uiLayout *layout, ID *id, ListBase *modifiers, FModifier *fcm)
{
	FModifierTypeInfo *fmi = fmodifier_get_typeinfo(fcm);
	uiLayout *box, *row, *sub, *col;
	uiBlock *block;
	uiBut *but;
	short width = 314;
	PointerRNA ptr;
	
	/* init the RNA-pointer */
	RNA_pointer_create(id, &RNA_FModifier, fcm, &ptr);
	
	/* draw header */
	{
		/* get layout-row + UI-block for this */
		box = uiLayoutBox(layout);
		
		row = uiLayoutRow(box, FALSE);
		block = uiLayoutGetBlock(row); // err...
		
		/* left-align -------------------------------------------- */
		sub = uiLayoutRow(row, TRUE);
		uiLayoutSetAlignment(sub, UI_LAYOUT_ALIGN_LEFT);
		
		uiBlockSetEmboss(block, UI_EMBOSSN);
		
		/* expand */
		uiItemR(sub, &ptr, "show_expanded", UI_ITEM_R_ICON_ONLY, "", ICON_NONE);
		
		/* checkbox for 'active' status (for now) */
		uiItemR(sub, &ptr, "active", UI_ITEM_R_ICON_ONLY, "", ICON_NONE);
		
		/* name */
		if (fmi)
			uiItemL(sub, IFACE_(fmi->name), ICON_NONE);
		else
			uiItemL(sub, IFACE_("<Unknown Modifier>"), ICON_NONE);
		
		/* right-align ------------------------------------------- */
		sub = uiLayoutRow(row, TRUE);
		uiLayoutSetAlignment(sub, UI_LAYOUT_ALIGN_RIGHT);
		
		
		/* 'mute' button */
		uiItemR(sub, &ptr, "mute", UI_ITEM_R_ICON_ONLY, "", ICON_NONE);
		
		uiBlockSetEmboss(block, UI_EMBOSSN);
		
		/* delete button */
		but = uiDefIconBut(block, BUT, B_REDR, ICON_X, 0, 0, UI_UNIT_X, UI_UNIT_Y,
		                   NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Delete F-Curve Modifier"));
		uiButSetFunc(but, delete_fmodifier_cb, modifiers, fcm);
		
		uiBlockSetEmboss(block, UI_EMBOSS);
	}
	
	/* when modifier is expanded, draw settings */
	if (fcm->flag & FMODIFIER_FLAG_EXPANDED) {
		/* set up the flexible-box layout which acts as the backdrop for the modifier settings */
		box = uiLayoutBox(layout);
		
		/* draw settings for individual modifiers */
		switch (fcm->type) {
			case FMODIFIER_TYPE_GENERATOR: /* Generator */
				draw_modifier__generator(box, id, fcm, width);
				break;
				
			case FMODIFIER_TYPE_FN_GENERATOR: /* Built-In Function Generator */
				draw_modifier__fn_generator(box, id, fcm, width);
				break;
				
			case FMODIFIER_TYPE_CYCLES: /* Cycles */
				draw_modifier__cycles(box, id, fcm, width);
				break;
				
			case FMODIFIER_TYPE_ENVELOPE: /* Envelope */
				draw_modifier__envelope(box, id, fcm, width);
				break;
				
			case FMODIFIER_TYPE_LIMITS: /* Limits */
				draw_modifier__limits(box, id, fcm, width);
				break;
			
			case FMODIFIER_TYPE_NOISE: /* Noise */
				draw_modifier__noise(box, id, fcm, width);
				break;
				
			case FMODIFIER_TYPE_STEPPED: /* Stepped */
				draw_modifier__stepped(box, id, fcm, width);
				break;
			
			default: /* unknown type */
				break;
		}
		
		/* one last panel below this: FModifier range */
		// TODO: experiment with placement of this
		{
			box = uiLayoutBox(layout);
			
			/* restricted range ----------------------------------------------------- */
			col = uiLayoutColumn(box, TRUE);
			
			/* top row: use restricted range */
			row = uiLayoutRow(col, TRUE);
			uiItemR(row, &ptr, "use_restricted_range", 0, NULL, ICON_NONE);
			
			if (fcm->flag & FMODIFIER_FLAG_RANGERESTRICT) {
				/* second row: settings */
				row = uiLayoutRow(col, TRUE);
				
				uiItemR(row, &ptr, "frame_start", 0, IFACE_("Start"), ICON_NONE);
				uiItemR(row, &ptr, "frame_end", 0, IFACE_("End"), ICON_NONE);
				
				/* third row: blending influence */
				row = uiLayoutRow(col, TRUE);
				
				uiItemR(row, &ptr, "blend_in", 0, IFACE_("In"), ICON_NONE);
				uiItemR(row, &ptr, "blend_out", 0, IFACE_("Out"), ICON_NONE);
			}
			
			/* influence -------------------------------------------------------------- */
			col = uiLayoutColumn(box, TRUE);
			
			/* top row: use influence */
			uiItemR(col, &ptr, "use_influence", 0, NULL, ICON_NONE);
			
			if (fcm->flag & FMODIFIER_FLAG_USEINFLUENCE) {
				/* second row: influence value */
				uiItemR(col, &ptr, "influence", 0, NULL, ICON_NONE);
			}
		}
	}
}
Exemplo n.º 7
0
/* driver settings for active F-Curve (only for 'Drivers' mode) */
static void graph_panel_drivers(const bContext *C, Panel *pa)
{
	bAnimListElem *ale;
	FCurve *fcu;
	ChannelDriver *driver;
	DriverVar *dvar;
	
	PointerRNA driver_ptr;
	uiLayout *col;
	uiBlock *block;
	uiBut *but;
	
	/* Get settings from context */
	if (!graph_panel_context(C, &ale, &fcu))
		return;
	driver = fcu->driver;
	
	/* set event handler for panel */
	block = uiLayoutGetBlock(pa->layout); // xxx?
	uiBlockSetHandleFunc(block, do_graph_region_driver_buttons, NULL);
	
	/* general actions - management */
	col = uiLayoutColumn(pa->layout, FALSE);
	block = uiLayoutGetBlock(col);
	but = uiDefBut(block, BUT, B_IPO_DEPCHANGE, IFACE_("Update Dependencies"), 0, 0, 10 * UI_UNIT_X, 22,
	               NULL, 0.0, 0.0, 0, 0, TIP_("Force updates of dependencies"));
	uiButSetFunc(but, driver_update_flags_cb, fcu, NULL);

	but = uiDefBut(block, BUT, B_IPO_DEPCHANGE, IFACE_("Remove Driver"), 0, 0, 10 * UI_UNIT_X, 18,
	               NULL, 0.0, 0.0, 0, 0, TIP_("Remove this driver"));
	uiButSetNFunc(but, driver_remove_cb, MEM_dupallocN(ale), NULL);
		
	/* driver-level settings - type, expressions, and errors */
	RNA_pointer_create(ale->id, &RNA_Driver, driver, &driver_ptr);
	
	col = uiLayoutColumn(pa->layout, TRUE);
	block = uiLayoutGetBlock(col);
	uiItemR(col, &driver_ptr, "type", 0, NULL, ICON_NONE);

	/* show expression box if doing scripted drivers, and/or error messages when invalid drivers exist */
	if (driver->type == DRIVER_TYPE_PYTHON) {
		/* expression */
		uiItemR(col, &driver_ptr, "expression", 0, IFACE_("Expr"), ICON_NONE);

		/* errors? */
		if (driver->flag & DRIVER_FLAG_INVALID)
			uiItemL(col, IFACE_("ERROR: invalid Python expression"), ICON_ERROR);
	}
	else {
		/* errors? */
		if (driver->flag & DRIVER_FLAG_INVALID)
			uiItemL(col, IFACE_("ERROR: invalid target channel(s)"), ICON_ERROR);
	}
		
	col = uiLayoutColumn(pa->layout, TRUE);
	/* debug setting */
	uiItemR(col, &driver_ptr, "show_debug_info", 0, NULL, ICON_NONE);
		
	/* value of driver */
	if (driver->flag & DRIVER_FLAG_SHOWDEBUG) {
		uiLayout *row = uiLayoutRow(col, TRUE);
		char valBuf[32];
			
		uiItemL(row, IFACE_("Driver Value:"), ICON_NONE);
			
		BLI_snprintf(valBuf, sizeof(valBuf), "%.3f", driver->curval);
		uiItemL(row, valBuf, ICON_NONE);
	}
	
	/* add driver variables */
	col = uiLayoutColumn(pa->layout, FALSE);
	block = uiLayoutGetBlock(col);
	but = uiDefBut(block, BUT, B_IPO_DEPCHANGE, IFACE_("Add Variable"), 0, 0, 10 * UI_UNIT_X, UI_UNIT_Y,
	               NULL, 0.0, 0.0, 0, 0, TIP_("Add a new target variable for this Driver"));
	uiButSetFunc(but, driver_add_var_cb, driver, NULL);
	
	/* loop over targets, drawing them */
	for (dvar = driver->variables.first; dvar; dvar = dvar->next) {
		PointerRNA dvar_ptr;
		uiLayout *box, *row;
		
		/* sub-layout column for this variable's settings */
		col = uiLayoutColumn(pa->layout, TRUE);
		
		/* header panel */
		box = uiLayoutBox(col);
		/* first row context info for driver */
		RNA_pointer_create(ale->id, &RNA_DriverVariable, dvar, &dvar_ptr);

		row = uiLayoutRow(box, FALSE);
		block = uiLayoutGetBlock(row);
		/* variable name */
		uiItemR(row, &dvar_ptr, "name", 0, "", ICON_NONE);

		/* remove button */
		uiBlockSetEmboss(block, UI_EMBOSSN);
		but = uiDefIconBut(block, BUT, B_IPO_DEPCHANGE, ICON_X, 290, 0, UI_UNIT_X, UI_UNIT_Y,
		                   NULL, 0.0, 0.0, 0.0, 0.0, IFACE_("Delete target variable"));
		uiButSetFunc(but, driver_delete_var_cb, driver, dvar);
		uiBlockSetEmboss(block, UI_EMBOSS);

		/* variable type */
		row = uiLayoutRow(box, FALSE);
		uiItemR(row, &dvar_ptr, "type", 0, "", ICON_NONE);
				
		/* variable type settings */
		box = uiLayoutBox(col);
		/* controls to draw depends on the type of variable */
		switch (dvar->type) {
			case DVAR_TYPE_SINGLE_PROP:     /* single property */
				graph_panel_driverVar__singleProp(box, ale->id, dvar);
				break;
			case DVAR_TYPE_ROT_DIFF:     /* rotational difference */
				graph_panel_driverVar__rotDiff(box, ale->id, dvar);
				break;
			case DVAR_TYPE_LOC_DIFF:     /* location difference */
				graph_panel_driverVar__locDiff(box, ale->id, dvar);
				break;
			case DVAR_TYPE_TRANSFORM_CHAN:     /* transform channel */
				graph_panel_driverVar__transChan(box, ale->id, dvar);
				break;
		}

		/* value of variable */
		if (driver->flag & DRIVER_FLAG_SHOWDEBUG) {
			char valBuf[32];

			box = uiLayoutBox(col);
			row = uiLayoutRow(box, TRUE);
			uiItemL(row, IFACE_("Value:"), ICON_NONE);

			BLI_snprintf(valBuf, sizeof(valBuf), "%.3f", dvar->curval);
			uiItemL(row, valBuf, ICON_NONE);
		}
	}
	
	/* cleanup */
	MEM_freeN(ale);
}
Exemplo n.º 8
0
/* /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// */
static void mat_livedb_draw_tree_element(bContext *C, uiBlock *block, ARegion *ar, SpaceLDB *slivedb, LiveDbTreeElement *te, int startx, int *starty, int *row_num)
{
    LiveDbTreeElement   *ten;
    float               ufac = UI_UNIT_X / 20.0f;
    int                 offsx = 0, active = 0;
    int                 CUR_UNIT_Y;

    if(TE_GET_TYPE(te->item->type) == MAT_LDB_TREE_ITEM_TYPE_CATEGORY)
        CUR_UNIT_Y = UI_UNIT_Y;
    else
        CUR_UNIT_Y = MAT_LIVEDB_UI_UNIT_Y;

    *starty -= CUR_UNIT_Y;
    ++ *row_num;

    if (*starty + 2 * CUR_UNIT_Y >= ar->v2d.cur.ymin && *starty <= ar->v2d.cur.ymax) {
        int xmax = ar->v2d.cur.xmax;
        unsigned char alpha = 128;

        /* icons can be ui buts, we don't want it to overlap with material previews */
        if(TE_GET_TYPE(te->item->type) == MAT_LDB_TREE_ITEM_TYPE_MATERIAL)
            xmax -= MAT_LIVEDB_UI_UNIT_Y;

        glEnable(GL_BLEND);

        if(*row_num % 2) {
            UI_ThemeColorShade(TH_BACK, 6);
            glRecti(0, *starty + 1, ar->v2d.cur.xmax, *starty + CUR_UNIT_Y - 1);
        }

        if (*te->flag & TE_SELECTED) {
            float           col[4];
            unsigned char   col_circle[4];

            UI_GetThemeColor3fv(TH_SELECT_HIGHLIGHT, col);
            glColor3fv(col);
            glRecti(0, *starty + 1, (int)ar->v2d.cur.xmax, *starty + CUR_UNIT_Y - 1);

            /* active circle */
            UI_GetThemeColorType4ubv(TH_ACTIVE, SPACE_VIEW3D, col_circle);
            col_circle[3] = alpha;
            glColor4ubv((GLubyte *)col_circle);

            UI_draw_roundbox_corner_set(UI_CNR_ALL);
            UI_draw_roundbox((float)startx + UI_UNIT_X - ufac,
                       (float)*starty + (TE_GET_TYPE(te->item->type) == MAT_LDB_TREE_ITEM_TYPE_CATEGORY ? 1.0f : UI_UNIT_Y * 3),
                       (float)startx + 2.0f * UI_UNIT_X - 2.0f * ufac,
                       (float)*starty + CUR_UNIT_Y - 1.0f * ufac,
                       UI_UNIT_Y / 2.0f - 1.0f * ufac);
            glEnable(GL_BLEND); /* roundbox disables it */
        }

        /* start by highlighting search matches */
        if (SEARCHING_MAT_LIVEDB(slivedb) && (*te->flag & TE_SEARCHMATCH))
        {
            char col[4];
            UI_GetThemeColorType4ubv(TH_MATCH, SPACE_MAT_LIVEDB, col);
            col[3] = alpha;
            glColor4ubv((GLubyte *)col);
            glRecti(startx, *starty + 1, ar->v2d.cur.xmax, *starty + CUR_UNIT_Y - 1);
        }

        /* open/close icon, only when sublevels */
        if (te->subtree.first || (*te->flag & TE_LAZY_CLOSED)) {
            int icon_x;
            if (TE_GET_TYPE(te->item->type) == MAT_LDB_TREE_ITEM_TYPE_CATEGORY)
                icon_x = startx;
            else
                icon_x = startx + 5 * ufac;

            if (MAT_LIVEDB_ELEM_OPEN(te, slivedb))
                UI_icon_draw((float)icon_x, (float)*starty + 2 * ufac, ICON_DISCLOSURE_TRI_DOWN);
            else
                UI_icon_draw((float)icon_x, (float)*starty + 2 * ufac, ICON_DISCLOSURE_TRI_RIGHT);
        }
        offsx += UI_UNIT_X;

        /* Element type icon */
        if(TE_GET_TYPE(te->item->type) == MAT_LDB_TREE_ITEM_TYPE_CATEGORY)
            mat_livedb_elem_draw_icon((float)startx + offsx, (float)*starty, te);
        else
            mat_livedb_elem_draw_icon((float)startx + offsx, (float)*starty + UI_UNIT_X * 3, te);

        offsx += UI_UNIT_X;

        glDisable(GL_BLEND);

        /* name */
        if (active == 1) UI_ThemeColor(TH_TEXT_HI);
        else UI_ThemeColor(TH_TEXT);

        if(TE_GET_TYPE(te->item->type) == MAT_LDB_TREE_ITEM_TYPE_CATEGORY)
            UI_fontstyle_draw_simple(UI_FSTYLE_WIDGET, startx + offsx, *starty + 5 * ufac, te->name);
        else {
            uiBut *bt;

            UI_fontstyle_draw_simple(UI_FSTYLE_WIDGET, startx + offsx, *starty + UI_UNIT_X * 3 + 5 * ufac, te->name);
            UI_fontstyle_draw_simple(UI_FSTYLE_WIDGET, startx + offsx, *starty + UI_UNIT_X * 2 + 5 * ufac, te->nick_name);
            UI_fontstyle_draw_simple(UI_FSTYLE_WIDGET, startx + offsx, *starty + UI_UNIT_X + 5 * ufac, te->copyright);

            bt = uiDefIconBut(block, UI_BTYPE_ICON_TOGGLE, 0, ICON_WORLD,
                                xmax - UI_UNIT_X - 3, *starty + 1 * ufac, UI_UNIT_X, UI_UNIT_Y,
                                NULL, 0.0, 0.0, 1.0, 0.5f, "Get item");
            UI_but_func_set(bt, get_material_cb, (void*)slivedb->server_address, (void*)te->item->mat_item.id);
            UI_but_flag_enable(bt, UI_BUT_DRAG_LOCK);
        }

        offsx += (int)(UI_UNIT_X + UI_fontstyle_string_width(UI_FSTYLE_WIDGET, te->name));

        /* Closed item, we draw the category-info icons */
        if (TE_GET_TYPE(te->item->type) == MAT_LDB_TREE_ITEM_TYPE_CATEGORY && !MAT_LIVEDB_ELEM_OPEN(te, slivedb)) {
            if (te->subtree.first) {
                int tempx = startx + offsx;

                /* divider */
                UI_ThemeColorShade(TH_BACK, -40);
                glRecti(tempx   - 10.0f * ufac,
                        *starty +  4.0f * ufac,
                        tempx   -  8.0f * ufac,
                        *starty + CUR_UNIT_Y - 4.0f * ufac);

                glEnable(GL_BLEND);
                glPixelTransferf(GL_ALPHA_SCALE, 0.5);

                mat_livedb_draw_content_count_icons(&te->subtree, xmax, &tempx, *starty);

                glPixelTransferf(GL_ALPHA_SCALE, 1.0);
                glDisable(GL_BLEND);
            }
        }
    }
    /* store coord and continue, we need coordinates for elements outside view too */
    te->xs   = (float)startx;
    te->ys   = (float)*starty;
    te->xend = startx + offsx;

    if (MAT_LIVEDB_ELEM_OPEN(te, slivedb)) {
        for (ten = te->subtree.first; ten; ten = ten->next)
            mat_livedb_draw_tree_element(C, block, ar, slivedb, ten, startx + UI_UNIT_X, starty, row_num);
    }
    else {
        for (ten = te->subtree.first; ten; ten = ten->next)
            mat_livedb_set_coord_tree_element(slivedb, te, startx, starty);
    }
} /* mat_livedb_draw_tree_element() */
Exemplo n.º 9
0
/* draw the controls for a given layer */
static void gp_drawui_layer(uiLayout *layout, bGPdata *gpd, bGPDlayer *gpl, const short is_v3d)
{
	uiLayout *box = NULL, *split = NULL;
	uiLayout *col = NULL;
	uiLayout *row = NULL, *sub = NULL;
	uiBlock *block;
	uiBut *but;
	PointerRNA ptr;
	int icon;
	
	/* make pointer to layer data */
	RNA_pointer_create((ID *)gpd, &RNA_GPencilLayer, gpl, &ptr);
	
	/* unless button has own callback, it adds this callback to button */
	block = uiLayoutGetBlock(layout);
	uiBlockSetFunc(block, gp_ui_activelayer_cb, gpd, gpl);
	
	/* draw header ---------------------------------- */
	/* get layout-row + UI-block for header */
	box = uiLayoutBox(layout);
	
	row = uiLayoutRow(box, FALSE);
	uiLayoutSetAlignment(row, UI_LAYOUT_ALIGN_EXPAND);
	block = uiLayoutGetBlock(row); /* err... */
	
	uiBlockSetEmboss(block, UI_EMBOSSN);
	
	/* left-align ............................... */
	sub = uiLayoutRow(row, FALSE);
	
	/* active */
	block = uiLayoutGetBlock(sub);
	icon = (gpl->flag & GP_LAYER_ACTIVE) ? ICON_RADIOBUT_ON : ICON_RADIOBUT_OFF;
	but = uiDefIconButBitI(block, TOG, GP_LAYER_ACTIVE, 0, icon, 0, 0, UI_UNIT_X, UI_UNIT_Y,
	                       &gpl->flag, 0.0, 0.0, 0.0, 0.0, TIP_("Set active layer"));
	uiButSetFunc(but, gp_ui_activelayer_cb, gpd, gpl);
	
	/* locked */
	icon = (gpl->flag & GP_LAYER_LOCKED) ? ICON_LOCKED : ICON_UNLOCKED;
	uiItemR(sub, &ptr, "lock", 0, "", icon);
	
	/* when layer is locked or hidden, only draw header */
	if (gpl->flag & (GP_LAYER_LOCKED | GP_LAYER_HIDE)) {
		char name[256]; /* gpl->info is 128, but we need space for 'locked/hidden' as well */
		
		/* visibility button (only if hidden but not locked!) */
		if ((gpl->flag & GP_LAYER_HIDE) && !(gpl->flag & GP_LAYER_LOCKED))
			uiItemR(sub, &ptr, "hide", 0, "", ICON_RESTRICT_VIEW_ON);
		
		/* name */
		if (gpl->flag & GP_LAYER_HIDE)
			BLI_snprintf(name, sizeof(name), IFACE_("%s (Hidden)"), gpl->info);
		else
			BLI_snprintf(name, sizeof(name), IFACE_("%s (Locked)"), gpl->info);
		uiItemL(sub, name, ICON_NONE);
		
		/* delete button (only if hidden but not locked!) */
		if ((gpl->flag & GP_LAYER_HIDE) && !(gpl->flag & GP_LAYER_LOCKED)) {
			/* right-align ............................... */
			sub = uiLayoutRow(row, TRUE);
			uiLayoutSetAlignment(sub, UI_LAYOUT_ALIGN_RIGHT);
			block = uiLayoutGetBlock(sub); /* XXX... err... */
			
			but = uiDefIconBut(block, BUT, 0, ICON_X, 0, 0, UI_UNIT_X, UI_UNIT_Y,
			                   NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Delete layer"));
			uiButSetFunc(but, gp_ui_dellayer_cb, gpd, gpl);
		}
		uiBlockSetEmboss(block, UI_EMBOSS);
	}
	else {
		/* draw rest of header -------------------------------- */
		/* visibility button */
		uiItemR(sub, &ptr, "hide", 0, "", ICON_RESTRICT_VIEW_OFF);
		
		/* frame locking */
		/* TODO: this needs its own icons... */
		icon = (gpl->flag & GP_LAYER_FRAMELOCK) ? ICON_RENDER_STILL : ICON_RENDER_ANIMATION;
		uiItemR(sub, &ptr, "lock_frame", 0, "", icon);
		
		uiBlockSetEmboss(block, UI_EMBOSS);
		
		/* name */
		uiItemR(sub, &ptr, "info", 0, "", ICON_NONE);
		
		/* move up/down */
		uiBlockBeginAlign(block);
		
		if (gpl->prev) {
			but = uiDefIconBut(block, BUT, 0, ICON_TRIA_UP, 0, 0, UI_UNIT_X, UI_UNIT_Y,
			                   NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Move layer up"));
			uiButSetFunc(but, gp_ui_layer_up_cb, gpd, gpl);
		}
		if (gpl->next) {
			but = uiDefIconBut(block, BUT, 0, ICON_TRIA_DOWN, 0, 0, UI_UNIT_X, UI_UNIT_Y,
			                   NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Move layer down"));
			uiButSetFunc(but, gp_ui_layer_down_cb, gpd, gpl);
		}
		
		uiBlockEndAlign(block);
		
		/* delete 'button' */
		uiBlockSetEmboss(block, UI_EMBOSSN);
		/* right-align ............................... */
		sub = uiLayoutRow(row, TRUE);
		uiLayoutSetAlignment(sub, UI_LAYOUT_ALIGN_RIGHT);
		block = uiLayoutGetBlock(sub); /* XXX... err... */
		
		but = uiDefIconBut(block, BUT, 0, ICON_X, 0, 0, UI_UNIT_X, UI_UNIT_Y,
		                   NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Delete layer"));
		uiButSetFunc(but, gp_ui_dellayer_cb, gpd, gpl);
		uiBlockSetEmboss(block, UI_EMBOSS);
		
		/* new backdrop ----------------------------------- */
		box = uiLayoutBox(layout);
		split = uiLayoutSplit(box, 0.5f, FALSE);
		
		/* draw settings ---------------------------------- */
		/* left column ..................... */
		col = uiLayoutColumn(split, FALSE);
		
		/* color */
		sub = uiLayoutColumn(col, TRUE);
		uiItemR(sub, &ptr, "color", 0, "", ICON_NONE);
		uiItemR(sub, &ptr, "alpha", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
		
		/* stroke thickness */
		uiItemR(col, &ptr, "line_width", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
		
		/* debugging options */
		if (G.debug & G_DEBUG) {
			uiItemR(col, &ptr, "show_points", 0, NULL, ICON_NONE);
		}
		
		/* right column ................... */
		col = uiLayoutColumn(split, FALSE);
		
		/* onion-skinning */
		sub = uiLayoutColumn(col, TRUE);
		uiItemR(sub, &ptr, "use_onion_skinning", 0, NULL, ICON_NONE);
		uiItemR(sub, &ptr, "ghost_range_max", 0, IFACE_("Frames"), ICON_NONE);
		
		/* 3d-view specific drawing options */
		if (is_v3d) {
			uiItemR(col, &ptr, "show_x_ray", 0, NULL, ICON_NONE);
		}
	}
}
Exemplo n.º 10
0
/* driver settings for active F-Curve (only for 'Drivers' mode) */
static void graph_panel_drivers(const bContext *C, Panel *pa)
{
	bAnimListElem *ale;
	FCurve *fcu;
	ChannelDriver *driver;
	DriverVar *dvar;
	
	PointerRNA driver_ptr;
	uiLayout *col;
	uiBlock *block;
	uiBut *but;
	
	/* Get settings from context */
	if (!graph_panel_context(C, &ale, &fcu))
		return;
	driver = fcu->driver;
	
	/* set event handler for panel */
	block = uiLayoutGetBlock(pa->layout); // xxx?
	uiBlockSetHandleFunc(block, do_graph_region_driver_buttons, NULL);
	
	/* general actions - management */
	col = uiLayoutColumn(pa->layout, false);
	block = uiLayoutGetBlock(col);
	but = uiDefIconTextBut(block, BUT, B_IPO_DEPCHANGE, ICON_FILE_REFRESH, IFACE_("Update Dependencies"),
	               0, 0, 10 * UI_UNIT_X, 22,
	               NULL, 0.0, 0.0, 0, 0,
	               TIP_("Force updates of dependencies"));
	uiButSetFunc(but, driver_update_flags_cb, fcu, NULL);

	but = uiDefIconTextBut(block, BUT, B_IPO_DEPCHANGE, ICON_ZOOMOUT, IFACE_("Remove Driver"),
	               0, 0, 10 * UI_UNIT_X, 18,
	               NULL, 0.0, 0.0, 0, 0,
	               TIP_("Remove this driver"));
	uiButSetNFunc(but, driver_remove_cb, MEM_dupallocN(ale), NULL);
		
	/* driver-level settings - type, expressions, and errors */
	RNA_pointer_create(ale->id, &RNA_Driver, driver, &driver_ptr);
	
	col = uiLayoutColumn(pa->layout, true);
	block = uiLayoutGetBlock(col);
	uiItemR(col, &driver_ptr, "type", 0, NULL, ICON_NONE);

	/* show expression box if doing scripted drivers, and/or error messages when invalid drivers exist */
	if (driver->type == DRIVER_TYPE_PYTHON) {
		bool bpy_data_expr_error = (strstr(driver->expression, "bpy.data.") != NULL);
		bool bpy_ctx_expr_error  = (strstr(driver->expression, "bpy.context.") != NULL);
		
		/* expression */
		uiItemR(col, &driver_ptr, "expression", 0, IFACE_("Expr"), ICON_NONE);
		
		/* errors? */
		if ((G.f & G_SCRIPT_AUTOEXEC) == 0) {
			uiItemL(col, IFACE_("ERROR: Python auto-execution disabled"), ICON_CANCEL);
		}
		else if (driver->flag & DRIVER_FLAG_INVALID) {
			uiItemL(col, IFACE_("ERROR: Invalid Python expression"), ICON_CANCEL);
		}
		
		/* Explicit bpy-references are evil. Warn about these to prevent errors */
		/* TODO: put these in a box? */
		if (bpy_data_expr_error || bpy_ctx_expr_error) {
			uiItemL(col, IFACE_("WARNING: Driver expression may not work correctly"), ICON_HELP);
			
			if (bpy_data_expr_error) {
				uiItemL(col, IFACE_("TIP: Use variables instead of bpy.data paths (see below)"), ICON_ERROR);
			}
			if (bpy_ctx_expr_error) {
				uiItemL(col, IFACE_("TIP: bpy.context is not safe for renderfarm usage"), ICON_ERROR);
			}
		}
	}
	else {
		/* errors? */
		if (driver->flag & DRIVER_FLAG_INVALID)
			uiItemL(col, IFACE_("ERROR: Invalid target channel(s)"), ICON_ERROR);
			
		/* Warnings about a lack of variables
		 * NOTE: The lack of variables is generally a bad thing, since it indicates
		 *       that the driver doesn't work at all. This particular scenario arises
		 *       primarily when users mistakenly try to use drivers for procedural
		 *       property animation
		 */
		if (BLI_listbase_is_empty(&driver->variables)) {
			uiItemL(col, IFACE_("ERROR: Driver is useless without any inputs"), ICON_ERROR);
			
			if (!BLI_listbase_is_empty(&fcu->modifiers)) {
				uiItemL(col, IFACE_("TIP: Use F-Curves for procedural animation instead"), ICON_INFO);
				uiItemL(col, IFACE_("F-Modifiers can generate curves for those too"), ICON_INFO);
			}
		}
	}
		
	col = uiLayoutColumn(pa->layout, true);
	/* debug setting */
	uiItemR(col, &driver_ptr, "show_debug_info", 0, NULL, ICON_NONE);
		
	/* value of driver */
	if (driver->flag & DRIVER_FLAG_SHOWDEBUG) {
		uiLayout *row = uiLayoutRow(col, true);
		char valBuf[32];
			
		uiItemL(row, IFACE_("Driver Value:"), ICON_NONE);
			
		BLI_snprintf(valBuf, sizeof(valBuf), "%.3f", driver->curval);
		uiItemL(row, valBuf, ICON_NONE);
	}
	
	/* add driver variables */
	col = uiLayoutColumn(pa->layout, false);
	block = uiLayoutGetBlock(col);
	but = uiDefIconTextBut(block, BUT, B_IPO_DEPCHANGE, ICON_ZOOMIN, IFACE_("Add Variable"),
	               0, 0, 10 * UI_UNIT_X, UI_UNIT_Y,
	               NULL, 0.0, 0.0, 0, 0,
	               TIP_("Driver variables ensure that all dependencies will be accounted for and that drivers will update correctly"));
	uiButSetFunc(but, driver_add_var_cb, driver, NULL);
	
	/* loop over targets, drawing them */
	for (dvar = driver->variables.first; dvar; dvar = dvar->next) {
		PointerRNA dvar_ptr;
		uiLayout *box, *row;
		
		/* sub-layout column for this variable's settings */
		col = uiLayoutColumn(pa->layout, true);
		
		/* header panel */
		box = uiLayoutBox(col);
		/* first row context info for driver */
		RNA_pointer_create(ale->id, &RNA_DriverVariable, dvar, &dvar_ptr);
		
		row = uiLayoutRow(box, false);
		block = uiLayoutGetBlock(row);
		/* variable name */
		uiItemR(row, &dvar_ptr, "name", 0, "", ICON_NONE);
		
		/* remove button */
		uiBlockSetEmboss(block, UI_EMBOSSN);
		but = uiDefIconBut(block, BUT, B_IPO_DEPCHANGE, ICON_X, 290, 0, UI_UNIT_X, UI_UNIT_Y,
		                   NULL, 0.0, 0.0, 0.0, 0.0, IFACE_("Delete target variable"));
		uiButSetFunc(but, driver_delete_var_cb, driver, dvar);
		uiBlockSetEmboss(block, UI_EMBOSS);
		
		/* variable type */
		row = uiLayoutRow(box, false);
		uiItemR(row, &dvar_ptr, "type", 0, "", ICON_NONE);
				
		/* variable type settings */
		box = uiLayoutBox(col);
		/* controls to draw depends on the type of variable */
		switch (dvar->type) {
			case DVAR_TYPE_SINGLE_PROP:     /* single property */
				graph_panel_driverVar__singleProp(box, ale->id, dvar);
				break;
			case DVAR_TYPE_ROT_DIFF:     /* rotational difference */
				graph_panel_driverVar__rotDiff(box, ale->id, dvar);
				break;
			case DVAR_TYPE_LOC_DIFF:     /* location difference */
				graph_panel_driverVar__locDiff(box, ale->id, dvar);
				break;
			case DVAR_TYPE_TRANSFORM_CHAN:     /* transform channel */
				graph_panel_driverVar__transChan(box, ale->id, dvar);
				break;
		}
		
		/* value of variable */
		if (driver->flag & DRIVER_FLAG_SHOWDEBUG) {
			char valBuf[32];
			
			box = uiLayoutBox(col);
			row = uiLayoutRow(box, true);
			uiItemL(row, IFACE_("Value:"), ICON_NONE);
			
			if ((dvar->type == DVAR_TYPE_ROT_DIFF) ||
			    (dvar->type == DVAR_TYPE_TRANSFORM_CHAN &&
			     dvar->targets[0].transChan >= DTAR_TRANSCHAN_ROTX &&
			     dvar->targets[0].transChan < DTAR_TRANSCHAN_SCALEX))
			{
				BLI_snprintf(valBuf, sizeof(valBuf), "%.3f (%4.1f°)", dvar->curval, RAD2DEGF(dvar->curval));
			}
			else {
				BLI_snprintf(valBuf, sizeof(valBuf), "%.3f", dvar->curval);
			}
			
			uiItemL(row, valBuf, ICON_NONE);
		}
	}
	
	/* cleanup */
	MEM_freeN(ale);
}
Exemplo n.º 11
0
void ANIM_uiTemplate_fmodifier_draw (uiLayout *layout, ID *id, ListBase *modifiers, FModifier *fcm)
{
	FModifierTypeInfo *fmi= fmodifier_get_typeinfo(fcm);
	uiLayout *box, *row, *subrow;
	uiBlock *block;
	uiBut *but;
	short width= 314;
	PointerRNA ptr;
	
	/* init the RNA-pointer */
	RNA_pointer_create(id, &RNA_FModifier, fcm, &ptr);
	
	/* draw header */
	{
		/* get layout-row + UI-block for this */
		box= uiLayoutBox(layout);
		
		row= uiLayoutRow(box, 0);
		block= uiLayoutGetBlock(row); // err...
		
		/* left-align -------------------------------------------- */
		subrow= uiLayoutRow(row, 0);
		uiLayoutSetAlignment(subrow, UI_LAYOUT_ALIGN_LEFT);
		
		uiBlockSetEmboss(block, UI_EMBOSSN);
		
		/* expand */
		uiItemR(subrow, &ptr, "show_expanded", UI_ITEM_R_ICON_ONLY, "", ICON_NONE);
		
		/* checkbox for 'active' status (for now) */
		uiItemR(subrow, &ptr, "active", UI_ITEM_R_ICON_ONLY, "", ICON_NONE);
		
		/* name */
		if (fmi)
			uiItemL(subrow, fmi->name, ICON_NONE);
		else
			uiItemL(subrow, "<Unknown Modifier>", ICON_NONE);
		
		/* right-align ------------------------------------------- */
		subrow= uiLayoutRow(row, 0);
		uiLayoutSetAlignment(subrow, UI_LAYOUT_ALIGN_RIGHT);
		
		
		/* 'mute' button */
		uiItemR(subrow, &ptr, "mute", UI_ITEM_R_ICON_ONLY, "", ICON_NONE);
		
		uiBlockSetEmboss(block, UI_EMBOSSN);
		
		/* delete button */
		but= uiDefIconBut(block, BUT, B_REDR, ICON_X, 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL, 0.0, 0.0, 0.0, 0.0, "Delete F-Curve Modifier.");
		uiButSetFunc(but, delete_fmodifier_cb, modifiers, fcm);
		
		uiBlockSetEmboss(block, UI_EMBOSS);
	}
	
	/* when modifier is expanded, draw settings */
	if (fcm->flag & FMODIFIER_FLAG_EXPANDED) {
		/* set up the flexible-box layout which acts as the backdrop for the modifier settings */
		box= uiLayoutBox(layout); 
		
		/* draw settings for individual modifiers */
		switch (fcm->type) {
			case FMODIFIER_TYPE_GENERATOR: /* Generator */
				draw_modifier__generator(box, id, fcm, width);
				break;
				
			case FMODIFIER_TYPE_FN_GENERATOR: /* Built-In Function Generator */
				draw_modifier__fn_generator(box, id, fcm, width);
				break;
				
			case FMODIFIER_TYPE_CYCLES: /* Cycles */
				draw_modifier__cycles(box, id, fcm, width);
				break;
				
			case FMODIFIER_TYPE_ENVELOPE: /* Envelope */
				draw_modifier__envelope(box, id, fcm, width);
				break;
				
			case FMODIFIER_TYPE_LIMITS: /* Limits */
				draw_modifier__limits(box, id, fcm, width);
				break;
			
			case FMODIFIER_TYPE_NOISE: /* Noise */
				draw_modifier__noise(box, id, fcm, width);
				break;
				
			case FMODIFIER_TYPE_STEPPED: /* Stepped */
				draw_modifier__stepped(box, id, fcm, width);
				break;
			
			default: /* unknown type */
				break;
		}
	}
}