Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/editors/interface')
-rw-r--r--source/blender/editors/interface/interface.c16
-rw-r--r--source/blender/editors/interface/interface_anim.c77
-rw-r--r--source/blender/editors/interface/interface_handlers.c9
-rw-r--r--source/blender/editors/interface/interface_intern.h1
-rw-r--r--source/blender/editors/interface/interface_style.c10
-rw-r--r--source/blender/editors/interface/interface_templates.c34
-rw-r--r--source/blender/editors/interface/resources.c35
7 files changed, 157 insertions, 25 deletions
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index e31e3a26b40..ccc5ac52744 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -1701,6 +1701,10 @@ int ui_set_but_string(bContext *C, uiBut *but, const char *str)
/* driver expression */
return 1;
}
+ else if(str[0]=='#') {
+ /* shortcut to create new driver expression (versus immediate Py-execution) */
+ return ui_but_anim_expression_create(but, str+1);
+ }
else {
/* number editing */
double value;
@@ -3214,11 +3218,17 @@ void uiButSetUnitType(uiBut *but, const int unit_type)
int uiButGetUnitType(uiBut *but)
{
- if(but->rnaprop) {
- return RNA_SUBTYPE_UNIT(RNA_property_subtype(but->rnaprop));
+ int ownUnit = (int)but->unit_type;
+
+ /* own unit define always takes precidence over RNA provided, allowing for overriding
+ * default value provided in RNA in a few special cases (i.e. Active Keyframe in Graph Edit)
+ */
+ // XXX: this doesn't allow clearing unit completely, though the same could be said for icons
+ if ((ownUnit != 0) || (but->rnaprop == NULL)) {
+ return ownUnit << 16;
}
else {
- return ((int)but->unit_type)<<16;
+ return RNA_SUBTYPE_UNIT(RNA_property_subtype(but->rnaprop));
}
}
diff --git a/source/blender/editors/interface/interface_anim.c b/source/blender/editors/interface/interface_anim.c
index d9691819b29..1113f90a652 100644
--- a/source/blender/editors/interface/interface_anim.c
+++ b/source/blender/editors/interface/interface_anim.c
@@ -30,6 +30,7 @@
#include <stdlib.h>
#include <string.h>
+#include "MEM_guardedalloc.h"
#include "DNA_anim_types.h"
#include "DNA_scene_types.h"
@@ -37,15 +38,19 @@
#include "BLI_listbase.h"
#include "BLI_string.h"
+#include "BLI_utildefines.h"
#include "BKE_context.h"
+#include "BKE_animsys.h"
#include "BKE_fcurve.h"
-
+#include "BKE_global.h"
#include "ED_keyframing.h"
#include "UI_interface.h"
+#include "RNA_access.h"
+
#include "WM_api.h"
#include "WM_types.h"
@@ -108,7 +113,7 @@ int ui_but_anim_expression_set(uiBut *but, const char *str)
if(fcu && driven) {
driver= fcu->driver;
-
+
if(driver && driver->type == DRIVER_TYPE_PYTHON) {
BLI_strncpy(driver->expression, str, sizeof(driver->expression));
driver->flag |= DRIVER_FLAG_RECOMPILE;
@@ -120,6 +125,74 @@ int ui_but_anim_expression_set(uiBut *but, const char *str)
return 0;
}
+/* create new expression for button (i.e. a "scripted driver"), if it can be created... */
+int ui_but_anim_expression_create(uiBut *but, const char *str)
+{
+ bContext *C = but->block->evil_C;
+ ID *id;
+ FCurve *fcu;
+ char *path;
+ short ok=0;
+
+ /* button must have RNA-pointer to a numeric-capable property */
+ if (ELEM(NULL, but->rnapoin.data, but->rnaprop)) {
+ if (G.f & G_DEBUG)
+ printf("ERROR: create expression failed - button has no RNA info attached\n");
+ return 0;
+ }
+
+ /* make sure we have animdata for this */
+ // FIXME: until materials can be handled by depsgraph, don't allow drivers to be created for them
+ id = (ID *)but->rnapoin.id.data;
+ if ((id == NULL) || (GS(id->name)==ID_MA) || (GS(id->name)==ID_TE)) {
+ if (G.f & G_DEBUG)
+ printf("ERROR: create expression failed - invalid id-datablock for adding drivers (%p)\n", id);
+ return 0;
+ }
+
+ /* get path */
+ path = RNA_path_from_ID_to_property(&but->rnapoin, but->rnaprop);
+
+ /* create driver */
+ fcu = verify_driver_fcurve(id, path, but->rnaindex, 1);
+ if (fcu) {
+ ChannelDriver *driver= fcu->driver;
+
+ if (driver) {
+ /* set type of driver */
+ driver->type = DRIVER_TYPE_PYTHON;
+
+ /* set the expression */
+ // TODO: need some way of identifying variables used
+ BLI_strncpy(driver->expression, str, sizeof(driver->expression));
+
+ /* FIXME: for now, assume that
+ * - for expressions, users are likely to be using "frame" -> current frame" as a variable
+ * - driver_add_new_variable() adds a single-prop variable by default
+ */
+ {
+ DriverVar *dvar;
+ DriverTarget *dtar;
+
+ dvar = driver_add_new_variable(driver);
+ BLI_strncpy(dvar->name, "frame", sizeof(dvar->name));
+
+ dtar = &dvar->targets[0];
+ dtar->id = (ID *)CTX_data_scene(C); // XXX: should we check that C is valid first?
+ dtar->rna_path = BLI_sprintfN("frame_current");
+ }
+
+ /* updates */
+ driver->flag |= DRIVER_FLAG_RECOMPILE;
+ WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME, NULL);
+ }
+ }
+
+ MEM_freeN(path);
+
+ return ok;
+}
+
void ui_but_anim_autokey(bContext *C, uiBut *but, Scene *scene, float cfra)
{
ID *id;
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index 6f3ca2bf003..15f46b4eee4 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -1236,7 +1236,7 @@ static short test_special_char(char ch)
case ':':
case ';':
case '\'':
- case '\"':
+ case '\"': // " - an extra closing one for Aligorith's text editor
case '<':
case '>':
case ',':
@@ -4235,6 +4235,7 @@ static int ui_but_menu(bContext *C, uiBut *but)
/* Keyframes */
if(but->flag & UI_BUT_ANIMATED_KEY) {
+ /* replace/delete keyfraemes */
if(length) {
uiItemBooleanO(layout, "Replace Keyframes", ICON_NONE, "ANIM_OT_keyframe_insert_button", "all", 1);
uiItemBooleanO(layout, "Replace Single Keyframe", ICON_NONE, "ANIM_OT_keyframe_insert_button", "all", 0);
@@ -4245,6 +4246,11 @@ static int ui_but_menu(bContext *C, uiBut *but)
uiItemBooleanO(layout, "Replace Keyframe", ICON_NONE, "ANIM_OT_keyframe_insert_button", "all", 0);
uiItemBooleanO(layout, "Delete Keyframe", ICON_NONE, "ANIM_OT_keyframe_delete_button", "all", 0);
}
+
+ /* keyframe settings */
+ uiItemS(layout);
+
+
}
else if(but->flag & UI_BUT_DRIVEN);
else if(is_anim) {
@@ -4287,6 +4293,7 @@ static int ui_but_menu(bContext *C, uiBut *but)
}
/* Keying Sets */
+ // TODO: check on modifyability of Keying Set when doing this
if(is_anim) {
uiItemS(layout);
diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h
index 8475090b468..8194ad610f7 100644
--- a/source/blender/editors/interface/interface_intern.h
+++ b/source/blender/editors/interface/interface_intern.h
@@ -520,6 +520,7 @@ void ui_but_anim_add_keyingset(struct bContext *C);
void ui_but_anim_remove_keyingset(struct bContext *C);
int ui_but_anim_expression_get(uiBut *but, char *str, int maxlen);
int ui_but_anim_expression_set(uiBut *but, const char *str);
+int ui_but_anim_expression_create(uiBut *but, const char *str);
void ui_but_anim_autokey(struct bContext *C, uiBut *but, struct Scene *scene, float cfra);
#endif
diff --git a/source/blender/editors/interface/interface_style.c b/source/blender/editors/interface/interface_style.c
index 8d4b4209120..704b9ae3a80 100644
--- a/source/blender/editors/interface/interface_style.c
+++ b/source/blender/editors/interface/interface_style.c
@@ -295,6 +295,7 @@ void uiStyleInit(void)
{
uiFont *font= U.uifonts.first;
uiStyle *style= U.uistyles.first;
+ int defaultFontId = -1;
/* recover from uninitialized dpi */
if(U.dpi == 0)
@@ -314,6 +315,7 @@ void uiStyleInit(void)
if(font->uifont_id==UIFONT_DEFAULT) {
font->blf_id= BLF_load_mem("default", (unsigned char*)datatoc_bfont_ttf, datatoc_bfont_ttf_size);
+ defaultFontId = font->blf_id;
}
else {
font->blf_id= BLF_load(font->filename);
@@ -351,6 +353,14 @@ void uiStyleInit(void)
blf_mono_font_render= BLF_load_mem_unique("monospace", (unsigned char *)datatoc_bmonofont_ttf, datatoc_bmonofont_ttf_size);
BLF_size(blf_mono_font_render, 12, 72);
+
+ /* also another copy of default for rendering else we get threading problems */
+ if (defaultFontId != -1) {
+ if (blf_default_font_render == -1)
+ blf_default_font_render= BLF_load_mem_unique("default", (unsigned char*)datatoc_bfont_ttf, datatoc_bfont_ttf_size);
+
+ BLF_size(blf_default_font_render, 12, 72);
+ }
}
void uiStyleFontSet(uiFontStyle *fs)
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c
index 2d443bbfcd0..c85d5ae5616 100644
--- a/source/blender/editors/interface/interface_templates.c
+++ b/source/blender/editors/interface/interface_templates.c
@@ -33,6 +33,7 @@
#include "MEM_guardedalloc.h"
+#include "DNA_anim_types.h"
#include "DNA_key_types.h"
#include "DNA_scene_types.h"
#include "DNA_userdef_types.h"
@@ -56,6 +57,7 @@
#include "ED_render.h"
#include "RNA_access.h"
+#include "RNA_enum_types.h"
#include "WM_api.h"
#include "WM_types.h"
@@ -235,7 +237,7 @@ static void template_id_cb(bContext *C, void *arg_litem, void *arg_event)
{
TemplateID *template= (TemplateID*)arg_litem;
PointerRNA idptr= RNA_property_pointer_get(&template->ptr, template->prop);
- ID *id= idptr.data, *newid;
+ ID *id= idptr.data;
int event= GET_INT_FROM_POINTER(arg_event);
switch(event) {
@@ -274,21 +276,8 @@ static void template_id_cb(bContext *C, void *arg_litem, void *arg_event)
}
break;
case UI_ID_ALONE:
- if(id) {
- /* make copy */
- if(id_copy(id, &newid, 0) && newid) {
- /* copy animation actions too */
- BKE_copy_animdata_id_action(id);
- /* us is 1 by convention, but RNA_property_pointer_set
- will also incremement it, so set it to zero */
- newid->us= 0;
-
- /* assign copy */
- RNA_id_pointer_create(newid, &idptr);
- RNA_property_pointer_set(&template->ptr, template->prop, idptr);
- RNA_property_update(C, &template->ptr, template->prop);
- }
- }
+ if(id)
+ id_single_user(C, id, &template->ptr, template->prop);
break;
#if 0
case UI_ID_AUTO_NAME:
@@ -309,11 +298,13 @@ static const char *template_id_browse_tip(StructRNA *type)
case ID_MA: return "Browse Material to be linked";
case ID_TE: return "Browse Texture to be linked";
case ID_IM: return "Browse Image to be linked";
- case ID_LA: return "Browse Lattice Data to be linked";
+ case ID_LT: return "Browse Lattice Data to be linked";
+ case ID_LA: return "Browse Lamp Data to be linked";
case ID_CA: return "Browse Camera Data to be linked";
case ID_WO: return "Browse World Settings to be linked";
case ID_SCR: return "Choose Screen lay-out";
case ID_TXT: return "Browse Text to be linked";
+ case ID_SPK: return "Browse Speaker Data to be linked";
case ID_SO: return "Browse Sound to be linked";
case ID_AR: return "Browse Armature data to be linked";
case ID_AC: return "Browse Action to be linked";
@@ -2118,6 +2109,15 @@ static void list_item_row(bContext *C, uiLayout *layout, PointerRNA *ptr, Pointe
//uiItemR(row, itemptr, "mute", 0, "", ICON_MUTE_IPO_OFF);
uiBlockSetEmboss(block, UI_EMBOSS);
}
+ else if(itemptr->type == &RNA_KeyingSetPath) {
+ KS_Path *ksp = (KS_Path*)itemptr->data;
+
+ /* icon needs to be the type of ID which is currently active */
+ RNA_enum_icon_from_value(id_type_items, ksp->idtype, &icon);
+
+ /* nothing else special to do... */
+ uiItemL(sub, name, icon); /* fails, backdrop LISTROW... */
+ }
else
uiItemL(sub, name, icon); /* fails, backdrop LISTROW... */
diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c
index e71f709f89b..02054fbe90f 100644
--- a/source/blender/editors/interface/resources.c
+++ b/source/blender/editors/interface/resources.c
@@ -250,6 +250,8 @@ const unsigned char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colo
cp= ts->wire; break;
case TH_LAMP:
cp= ts->lamp; break;
+ case TH_SPEAKER:
+ cp= ts->speaker; break;
case TH_SELECT:
cp= ts->select; break;
case TH_ACTIVE:
@@ -326,6 +328,8 @@ const unsigned char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colo
cp= ts->handle_free; break;
case TH_HANDLE_AUTO:
cp= ts->handle_auto; break;
+ case TH_HANDLE_AUTOCLAMP:
+ cp= ts->handle_auto_clamped; break;
case TH_HANDLE_VECT:
cp= ts->handle_vect; break;
case TH_HANDLE_ALIGN:
@@ -334,11 +338,13 @@ const unsigned char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colo
cp= ts->handle_sel_free; break;
case TH_HANDLE_SEL_AUTO:
cp= ts->handle_sel_auto; break;
+ case TH_HANDLE_SEL_AUTOCLAMP:
+ cp= ts->handle_sel_auto_clamped; break;
case TH_HANDLE_SEL_VECT:
cp= ts->handle_sel_vect; break;
case TH_HANDLE_SEL_ALIGN:
cp= ts->handle_sel_align; break;
-
+
case TH_SYNTAX_B:
cp= ts->syntaxb; break;
case TH_SYNTAX_V:
@@ -587,6 +593,7 @@ void ui_theme_init_default(void)
SETCOLF(btheme->tv3d.grid, 0.251, 0.251, 0.251, 1.0);
SETCOL(btheme->tv3d.wire, 0x0, 0x0, 0x0, 255);
SETCOL(btheme->tv3d.lamp, 0, 0, 0, 40);
+ SETCOL(btheme->tv3d.speaker, 0, 0, 0, 255);
SETCOL(btheme->tv3d.select, 241, 88, 0, 255);
SETCOL(btheme->tv3d.active, 255, 170, 64, 255);
SETCOL(btheme->tv3d.group, 8, 48, 8, 255);
@@ -666,7 +673,9 @@ void ui_theme_init_default(void)
SETCOL(btheme->tipo.handle_vertex, 0, 0, 0, 255);
SETCOL(btheme->tipo.handle_vertex_select, 255, 133, 0, 255);
- btheme->tipo.handle_vertex_size= 3;
+ SETCOL(btheme->tipo.handle_auto_clamped, 0x99, 0x40, 0x30, 255);
+ SETCOL(btheme->tipo.handle_sel_auto_clamped, 0xf0, 0xaf, 0x90, 255);
+ btheme->tipo.handle_vertex_size= 4;
SETCOL(btheme->tipo.ds_channel, 82, 96, 110, 255);
SETCOL(btheme->tipo.ds_subchannel, 124, 137, 150, 255);
@@ -1564,6 +1573,21 @@ void init_userdef_do_versions(void)
}
}
+ if (bmain->versionfile < 258 || (bmain->versionfile == 258 && bmain->subversionfile < 1)) {
+ bTheme *btheme;
+
+ /* if new keyframes handle default is stuff "auto", make it "auto-clamped" instead */
+ if (U.keyhandles_new == HD_AUTO)
+ U.keyhandles_new = HD_AUTO_ANIM;
+
+ /* theme color additions */
+ for (btheme= U.themes.first; btheme; btheme= btheme->next) {
+ /* auto-clamped handles -> based on auto */
+ SETCOL(btheme->tipo.handle_auto_clamped, 0x99, 0x40, 0x30, 255);
+ SETCOL(btheme->tipo.handle_sel_auto_clamped, 0xf0, 0xaf, 0x90, 255);
+ }
+ }
+
/* GL Texture Garbage Collection (variable abused above!) */
if (U.textimeout == 0) {
U.texcollectrate = 60;
@@ -1601,6 +1625,13 @@ void init_userdef_do_versions(void)
NDOF_SHOULD_PAN | NDOF_SHOULD_ZOOM | NDOF_SHOULD_ROTATE;
}
+ {
+ bTheme *btheme;
+ for(btheme= U.themes.first; btheme; btheme= btheme->next) {
+ btheme->tv3d.speaker[3] = 255;
+ }
+ }
+
/* funny name, but it is GE stuff, moves userdef stuff to engine */
// XXX space_set_commmandline_options();
/* this timer uses U */