forked from bartvdbraak/blender
2.5: Couple of small fun features
* Text window font size now supports full range 8-32, instead of just 12 and 15. I added BLF_fixed_width to get the character width of a fixed size font. * Buttons do undo push on change again. * Animated/Keyframe/Driver colors are now themable, with blend value to blend with original color. Set this to 0.5 now to give colors less constrast. * Fix tooltip popping up with RMB menu open, and missing redraw. * Autokeyframe now works for buttons. * Driver expressions can be edited in place in a button now. (still some refresh issues). * Also made python driver default for the Add Driver function in the RMB button. This way you don't have to open a Graph editor if you just want to type an expression. Also, the default expression then is the current value. * Tooltips now show some extra info, not sure what is good to have, but currently I added: * Shortcut key for operator buttons. * Python struct & property name for RNA buttons. * Expression for driven values. * Value for text/search/pointer buttons.
This commit is contained in:
parent
8b9bb47a3f
commit
3116062a82
@ -70,6 +70,13 @@ void BLF_boundbox(char *str, struct rctf *box);
|
||||
float BLF_width(char *str);
|
||||
float BLF_height(char *str);
|
||||
|
||||
|
||||
/*
|
||||
* For fixed width fonts only, returns the width of a
|
||||
* character.
|
||||
*/
|
||||
float BLF_fixed_width(void);
|
||||
|
||||
/*
|
||||
* and this two function return the width and height
|
||||
* of the string, using the default font and both value
|
||||
|
@ -398,6 +398,16 @@ float BLF_width(char *str)
|
||||
return(0.0f);
|
||||
}
|
||||
|
||||
float BLF_fixed_width(void)
|
||||
{
|
||||
FontBLF *font;
|
||||
|
||||
font= global_font[global_font_cur];
|
||||
if (font)
|
||||
return(blf_font_fixed_width(font));
|
||||
return(0.0f);
|
||||
}
|
||||
|
||||
float BLF_width_default(char *str)
|
||||
{
|
||||
FontBLF *font;
|
||||
|
@ -274,6 +274,27 @@ float blf_font_height(FontBLF *font, char *str)
|
||||
return((box.ymax - box.ymin) * font->aspect);
|
||||
}
|
||||
|
||||
float blf_font_fixed_width(FontBLF *font)
|
||||
{
|
||||
GlyphBLF *g;
|
||||
FT_UInt glyph_index;
|
||||
unsigned int c = ' ';
|
||||
|
||||
if (!font->glyph_cache)
|
||||
return 0.0f;
|
||||
|
||||
glyph_index= FT_Get_Char_Index(font->face, c);
|
||||
g= blf_glyph_search(font->glyph_cache, c);
|
||||
if (!g)
|
||||
g= blf_glyph_add(font, glyph_index, c);
|
||||
|
||||
/* if we don't find the glyph. */
|
||||
if (!g)
|
||||
return 0.0f;
|
||||
|
||||
return g->advance;
|
||||
}
|
||||
|
||||
void blf_font_free(FontBLF *font)
|
||||
{
|
||||
GlyphCacheBLF *gc;
|
||||
|
@ -48,6 +48,7 @@ void blf_font_draw(FontBLF *font, char *str);
|
||||
void blf_font_boundbox(FontBLF *font, char *str, rctf *box);
|
||||
float blf_font_width(FontBLF *font, char *str);
|
||||
float blf_font_height(FontBLF *font, char *str);
|
||||
float blf_font_fixed_width(FontBLF *font);
|
||||
void blf_font_free(FontBLF *font);
|
||||
|
||||
GlyphCacheBLF *blf_glyph_cache_find(FontBLF *font, int size, int dpi);
|
||||
|
@ -135,7 +135,7 @@ FCurve *verify_driver_fcurve (ID *id, const char rna_path[], const int array_ind
|
||||
/* Main Driver Management API calls:
|
||||
* Add a new driver for the specified property on the given ID block
|
||||
*/
|
||||
short ANIM_add_driver (ID *id, const char rna_path[], int array_index, short flag)
|
||||
short ANIM_add_driver (ID *id, const char rna_path[], int array_index, short flag, int type)
|
||||
{
|
||||
PointerRNA id_ptr, ptr;
|
||||
PropertyRNA *prop;
|
||||
@ -151,6 +151,39 @@ short ANIM_add_driver (ID *id, const char rna_path[], int array_index, short fla
|
||||
/* create F-Curve with Driver */
|
||||
fcu= verify_driver_fcurve(id, rna_path, array_index, 1);
|
||||
|
||||
if(fcu && fcu->driver) {
|
||||
fcu->driver->type= type;
|
||||
|
||||
/* fill in current value for python */
|
||||
if(type == DRIVER_TYPE_PYTHON) {
|
||||
PropertyType proptype= RNA_property_type(prop);
|
||||
int array= RNA_property_array_length(prop);
|
||||
char *expression= fcu->driver->expression;
|
||||
int val, maxlen= sizeof(fcu->driver->expression);
|
||||
float fval;
|
||||
|
||||
if(proptype == PROP_BOOLEAN) {
|
||||
if(!array) val= RNA_property_boolean_get(&ptr, prop);
|
||||
else val= RNA_property_boolean_get_index(&ptr, prop, array_index);
|
||||
|
||||
BLI_strncpy(expression, (val)? "True": "False", maxlen);
|
||||
}
|
||||
else if(proptype == PROP_INT) {
|
||||
if(!array) val= RNA_property_int_get(&ptr, prop);
|
||||
else val= RNA_property_int_get_index(&ptr, prop, array_index);
|
||||
|
||||
BLI_snprintf(expression, maxlen, "%d", val);
|
||||
}
|
||||
else if(proptype == PROP_FLOAT) {
|
||||
if(!array) fval= RNA_property_float_get(&ptr, prop);
|
||||
else fval= RNA_property_float_get_index(&ptr, prop, array_index);
|
||||
|
||||
BLI_snprintf(expression, maxlen, "%.3f", fval);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/* done */
|
||||
return (fcu != NULL);
|
||||
}
|
||||
@ -217,7 +250,7 @@ static int add_driver_button_exec (bContext *C, wmOperator *op)
|
||||
length= 1;
|
||||
|
||||
for (a=0; a<length; a++)
|
||||
success+= ANIM_add_driver(ptr.id.data, path, index+a, 0);
|
||||
success+= ANIM_add_driver(ptr.id.data, path, index+a, 0, DRIVER_TYPE_PYTHON);
|
||||
|
||||
MEM_freeN(path);
|
||||
}
|
||||
|
@ -1425,6 +1425,22 @@ void ANIM_OT_delete_keyframe_button (wmOperatorType *ot)
|
||||
RNA_def_boolean(ot->srna, "all", 1, "All", "Delete keyfames from all elements of the array.");
|
||||
}
|
||||
|
||||
/* ******************************************* */
|
||||
/* AUTO KEYFRAME */
|
||||
|
||||
int autokeyframe_cfra_can_key(Scene *scene, ID *id)
|
||||
{
|
||||
float cfra= (float)CFRA; // XXX for now, this will do
|
||||
|
||||
/* only filter if auto-key mode requires this */
|
||||
if (IS_AUTOKEY_ON(scene) == 0)
|
||||
return 0;
|
||||
else if (IS_AUTOKEY_MODE(scene, NORMAL))
|
||||
return 1;
|
||||
else
|
||||
return id_frame_has_keyframe(id, cfra, ANIMFILTER_KEYS_LOCAL);
|
||||
}
|
||||
|
||||
/* ******************************************* */
|
||||
/* KEYFRAME DETECTION */
|
||||
|
||||
|
@ -30,6 +30,7 @@
|
||||
|
||||
struct ListBase;
|
||||
struct ID;
|
||||
struct Scene;
|
||||
|
||||
struct KeyingSet;
|
||||
|
||||
@ -168,7 +169,7 @@ void ANIM_OT_keyingset_add_destination(struct wmOperatorType *ot);
|
||||
/* Main Driver Management API calls:
|
||||
* Add a new driver for the specified property on the given ID block
|
||||
*/
|
||||
short ANIM_add_driver (struct ID *id, const char rna_path[], int array_index, short flag);
|
||||
short ANIM_add_driver (struct ID *id, const char rna_path[], int array_index, short flag, int type);
|
||||
|
||||
/* Main Driver Management API calls:
|
||||
* Remove the driver for the specified property on the given ID block (if available)
|
||||
@ -197,6 +198,9 @@ void ANIM_OT_remove_driver_button(struct wmOperatorType *ot);
|
||||
/* check if a flag is set for auto-keyframing (as userprefs only!) */
|
||||
#define IS_AUTOKEY_FLAG(flag) (U.autokey_flag & AUTOKEY_FLAG_##flag)
|
||||
|
||||
/* auto-keyframing feature - checks for whether anything should be done for the current frame */
|
||||
int autokeyframe_cfra_can_key(struct Scene *scene, struct ID *id);
|
||||
|
||||
/* ************ Keyframe Checking ******************** */
|
||||
|
||||
/* Lesser Keyframe Checking API call:
|
||||
|
@ -1312,8 +1312,10 @@ void ui_get_but_string(uiBut *but, char *str, int maxlen)
|
||||
BLI_strncpy(str, but->poin, maxlen);
|
||||
return;
|
||||
}
|
||||
else if(ui_but_anim_expression_get(but, str, maxlen))
|
||||
; /* driver expression */
|
||||
else {
|
||||
/* number */
|
||||
/* number editing */
|
||||
double value;
|
||||
|
||||
value= ui_get_but_val(but);
|
||||
@ -1384,7 +1386,12 @@ int ui_set_but_string(bContext *C, uiBut *but, const char *str)
|
||||
BLI_strncpy(but->poin, str, but->hardmax);
|
||||
return 1;
|
||||
}
|
||||
else if(ui_but_anim_expression_set(but, str)) {
|
||||
/* driver expression */
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
/* number editing */
|
||||
double value;
|
||||
|
||||
/* XXX 2.50 missing python api */
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "DNA_screen_types.h"
|
||||
|
||||
#include "BLI_listbase.h"
|
||||
#include "BLI_string.h"
|
||||
|
||||
#include "BKE_animsys.h"
|
||||
#include "BKE_context.h"
|
||||
@ -27,49 +28,135 @@
|
||||
|
||||
#include "interface_intern.h"
|
||||
|
||||
void ui_but_anim_flag(uiBut *but, float cfra)
|
||||
static FCurve *ui_but_get_fcurve(uiBut *but, bAction **action, int *driven)
|
||||
{
|
||||
but->flag &= ~(UI_BUT_ANIMATED|UI_BUT_ANIMATED_KEY|UI_BUT_DRIVEN);
|
||||
FCurve *fcu= NULL;
|
||||
|
||||
*driven= 0;
|
||||
|
||||
/* there must be some RNA-pointer + property combo for this button */
|
||||
if (but->rnaprop && but->rnapoin.id.data &&
|
||||
if(but->rnaprop && but->rnapoin.id.data &&
|
||||
RNA_property_animateable(&but->rnapoin, but->rnaprop))
|
||||
{
|
||||
AnimData *adt= BKE_animdata_from_id(but->rnapoin.id.data);
|
||||
FCurve *fcu;
|
||||
char *path;
|
||||
|
||||
if (adt) {
|
||||
if ((adt->action && adt->action->curves.first) || (adt->drivers.first)) {
|
||||
if(adt) {
|
||||
if((adt->action && adt->action->curves.first) || (adt->drivers.first)) {
|
||||
/* XXX this function call can become a performance bottleneck */
|
||||
path= RNA_path_from_ID_to_property(&but->rnapoin, but->rnaprop);
|
||||
|
||||
if (path) {
|
||||
if(path) {
|
||||
/* animation takes priority over drivers */
|
||||
if (adt->action && adt->action->curves.first) {
|
||||
if(adt->action && adt->action->curves.first)
|
||||
fcu= list_find_fcurve(&adt->action->curves, path, but->rnaindex);
|
||||
|
||||
if (fcu) {
|
||||
but->flag |= UI_BUT_ANIMATED;
|
||||
|
||||
if (fcurve_frame_has_keyframe(fcu, cfra, 0))
|
||||
but->flag |= UI_BUT_ANIMATED_KEY;
|
||||
}
|
||||
}
|
||||
|
||||
/* if not animated, check if driven */
|
||||
if ((but->flag & UI_BUT_ANIMATED)==0 && (adt->drivers.first)) {
|
||||
if(!fcu && (adt->drivers.first)) {
|
||||
fcu= list_find_fcurve(&adt->drivers, path, but->rnaindex);
|
||||
|
||||
if (fcu)
|
||||
but->flag |= UI_BUT_DRIVEN;
|
||||
if(fcu)
|
||||
*driven= 1;
|
||||
}
|
||||
|
||||
if(fcu && action)
|
||||
*action= adt->action;
|
||||
|
||||
MEM_freeN(path);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return fcu;
|
||||
}
|
||||
|
||||
void ui_but_anim_flag(uiBut *but, float cfra)
|
||||
{
|
||||
FCurve *fcu;
|
||||
int driven;
|
||||
|
||||
but->flag &= ~(UI_BUT_ANIMATED|UI_BUT_ANIMATED_KEY|UI_BUT_DRIVEN);
|
||||
|
||||
fcu= ui_but_get_fcurve(but, NULL, &driven);
|
||||
|
||||
if(fcu) {
|
||||
if(!driven) {
|
||||
but->flag |= UI_BUT_ANIMATED;
|
||||
|
||||
if(fcurve_frame_has_keyframe(fcu, cfra, 0))
|
||||
but->flag |= UI_BUT_ANIMATED_KEY;
|
||||
}
|
||||
else {
|
||||
but->flag |= UI_BUT_DRIVEN;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int ui_but_anim_expression_get(uiBut *but, char *str, int maxlen)
|
||||
{
|
||||
FCurve *fcu;
|
||||
ChannelDriver *driver;
|
||||
int driven;
|
||||
|
||||
fcu= ui_but_get_fcurve(but, NULL, &driven);
|
||||
|
||||
if(fcu && driven) {
|
||||
driver= fcu->driver;
|
||||
|
||||
if(driver && driver->type == DRIVER_TYPE_PYTHON) {
|
||||
BLI_strncpy(str, driver->expression, maxlen);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ui_but_anim_expression_set(uiBut *but, const char *str)
|
||||
{
|
||||
FCurve *fcu;
|
||||
ChannelDriver *driver;
|
||||
int driven;
|
||||
|
||||
fcu= ui_but_get_fcurve(but, NULL, &driven);
|
||||
|
||||
if(fcu && driven) {
|
||||
driver= fcu->driver;
|
||||
|
||||
if(driver && driver->type == DRIVER_TYPE_PYTHON) {
|
||||
BLI_strncpy(driver->expression, str, sizeof(driver->expression));
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ui_but_anim_autokey(uiBut *but, Scene *scene, float cfra)
|
||||
{
|
||||
ID *id;
|
||||
bAction *action;
|
||||
FCurve *fcu;
|
||||
int driven;
|
||||
|
||||
fcu= ui_but_get_fcurve(but, &action, &driven);
|
||||
|
||||
if(fcu && !driven) {
|
||||
id= but->rnapoin.id.data;
|
||||
|
||||
if(autokeyframe_cfra_can_key(scene, id)) {
|
||||
short flag = 0;
|
||||
|
||||
if (IS_AUTOKEY_FLAG(INSERTNEEDED))
|
||||
flag |= INSERTKEY_NEEDED;
|
||||
if (IS_AUTOKEY_FLAG(AUTOMATKEY))
|
||||
flag |= INSERTKEY_MATRIX;
|
||||
|
||||
fcu->flag &= ~FCURVE_SELECTED;
|
||||
insert_keyframe(id, action, ((fcu->grp)?(fcu->grp->name):(NULL)), fcu->rna_path, fcu->array_index, cfra, flag);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void uiAnimContextProperty(const bContext *C, struct PointerRNA *ptr, struct PropertyRNA **prop, int *index)
|
||||
@ -140,6 +227,7 @@ void ui_but_anim_menu(bContext *C, uiBut *but)
|
||||
uiItemBooleanO(layout, "Delete Keyframe", 0, "ANIM_OT_delete_keyframe_button", "all", 0);
|
||||
}
|
||||
}
|
||||
else if(but->flag & UI_BUT_DRIVEN);
|
||||
else if(RNA_property_animateable(&but->rnapoin, but->rnaprop)) {
|
||||
if(length) {
|
||||
uiItemBooleanO(layout, "Insert Keyframes", 0, "ANIM_OT_insert_keyframe_button", "all", 1);
|
||||
@ -153,17 +241,18 @@ void ui_but_anim_menu(bContext *C, uiBut *but)
|
||||
uiItemS(layout);
|
||||
|
||||
if(length) {
|
||||
uiItemBooleanO(layout, "Remove Driver", 0, "ANIM_OT_remove_driver_button", "all", 1);
|
||||
uiItemBooleanO(layout, "Remove Single Driver", 0, "ANIM_OT_remove_driver_button", "all", 0);
|
||||
uiItemBooleanO(layout, "Delete Drivers", 0, "ANIM_OT_remove_driver_button", "all", 1);
|
||||
uiItemBooleanO(layout, "Delete Single Driver", 0, "ANIM_OT_remove_driver_button", "all", 0);
|
||||
}
|
||||
else
|
||||
uiItemBooleanO(layout, "Remove Driver", 0, "ANIM_OT_remove_driver_button", "all", 0);
|
||||
uiItemBooleanO(layout, "Delete Driver", 0, "ANIM_OT_remove_driver_button", "all", 0);
|
||||
}
|
||||
else if(but->flag & UI_BUT_ANIMATED_KEY);
|
||||
else if(RNA_property_animateable(&but->rnapoin, but->rnaprop)) {
|
||||
uiItemS(layout);
|
||||
|
||||
if(length) {
|
||||
uiItemBooleanO(layout, "Add Driver", 0, "ANIM_OT_add_driver_button", "all", 1);
|
||||
uiItemBooleanO(layout, "Add Drivers", 0, "ANIM_OT_add_driver_button", "all", 1);
|
||||
uiItemBooleanO(layout, "Add Single Driver", 0, "ANIM_OT_add_driver_button", "all", 0);
|
||||
}
|
||||
else
|
||||
|
@ -32,6 +32,7 @@
|
||||
|
||||
#include "DNA_color_types.h"
|
||||
#include "DNA_object_types.h"
|
||||
#include "DNA_scene_types.h"
|
||||
#include "DNA_screen_types.h"
|
||||
#include "DNA_texture_types.h"
|
||||
#include "DNA_userdef_types.h"
|
||||
@ -49,6 +50,7 @@
|
||||
#include "BKE_utildefines.h"
|
||||
|
||||
#include "ED_screen.h"
|
||||
#include "ED_util.h"
|
||||
|
||||
#include "UI_interface.h"
|
||||
|
||||
@ -166,6 +168,10 @@ typedef struct uiAfterFunc {
|
||||
PropertyRNA *rnaprop;
|
||||
|
||||
bContextStore *context;
|
||||
|
||||
char undostr[512];
|
||||
|
||||
int autokey;
|
||||
} uiAfterFunc;
|
||||
|
||||
static int ui_mouse_inside_button(ARegion *ar, uiBut *but, int x, int y);
|
||||
@ -174,6 +180,7 @@ static int ui_handler_region_menu(bContext *C, wmEvent *event, void *userdata);
|
||||
static int ui_handler_popup(bContext *C, wmEvent *event, void *userdata);
|
||||
static void ui_handler_remove_popup(bContext *C, void *userdata);
|
||||
static void ui_handle_button_activate(bContext *C, ARegion *ar, uiBut *but, uiButtonActivateType type);
|
||||
static void button_timers_tooltip_remove(bContext *C, uiBut *but);
|
||||
|
||||
/* ******************** menu navigation helpers ************** */
|
||||
|
||||
@ -271,6 +278,32 @@ static void ui_apply_but_func(bContext *C, uiBut *but)
|
||||
}
|
||||
}
|
||||
|
||||
static void ui_apply_autokey_undo(bContext *C, uiBut *but)
|
||||
{
|
||||
Scene *scene= CTX_data_scene(C);
|
||||
uiAfterFunc *after;
|
||||
char *str= NULL;
|
||||
|
||||
if ELEM5(but->type, BLOCK, BUT, LABEL, PULLDOWN, ROUNDBOX);
|
||||
else {
|
||||
/* define which string to use for undo */
|
||||
if ELEM(but->type, LINK, INLINK) str= "Add button link";
|
||||
else if ELEM(but->type, MENU, ICONTEXTROW) str= but->drawstr;
|
||||
else if(but->drawstr[0]) str= but->drawstr;
|
||||
else str= but->tip;
|
||||
}
|
||||
|
||||
/* delayed, after all other funcs run, popups are closed, etc */
|
||||
if(str) {
|
||||
after= MEM_callocN(sizeof(uiAfterFunc), "uiAfterFunc");
|
||||
BLI_strncpy(after->undostr, str, sizeof(after->undostr));
|
||||
BLI_addtail(&UIAfterFuncs, after);
|
||||
}
|
||||
|
||||
/* try autokey */
|
||||
ui_but_anim_autokey(but, scene, scene->r.cfra);
|
||||
}
|
||||
|
||||
static void ui_apply_but_funcs_after(bContext *C)
|
||||
{
|
||||
uiAfterFunc *afterf, after;
|
||||
@ -311,6 +344,9 @@ static void ui_apply_but_funcs_after(bContext *C)
|
||||
after.handle_func(C, after.handle_func_arg, after.retval);
|
||||
if(after.butm_func)
|
||||
after.butm_func(C, after.butm_func_arg, after.a2);
|
||||
|
||||
if(after.undostr[0])
|
||||
ED_undo_push(C, after.undostr);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1324,7 +1360,7 @@ static void ui_textedit_begin(bContext *C, uiBut *but, uiHandleButtonData *data)
|
||||
but->editstr= data->str;
|
||||
but->pos= strlen(data->str);
|
||||
but->selsta= 0;
|
||||
but->selend= strlen(but->drawstr) - strlen(but->str);
|
||||
but->selend= strlen(data->str);
|
||||
|
||||
/* optional searchbox */
|
||||
if(but->type==SEARCH_MENU) {
|
||||
@ -1539,7 +1575,8 @@ static void ui_do_but_textedit(bContext *C, uiBlock *block, uiBut *but, uiHandle
|
||||
}
|
||||
|
||||
if(changed) {
|
||||
if(data->interactive) ui_apply_button(C, block, but, data, 1);
|
||||
/* never update while typing for now */
|
||||
if(0/*data->interactive*/) ui_apply_button(C, block, but, data, 1);
|
||||
else ui_check_but(but);
|
||||
|
||||
if(data->searchbox)
|
||||
@ -3090,6 +3127,7 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, wmEvent *event)
|
||||
}
|
||||
/* handle menu */
|
||||
else if(event->type == RIGHTMOUSE && event->val == KM_PRESS) {
|
||||
button_timers_tooltip_remove(C, but);
|
||||
ui_but_anim_menu(C, but);
|
||||
return WM_UI_HANDLER_BREAK;
|
||||
}
|
||||
@ -3315,6 +3353,27 @@ static int button_modal_state(uiHandleButtonState state)
|
||||
BUTTON_STATE_TEXT_SELECTING, BUTTON_STATE_MENU_OPEN);
|
||||
}
|
||||
|
||||
static void button_timers_tooltip_remove(bContext *C, uiBut *but)
|
||||
{
|
||||
uiHandleButtonData *data;
|
||||
|
||||
data= but->active;
|
||||
|
||||
if(data->tooltiptimer) {
|
||||
WM_event_remove_window_timer(data->window, data->tooltiptimer);
|
||||
data->tooltiptimer= NULL;
|
||||
}
|
||||
if(data->tooltip) {
|
||||
ui_tooltip_free(C, data->tooltip);
|
||||
data->tooltip= NULL;
|
||||
}
|
||||
|
||||
if(data->autoopentimer) {
|
||||
WM_event_remove_window_timer(data->window, data->autoopentimer);
|
||||
data->autoopentimer= NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static void button_tooltip_timer_reset(uiBut *but)
|
||||
{
|
||||
uiHandleButtonData *data;
|
||||
@ -3362,20 +3421,7 @@ static void button_activate_state(bContext *C, uiBut *but, uiHandleButtonState s
|
||||
}
|
||||
else {
|
||||
but->flag |= UI_SELECT;
|
||||
|
||||
if(data->tooltiptimer) {
|
||||
WM_event_remove_window_timer(data->window, data->tooltiptimer);
|
||||
data->tooltiptimer= NULL;
|
||||
}
|
||||
if(data->tooltip) {
|
||||
ui_tooltip_free(C, data->tooltip);
|
||||
data->tooltip= NULL;
|
||||
}
|
||||
|
||||
if(data->autoopentimer) {
|
||||
WM_event_remove_window_timer(data->window, data->autoopentimer);
|
||||
data->autoopentimer= NULL;
|
||||
}
|
||||
button_timers_tooltip_remove(C, but);
|
||||
}
|
||||
|
||||
/* text editing */
|
||||
@ -3502,6 +3548,10 @@ static void button_activate_exit(bContext *C, uiHandleButtonData *data, uiBut *b
|
||||
}
|
||||
}
|
||||
|
||||
/* autokey & undo push */
|
||||
if(!data->cancel)
|
||||
ui_apply_autokey_undo(C, but);
|
||||
|
||||
/* disable tooltips until mousemove */
|
||||
ui_blocks_set_tooltips(data->region, 0);
|
||||
|
||||
|
@ -455,6 +455,9 @@ void ui_but_anim_delete_keyframe(struct bContext *C);
|
||||
void ui_but_anim_add_driver(struct bContext *C);
|
||||
void ui_but_anim_remove_driver(struct bContext *C);
|
||||
void ui_but_anim_menu(struct bContext *C, uiBut *but);
|
||||
int ui_but_anim_expression_get(uiBut *but, char *str, int maxlen);
|
||||
int ui_but_anim_expression_set(uiBut *but, const char *str);
|
||||
void ui_but_anim_autokey(uiBut *but, struct Scene *scene, float cfra);
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -294,19 +294,33 @@ void ui_remove_temporary_region(bContext *C, bScreen *sc, ARegion *ar)
|
||||
typedef struct uiTooltipData {
|
||||
rcti bbox;
|
||||
uiFontStyle fstyle;
|
||||
char *tip;
|
||||
char lines[5][512];
|
||||
int totline;
|
||||
int toth, spaceh, lineh;
|
||||
} uiTooltipData;
|
||||
|
||||
static void ui_tooltip_region_draw(const bContext *C, ARegion *ar)
|
||||
{
|
||||
uiTooltipData *data= ar->regiondata;
|
||||
rcti bbox= data->bbox;
|
||||
int a;
|
||||
|
||||
ui_draw_menu_back(U.uistyles.first, NULL, &data->bbox);
|
||||
|
||||
/* draw text */
|
||||
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
uiStyleFontSet(&data->fstyle);
|
||||
uiStyleFontDraw(&data->fstyle, &data->bbox, data->tip);
|
||||
|
||||
bbox.ymax= bbox.ymax - 0.5f*((bbox.ymax - bbox.ymin) - data->toth);
|
||||
bbox.ymin= bbox.ymax - data->lineh;
|
||||
|
||||
for(a=0; a<data->totline; a++) {
|
||||
if(a == 0) glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
else glColor4f(0.5f, 0.5f, 0.5f, 1.0f);
|
||||
|
||||
uiStyleFontDraw(&data->fstyle, &bbox, data->lines[a]);
|
||||
bbox.ymin -= data->lineh + data->spaceh;
|
||||
bbox.ymax -= data->lineh + data->spaceh;
|
||||
}
|
||||
}
|
||||
|
||||
static void ui_tooltip_region_free(ARegion *ar)
|
||||
@ -314,7 +328,6 @@ static void ui_tooltip_region_free(ARegion *ar)
|
||||
uiTooltipData *data;
|
||||
|
||||
data= ar->regiondata;
|
||||
MEM_freeN(data->tip);
|
||||
MEM_freeN(data);
|
||||
ar->regiondata= NULL;
|
||||
}
|
||||
@ -325,9 +338,11 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but)
|
||||
static ARegionType type;
|
||||
ARegion *ar;
|
||||
uiTooltipData *data;
|
||||
IDProperty *prop;
|
||||
char buf[512];
|
||||
float fonth, fontw, aspect= but->block->aspect;
|
||||
float x1f, x2f, y1f, y2f;
|
||||
int x1, x2, y1, y2, winx, winy, ofsx, ofsy;
|
||||
int x1, x2, y1, y2, winx, winy, ofsx, ofsy, w, h, a;
|
||||
|
||||
if(!but->tip || strlen(but->tip)==0)
|
||||
return NULL;
|
||||
@ -342,18 +357,64 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but)
|
||||
|
||||
/* create tooltip data */
|
||||
data= MEM_callocN(sizeof(uiTooltipData), "uiTooltipData");
|
||||
data->tip= BLI_strdup(but->tip);
|
||||
|
||||
BLI_strncpy(data->lines[0], but->tip, sizeof(data->lines[0]));
|
||||
data->totline= 1;
|
||||
|
||||
if(but->optype && !(but->block->flag & UI_BLOCK_LOOP)) {
|
||||
/* operator keymap (not menus, they already have it) */
|
||||
prop= (but->opptr)? but->opptr->data: NULL;
|
||||
|
||||
if(WM_key_event_operator_string(C, but->optype->idname, but->opcontext, prop, buf, sizeof(buf))) {
|
||||
BLI_snprintf(data->lines[data->totline], sizeof(data->lines[0]), "Shortcut: %s", buf);
|
||||
data->totline++;
|
||||
}
|
||||
}
|
||||
|
||||
if(ELEM3(but->type, TEX, IDPOIN, SEARCH_MENU)) {
|
||||
/* full string */
|
||||
ui_get_but_string(but, buf, sizeof(buf));
|
||||
BLI_snprintf(data->lines[data->totline], sizeof(data->lines[0]), "Value: %s", buf);
|
||||
data->totline++;
|
||||
}
|
||||
|
||||
if(but->rnaprop) {
|
||||
if(but->flag & UI_BUT_DRIVEN) {
|
||||
if(ui_but_anim_expression_get(but, buf, sizeof(buf))) {
|
||||
/* expression */
|
||||
BLI_snprintf(data->lines[data->totline], sizeof(data->lines[0]), "Expression: %s", buf);
|
||||
data->totline++;
|
||||
}
|
||||
}
|
||||
|
||||
/* rna info */
|
||||
BLI_snprintf(data->lines[data->totline], sizeof(data->lines[0]), "Python: %s.%s", RNA_struct_identifier(but->rnapoin.type), RNA_property_identifier(but->rnaprop));
|
||||
data->totline++;
|
||||
}
|
||||
|
||||
/* set font, get bb */
|
||||
data->fstyle= style->widget; /* copy struct */
|
||||
data->fstyle.align= UI_STYLE_TEXT_CENTER;
|
||||
ui_fontscale(&data->fstyle.points, aspect);
|
||||
uiStyleFontSet(&data->fstyle);
|
||||
fontw= aspect * BLF_width(data->tip);
|
||||
fonth= aspect * BLF_height(data->tip);
|
||||
|
||||
h= BLF_height(data->lines[0]);
|
||||
|
||||
for(a=0, fontw=0, fonth=0; a<data->totline; a++) {
|
||||
w= BLF_width(data->lines[a]);
|
||||
fontw= MAX2(fontw, w);
|
||||
fonth += (a == 0)? h: h+5;
|
||||
}
|
||||
|
||||
fontw *= aspect;
|
||||
fonth *= aspect;
|
||||
|
||||
ar->regiondata= data;
|
||||
|
||||
data->toth= fonth;
|
||||
data->lineh= h*aspect;
|
||||
data->spaceh= 5*aspect;
|
||||
|
||||
/* compute position */
|
||||
ofsx= (but->block->panel)? but->block->panel->ofsx: 0;
|
||||
ofsy= (but->block->panel)? but->block->panel->ofsy: 0;
|
||||
|
@ -85,15 +85,6 @@ typedef struct uiWidgetTrias {
|
||||
|
||||
} uiWidgetTrias;
|
||||
|
||||
typedef struct uiWidgetStateColors {
|
||||
char inner_anim[4];
|
||||
char inner_anim_sel[4];
|
||||
char inner_key[4];
|
||||
char inner_key_sel[4];
|
||||
char inner_driven[4];
|
||||
char inner_driven_sel[4];
|
||||
} uiWidgetStateColors;
|
||||
|
||||
typedef struct uiWidgetBase {
|
||||
|
||||
int totvert, halfwayvert;
|
||||
@ -116,6 +107,7 @@ typedef struct uiWidgetType {
|
||||
|
||||
/* pointer to theme color definition */
|
||||
uiWidgetColors *wcol_theme;
|
||||
uiWidgetStateColors *wcol_state;
|
||||
|
||||
/* converted colors for state */
|
||||
uiWidgetColors wcol;
|
||||
@ -918,6 +910,7 @@ static void widget_draw_text_icon(uiFontStyle *fstyle, uiWidgetColors *wcol, uiB
|
||||
char inner_key_sel[4];
|
||||
char inner_driven[4];
|
||||
char inner_driven_sel[4];
|
||||
float blend;
|
||||
|
||||
*/
|
||||
|
||||
@ -925,9 +918,10 @@ static struct uiWidgetStateColors wcol_state= {
|
||||
{115, 190, 76, 255},
|
||||
{90, 166, 51, 255},
|
||||
{240, 235, 100, 255},
|
||||
{148, 204, 76, 255},
|
||||
{215, 211, 75, 255},
|
||||
{180, 0, 255, 255},
|
||||
{153, 0, 230, 255}
|
||||
{153, 0, 230, 255},
|
||||
0.5f, 0.0f
|
||||
};
|
||||
|
||||
/* uiWidgetColors
|
||||
@ -1147,7 +1141,6 @@ static struct uiWidgetColors wcol_tmp= {
|
||||
/* called for theme init (new theme) and versions */
|
||||
void ui_widget_color_init(ThemeUI *tui)
|
||||
{
|
||||
|
||||
tui->wcol_regular= wcol_regular;
|
||||
tui->wcol_tool= wcol_tool;
|
||||
tui->wcol_text= wcol_text;
|
||||
@ -1162,24 +1155,37 @@ void ui_widget_color_init(ThemeUI *tui)
|
||||
tui->wcol_menu_item= wcol_menu_item;
|
||||
tui->wcol_box= wcol_box;
|
||||
tui->wcol_scroll= wcol_scroll;
|
||||
|
||||
tui->wcol_state= wcol_state;
|
||||
}
|
||||
|
||||
/* ************ button callbacks, state ***************** */
|
||||
|
||||
static void widget_state_blend(char *cp, char *cpstate, float fac)
|
||||
{
|
||||
if(fac != 0.0f) {
|
||||
cp[0]= (int)((1.0f-fac)*cp[0] + fac*cpstate[0]);
|
||||
cp[1]= (int)((1.0f-fac)*cp[1] + fac*cpstate[1]);
|
||||
cp[2]= (int)((1.0f-fac)*cp[2] + fac*cpstate[2]);
|
||||
}
|
||||
}
|
||||
|
||||
/* copy colors from theme, and set changes in it based on state */
|
||||
static void widget_state(uiWidgetType *wt, int state)
|
||||
{
|
||||
uiWidgetStateColors *wcol_state= wt->wcol_state;
|
||||
|
||||
wt->wcol= *(wt->wcol_theme);
|
||||
|
||||
if(state & UI_SELECT) {
|
||||
QUATCOPY(wt->wcol.inner, wt->wcol.inner_sel)
|
||||
|
||||
if(state & UI_BUT_ANIMATED_KEY)
|
||||
QUATCOPY(wt->wcol.inner, wcol_state.inner_key_sel)
|
||||
widget_state_blend(wt->wcol.inner, wcol_state->inner_key_sel, wcol_state->blend);
|
||||
else if(state & UI_BUT_ANIMATED)
|
||||
QUATCOPY(wt->wcol.inner, wcol_state.inner_anim_sel)
|
||||
widget_state_blend(wt->wcol.inner, wcol_state->inner_anim_sel, wcol_state->blend);
|
||||
else if(state & UI_BUT_DRIVEN)
|
||||
QUATCOPY(wt->wcol.inner, wcol_state.inner_driven_sel)
|
||||
else
|
||||
QUATCOPY(wt->wcol.inner, wt->wcol.inner_sel)
|
||||
widget_state_blend(wt->wcol.inner, wcol_state->inner_driven_sel, wcol_state->blend);
|
||||
|
||||
VECCOPY(wt->wcol.text, wt->wcol.text_sel);
|
||||
|
||||
@ -1190,11 +1196,11 @@ static void widget_state(uiWidgetType *wt, int state)
|
||||
}
|
||||
else {
|
||||
if(state & UI_BUT_ANIMATED_KEY)
|
||||
QUATCOPY(wt->wcol.inner, wcol_state.inner_key)
|
||||
widget_state_blend(wt->wcol.inner, wcol_state->inner_key, wcol_state->blend);
|
||||
else if(state & UI_BUT_ANIMATED)
|
||||
QUATCOPY(wt->wcol.inner, wcol_state.inner_anim)
|
||||
widget_state_blend(wt->wcol.inner, wcol_state->inner_anim, wcol_state->blend);
|
||||
else if(state & UI_BUT_DRIVEN)
|
||||
QUATCOPY(wt->wcol.inner, wcol_state.inner_driven)
|
||||
widget_state_blend(wt->wcol.inner, wcol_state->inner_driven, wcol_state->blend);
|
||||
|
||||
if(state & UI_ACTIVE) { /* mouse over? */
|
||||
wt->wcol.inner[0]= wt->wcol.inner[0]>=240? 255 : wt->wcol.inner[0]+15;
|
||||
@ -2039,6 +2045,7 @@ static uiWidgetType *widget_type(uiWidgetTypeEnum type)
|
||||
|
||||
/* defaults */
|
||||
wt.wcol_theme= &btheme->tui.wcol_regular;
|
||||
wt.wcol_state= &btheme->tui.wcol_state;
|
||||
wt.state= widget_state;
|
||||
wt.draw= widget_but;
|
||||
wt.custom= NULL;
|
||||
|
@ -377,6 +377,9 @@ static void buttons_area_listener(ScrArea *sa, wmNotifier *wmn)
|
||||
ED_area_tag_redraw(sa);
|
||||
sbuts->preview= 1;
|
||||
}
|
||||
|
||||
if(wmn->data == ND_KEYS)
|
||||
ED_area_tag_redraw(sa);
|
||||
}
|
||||
|
||||
/* only called once, from space/spacetypes.c */
|
||||
|
@ -3239,7 +3239,7 @@ static void do_outliner_drivers_editop(SpaceOops *soops, ListBase *tree, short m
|
||||
case DRIVERS_EDITMODE_ADD:
|
||||
{
|
||||
/* add a new driver with the information obtained (only if valid) */
|
||||
ANIM_add_driver(id, path, array_index, flag);
|
||||
ANIM_add_driver(id, path, array_index, flag, DRIVER_TYPE_AVERAGE);
|
||||
}
|
||||
break;
|
||||
case DRIVERS_EDITMODE_REMOVE:
|
||||
|
@ -95,13 +95,7 @@ static int text_font_draw_character(SpaceText *st, int x, int y, char c)
|
||||
BLF_position(x, y, 0);
|
||||
BLF_draw(str);
|
||||
|
||||
return text_font_width_character(st);
|
||||
}
|
||||
|
||||
int text_font_width_character(SpaceText *st)
|
||||
{
|
||||
// XXX need quick BLF function, or cache it somewhere
|
||||
return (st->lheight == 12)? 7: 9;
|
||||
return st->cwidth;
|
||||
}
|
||||
|
||||
int text_font_width(SpaceText *st, char *str)
|
||||
@ -523,7 +517,7 @@ int wrap_width(SpaceText *st, ARegion *ar)
|
||||
int x, max;
|
||||
|
||||
x= st->showlinenrs ? TXT_OFFSET + TEXTXLOC : TXT_OFFSET;
|
||||
max= (ar->winx-x)/text_font_width_character(st);
|
||||
max= (ar->winx-x)/st->cwidth;
|
||||
return max>8 ? max : 8;
|
||||
}
|
||||
|
||||
@ -615,7 +609,7 @@ static int text_draw_wrapped(SpaceText *st, char *str, int x, int y, int w, char
|
||||
|
||||
len= flatten_string(st, &fs, str);
|
||||
str= fs.buf;
|
||||
max= w/text_font_width_character(st);
|
||||
max= w/st->cwidth;
|
||||
if(max<8) max= 8;
|
||||
basex= x;
|
||||
|
||||
@ -687,7 +681,7 @@ static int text_draw(SpaceText *st, char *str, int cshift, int maxwidth, int dra
|
||||
}
|
||||
else {
|
||||
while(w-- && *acc++ < maxwidth)
|
||||
r+= text_font_width_character(st);
|
||||
r+= st->cwidth;
|
||||
}
|
||||
|
||||
flatten_string_free(&fs);
|
||||
@ -877,18 +871,18 @@ static void draw_markers(SpaceText *st, ARegion *ar)
|
||||
if(y1==y2) {
|
||||
y -= y1*st->lheight;
|
||||
glBegin(GL_LINE_LOOP);
|
||||
glVertex2i(x+x2*text_font_width_character(st)+1, y);
|
||||
glVertex2i(x+x1*text_font_width_character(st)-2, y);
|
||||
glVertex2i(x+x1*text_font_width_character(st)-2, y-st->lheight);
|
||||
glVertex2i(x+x2*text_font_width_character(st)+1, y-st->lheight);
|
||||
glVertex2i(x+x2*st->cwidth+1, y);
|
||||
glVertex2i(x+x1*st->cwidth-2, y);
|
||||
glVertex2i(x+x1*st->cwidth-2, y-st->lheight);
|
||||
glVertex2i(x+x2*st->cwidth+1, y-st->lheight);
|
||||
glEnd();
|
||||
}
|
||||
else {
|
||||
y -= y1*st->lheight;
|
||||
glBegin(GL_LINE_STRIP);
|
||||
glVertex2i(ar->winx, y);
|
||||
glVertex2i(x+x1*text_font_width_character(st)-2, y);
|
||||
glVertex2i(x+x1*text_font_width_character(st)-2, y-st->lheight);
|
||||
glVertex2i(x+x1*st->cwidth-2, y);
|
||||
glVertex2i(x+x1*st->cwidth-2, y-st->lheight);
|
||||
glVertex2i(ar->winx, y-st->lheight);
|
||||
glEnd();
|
||||
y-=st->lheight;
|
||||
@ -905,8 +899,8 @@ static void draw_markers(SpaceText *st, ARegion *ar)
|
||||
|
||||
glBegin(GL_LINE_STRIP);
|
||||
glVertex2i(x, y);
|
||||
glVertex2i(x+x2*text_font_width_character(st)+1, y);
|
||||
glVertex2i(x+x2*text_font_width_character(st)+1, y-st->lheight);
|
||||
glVertex2i(x+x2*st->cwidth+1, y);
|
||||
glVertex2i(x+x2*st->cwidth+1, y-st->lheight);
|
||||
glVertex2i(x, y-st->lheight);
|
||||
glEnd();
|
||||
}
|
||||
@ -940,18 +934,18 @@ static void draw_documentation(SpaceText *st, ARegion *ar)
|
||||
if(l<0) return;
|
||||
|
||||
if(st->showlinenrs) {
|
||||
x= text_font_width_character(st)*(st->text->curc-st->left) + TXT_OFFSET + TEXTXLOC - 4;
|
||||
x= st->cwidth*(st->text->curc-st->left) + TXT_OFFSET + TEXTXLOC - 4;
|
||||
}
|
||||
else {
|
||||
x= text_font_width_character(st)*(st->text->curc-st->left) + TXT_OFFSET - 4;
|
||||
x= st->cwidth*(st->text->curc-st->left) + TXT_OFFSET - 4;
|
||||
}
|
||||
if(texttool_suggest_first()) {
|
||||
x += SUGG_LIST_WIDTH*text_font_width_character(st) + 50;
|
||||
x += SUGG_LIST_WIDTH*st->cwidth + 50;
|
||||
}
|
||||
|
||||
top= y= ar->winy - st->lheight*l - 2;
|
||||
len= strlen(docs);
|
||||
boxw= DOC_WIDTH*text_font_width_character(st) + 20;
|
||||
boxw= DOC_WIDTH*st->cwidth + 20;
|
||||
boxh= (DOC_HEIGHT+1)*st->lheight;
|
||||
|
||||
/* Draw panel */
|
||||
@ -1034,14 +1028,14 @@ static void draw_suggestion_list(SpaceText *st, ARegion *ar)
|
||||
if(l<0) return;
|
||||
|
||||
if(st->showlinenrs) {
|
||||
x = text_font_width_character(st)*(st->text->curc-st->left) + TXT_OFFSET + TEXTXLOC - 4;
|
||||
x = st->cwidth*(st->text->curc-st->left) + TXT_OFFSET + TEXTXLOC - 4;
|
||||
}
|
||||
else {
|
||||
x = text_font_width_character(st)*(st->text->curc-st->left) + TXT_OFFSET - 4;
|
||||
x = st->cwidth*(st->text->curc-st->left) + TXT_OFFSET - 4;
|
||||
}
|
||||
y = ar->winy - st->lheight*l - 2;
|
||||
|
||||
boxw = SUGG_LIST_WIDTH*text_font_width_character(st) + 20;
|
||||
boxw = SUGG_LIST_WIDTH*st->cwidth + 20;
|
||||
boxh = SUGG_LIST_SIZE*st->lheight + 8;
|
||||
|
||||
UI_ThemeColor(TH_SHADE1);
|
||||
@ -1111,9 +1105,9 @@ static void draw_cursor(SpaceText *st, ARegion *ar)
|
||||
if(vcurl==vsell) {
|
||||
y -= vcurl*st->lheight;
|
||||
if(vcurc < vselc)
|
||||
glRecti(x+vcurc*text_font_width_character(st)-1, y, x+vselc*text_font_width_character(st), y-st->lheight);
|
||||
glRecti(x+vcurc*st->cwidth-1, y, x+vselc*st->cwidth, y-st->lheight);
|
||||
else
|
||||
glRecti(x+vselc*text_font_width_character(st)-1, y, x+vcurc*text_font_width_character(st), y-st->lheight);
|
||||
glRecti(x+vselc*st->cwidth-1, y, x+vcurc*st->cwidth, y-st->lheight);
|
||||
}
|
||||
else {
|
||||
int froml, fromc, tol, toc;
|
||||
@ -1128,11 +1122,11 @@ static void draw_cursor(SpaceText *st, ARegion *ar)
|
||||
}
|
||||
|
||||
y -= froml*st->lheight;
|
||||
glRecti(x+fromc*text_font_width_character(st)-1, y, ar->winx, y-st->lheight); y-=st->lheight;
|
||||
glRecti(x+fromc*st->cwidth-1, y, ar->winx, y-st->lheight); y-=st->lheight;
|
||||
for(i=froml+1; i<tol; i++)
|
||||
glRecti(x-4, y, ar->winx, y-st->lheight), y-=st->lheight;
|
||||
|
||||
glRecti(x-4, y, x+toc*text_font_width_character(st), y-st->lheight); y-=st->lheight;
|
||||
glRecti(x-4, y, x+toc*st->cwidth, y-st->lheight); y-=st->lheight;
|
||||
}
|
||||
}
|
||||
else {
|
||||
@ -1149,13 +1143,13 @@ static void draw_cursor(SpaceText *st, ARegion *ar)
|
||||
if(!hidden) {
|
||||
/* Draw the cursor itself (we draw the sel. cursor as this is the leading edge) */
|
||||
x= st->showlinenrs ? TXT_OFFSET + TEXTXLOC : TXT_OFFSET;
|
||||
x += vselc*text_font_width_character(st);
|
||||
x += vselc*st->cwidth;
|
||||
y= ar->winy-2 - vsell*st->lheight;
|
||||
|
||||
if(st->overwrite) {
|
||||
char ch= text->sell->line[text->selc];
|
||||
if(!ch) ch= ' ';
|
||||
w= text_font_width_character(st);
|
||||
w= st->cwidth;
|
||||
UI_ThemeColor(TH_HILITE);
|
||||
glRecti(x, y-st->lheight-1, x+w, y-st->lheight+1);
|
||||
}
|
||||
@ -1255,8 +1249,8 @@ static void draw_brackets(SpaceText *st, ARegion *ar)
|
||||
if(viewc >= 0){
|
||||
viewl= txt_get_span(text->lines.first, startl) - st->top + offl;
|
||||
|
||||
text_font_draw_character(st, x+viewc*text_font_width_character(st), y-viewl*st->lheight, ch);
|
||||
text_font_draw_character(st, x+viewc*text_font_width_character(st)+1, y-viewl*st->lheight, ch);
|
||||
text_font_draw_character(st, x+viewc*st->cwidth, y-viewl*st->lheight, ch);
|
||||
text_font_draw_character(st, x+viewc*st->cwidth+1, y-viewl*st->lheight, ch);
|
||||
}
|
||||
|
||||
/* draw closing bracket */
|
||||
@ -1267,8 +1261,8 @@ static void draw_brackets(SpaceText *st, ARegion *ar)
|
||||
if(viewc >= 0) {
|
||||
viewl= txt_get_span(text->lines.first, endl) - st->top + offl;
|
||||
|
||||
text_font_draw_character(st, x+viewc*text_font_width_character(st), y-viewl*st->lheight, ch);
|
||||
text_font_draw_character(st, x+viewc*text_font_width_character(st)+1, y-viewl*st->lheight, ch);
|
||||
text_font_draw_character(st, x+viewc*st->cwidth, y-viewl*st->lheight, ch);
|
||||
text_font_draw_character(st, x+viewc*st->cwidth+1, y-viewl*st->lheight, ch);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1313,6 +1307,8 @@ void draw_text_main(SpaceText *st, ARegion *ar)
|
||||
}
|
||||
|
||||
text_font_begin(st);
|
||||
st->cwidth= BLF_fixed_width();
|
||||
st->cwidth= MAX2(st->cwidth, 1);
|
||||
|
||||
/* draw cursor */
|
||||
draw_cursor(st, ar);
|
||||
@ -1371,6 +1367,14 @@ void draw_text_main(SpaceText *st, ARegion *ar)
|
||||
|
||||
/************************** update ***************************/
|
||||
|
||||
void text_update_character_width(SpaceText *st)
|
||||
{
|
||||
text_font_begin(st);
|
||||
st->cwidth= BLF_fixed_width();
|
||||
st->cwidth= MAX2(st->cwidth, 1);
|
||||
text_font_end(st);
|
||||
}
|
||||
|
||||
/* Moves the view to the cursor location,
|
||||
also used to make sure the view isnt outside the file */
|
||||
void text_update_cursor_moved(SpaceText *st, ARegion *ar)
|
||||
@ -1380,6 +1384,8 @@ void text_update_cursor_moved(SpaceText *st, ARegion *ar)
|
||||
|
||||
if(!text || !text->curl) return;
|
||||
|
||||
text_update_character_width(st);
|
||||
|
||||
i= txt_get_span(text->lines.first, text->sell);
|
||||
if(st->top+st->viewlines <= i || st->top > i)
|
||||
st->top= i - st->viewlines/2;
|
||||
@ -1391,7 +1397,7 @@ void text_update_cursor_moved(SpaceText *st, ARegion *ar)
|
||||
x= text_draw(st, text->sell->line, st->left, text->selc, 0, 0, 0, NULL);
|
||||
|
||||
if(x==0 || x>ar->winx)
|
||||
st->left= text->curc-0.5*(ar->winx)/text_font_width_character(st);
|
||||
st->left= text->curc-0.5*(ar->winx)/st->cwidth;
|
||||
}
|
||||
|
||||
if(st->top < 0) st->top= 0;
|
||||
|
@ -55,6 +55,7 @@ int text_font_width(struct SpaceText *st, char *str);
|
||||
|
||||
void text_update_line_edited(struct Text *text, struct TextLine *line);
|
||||
void text_update_edited(struct Text *text);
|
||||
void text_update_character_width(struct SpaceText *st);
|
||||
void text_update_cursor_moved(struct SpaceText *st, struct ARegion *ar);
|
||||
|
||||
#define TEXTXLOC 38
|
||||
|
@ -1289,6 +1289,8 @@ static void wrap_move_bol(SpaceText *st, ARegion *ar, short sel)
|
||||
Text *text= st->text;
|
||||
int offl, offc, lin;
|
||||
|
||||
text_update_character_width(st);
|
||||
|
||||
lin= txt_get_span(text->lines.first, text->sell);
|
||||
wrap_offset(st, ar, text->sell, text->selc, &offl, &offc);
|
||||
|
||||
@ -1307,6 +1309,8 @@ static void wrap_move_eol(SpaceText *st, ARegion *ar, short sel)
|
||||
Text *text= st->text;
|
||||
int offl, offc, lin, startl, c;
|
||||
|
||||
text_update_character_width(st);
|
||||
|
||||
lin= txt_get_span(text->lines.first, text->sell);
|
||||
wrap_offset(st, ar, text->sell, text->selc, &offl, &offc);
|
||||
startl= offl;
|
||||
@ -1331,6 +1335,8 @@ static void wrap_move_up(SpaceText *st, ARegion *ar, short sel)
|
||||
Text *text= st->text;
|
||||
int offl, offl_1, offc, fromline, toline, c, target;
|
||||
|
||||
text_update_character_width(st);
|
||||
|
||||
wrap_offset(st, ar, text->sell, 0, &offl_1, &offc);
|
||||
wrap_offset(st, ar, text->sell, text->selc, &offl, &offc);
|
||||
fromline= toline= txt_get_span(text->lines.first, text->sell);
|
||||
@ -1376,6 +1382,8 @@ static void wrap_move_down(SpaceText *st, ARegion *ar, short sel)
|
||||
Text *text= st->text;
|
||||
int offl, startoff, offc, fromline, toline, c, target;
|
||||
|
||||
text_update_character_width(st);
|
||||
|
||||
wrap_offset(st, ar, text->sell, text->selc, &offl, &offc);
|
||||
fromline= toline= txt_get_span(text->lines.first, text->sell);
|
||||
target= text->selc + offc;
|
||||
@ -1754,6 +1762,8 @@ static void scroll_apply(bContext *C, wmOperator *op, wmEvent *event)
|
||||
TextScroll *tsc= op->customdata;
|
||||
short *mval= event->mval;
|
||||
|
||||
text_update_character_width(st);
|
||||
|
||||
if(tsc->first) {
|
||||
tsc->old[0]= mval[0];
|
||||
tsc->old[1]= mval[1];
|
||||
@ -1763,7 +1773,7 @@ static void scroll_apply(bContext *C, wmOperator *op, wmEvent *event)
|
||||
}
|
||||
|
||||
if(!tsc->scrollbar) {
|
||||
tsc->delta[0]= (tsc->hold[0]-mval[0])/text_font_width_character(st);
|
||||
tsc->delta[0]= (tsc->hold[0]-mval[0])/st->cwidth;
|
||||
tsc->delta[1]= (mval[1]-tsc->hold[1])/st->lheight;
|
||||
}
|
||||
else
|
||||
@ -1906,6 +1916,8 @@ static void set_cursor_to_pos(SpaceText *st, ARegion *ar, int x, int y, int sel)
|
||||
int *charp;
|
||||
int w;
|
||||
|
||||
text_update_character_width(st);
|
||||
|
||||
if(sel) { linep= &text->sell; charp= &text->selc; }
|
||||
else { linep= &text->curl; charp= &text->curc; }
|
||||
|
||||
@ -1917,7 +1929,7 @@ static void set_cursor_to_pos(SpaceText *st, ARegion *ar, int x, int y, int sel)
|
||||
x-= TXT_OFFSET;
|
||||
|
||||
if(x<0) x= 0;
|
||||
x = (x/text_font_width_character(st)) + st->left;
|
||||
x = (x/st->cwidth) + st->left;
|
||||
|
||||
if(st->wordwrap) {
|
||||
int i, j, endj, curs, max, chop, start, end, chars, loop;
|
||||
|
@ -67,15 +67,17 @@ int text_do_suggest_select(SpaceText *st, ARegion *ar)
|
||||
for(tmp=st->text->curl, l=-st->top; tmp; tmp=tmp->prev, l++);
|
||||
if(l<0) return 0;
|
||||
|
||||
text_update_character_width(st);
|
||||
|
||||
if(st->showlinenrs) {
|
||||
x = text_font_width_character(st)*(st->text->curc-st->left) + TXT_OFFSET + TEXTXLOC - 4;
|
||||
x = st->cwidth*(st->text->curc-st->left) + TXT_OFFSET + TEXTXLOC - 4;
|
||||
}
|
||||
else {
|
||||
x = text_font_width_character(st)*(st->text->curc-st->left) + TXT_OFFSET - 4;
|
||||
x = st->cwidth*(st->text->curc-st->left) + TXT_OFFSET - 4;
|
||||
}
|
||||
y = ar->winy - st->lheight*l - 2;
|
||||
|
||||
w = SUGG_LIST_WIDTH*text_font_width_character(st) + 20;
|
||||
w = SUGG_LIST_WIDTH*st->cwidth + 20;
|
||||
h = SUGG_LIST_SIZE*st->lheight + 8;
|
||||
|
||||
// XXX getmouseco_areawin(mval);
|
||||
|
@ -510,7 +510,6 @@ void transform_autoik_update(TransInfo *t, short mode);
|
||||
int count_set_pose_transflags(int *out_mode, short around, struct Object *ob);
|
||||
|
||||
/* auto-keying stuff used by special_aftertrans_update */
|
||||
short autokeyframe_cfra_can_key(struct Scene *scene, struct Object *ob);
|
||||
void autokeyframe_ob_cb_func(struct Scene *scene, struct View3D *v3d, struct Object *ob, int tmode);
|
||||
void autokeyframe_pose_cb_func(struct Scene *scene, struct View3D *v3d, struct Object *ob, int tmode, short targetless_ik);
|
||||
|
||||
|
@ -4312,21 +4312,6 @@ static void clear_trans_object_base_flags(TransInfo *t)
|
||||
}
|
||||
}
|
||||
|
||||
/* auto-keyframing feature - checks for whether anything should be done for the current frame */
|
||||
// TODO: this should probably be done per channel instead...
|
||||
short autokeyframe_cfra_can_key(Scene *scene, Object *ob)
|
||||
{
|
||||
float cfra= (float)CFRA; // XXX for now, this will do
|
||||
|
||||
/* only filter if auto-key mode requires this */
|
||||
if (IS_AUTOKEY_ON(scene) == 0)
|
||||
return 0;
|
||||
else if (IS_AUTOKEY_MODE(scene, NORMAL))
|
||||
return 1;
|
||||
else
|
||||
return id_frame_has_keyframe(&ob->id, cfra, ANIMFILTER_KEYS_LOCAL);
|
||||
}
|
||||
|
||||
/* auto-keyframing feature - for objects
|
||||
* tmode: should be a transform mode
|
||||
*/
|
||||
@ -4335,7 +4320,8 @@ void autokeyframe_ob_cb_func(Scene *scene, View3D *v3d, Object *ob, int tmode)
|
||||
ID *id= &ob->id;
|
||||
FCurve *fcu;
|
||||
|
||||
if (autokeyframe_cfra_can_key(scene, ob)) {
|
||||
// TODO: this should probably be done per channel instead...
|
||||
if (autokeyframe_cfra_can_key(scene, id)) {
|
||||
AnimData *adt= ob->adt;
|
||||
float cfra= (float)CFRA; // xxx this will do for now
|
||||
short flag = 0;
|
||||
@ -4436,7 +4422,8 @@ void autokeyframe_pose_cb_func(Scene *scene, View3D *v3d, Object *ob, int tmode,
|
||||
bPoseChannel *pchan;
|
||||
FCurve *fcu;
|
||||
|
||||
if (autokeyframe_cfra_can_key(scene, ob)) {
|
||||
// TODO: this should probably be done per channel instead...
|
||||
if (autokeyframe_cfra_can_key(scene, id)) {
|
||||
float cfra= (float)CFRA;
|
||||
short flag= 0;
|
||||
char buf[512];
|
||||
|
@ -293,7 +293,8 @@ typedef struct SpaceText {
|
||||
int top, viewlines;
|
||||
short flags, menunr;
|
||||
|
||||
int lheight;
|
||||
short lheight; /* user preference */
|
||||
short cwidth; /* runtime computed */
|
||||
int left;
|
||||
int showlinenrs;
|
||||
int tabnumber;
|
||||
|
@ -122,6 +122,16 @@ typedef struct uiWidgetColors {
|
||||
short pad;
|
||||
} uiWidgetColors;
|
||||
|
||||
typedef struct uiWidgetStateColors {
|
||||
char inner_anim[4];
|
||||
char inner_anim_sel[4];
|
||||
char inner_key[4];
|
||||
char inner_key_sel[4];
|
||||
char inner_driven[4];
|
||||
char inner_driven_sel[4];
|
||||
float blend, pad;
|
||||
} uiWidgetStateColors;
|
||||
|
||||
typedef struct ThemeUI {
|
||||
|
||||
/* Interface Elements (buttons, menus, icons) */
|
||||
@ -131,6 +141,8 @@ typedef struct ThemeUI {
|
||||
uiWidgetColors wcol_menu, wcol_pulldown, wcol_menu_back, wcol_menu_item;
|
||||
uiWidgetColors wcol_box, wcol_scroll;
|
||||
|
||||
uiWidgetStateColors wcol_state;
|
||||
|
||||
char iconfile[80]; // FILE_MAXFILE length
|
||||
|
||||
} ThemeUI;
|
||||
|
@ -799,11 +799,6 @@ static void rna_def_space_text(BlenderRNA *brna)
|
||||
StructRNA *srna;
|
||||
PropertyRNA *prop;
|
||||
|
||||
static EnumPropertyItem font_size_items[] = {
|
||||
{12, "12", 0, "12", ""},
|
||||
{15, "15", 0, "15", ""},
|
||||
{0, NULL, 0, NULL, NULL}};
|
||||
|
||||
srna= RNA_def_struct(brna, "SpaceTextEditor", "Space");
|
||||
RNA_def_struct_sdna(srna, "SpaceText");
|
||||
RNA_def_struct_ui_text(srna, "Space Text Editor", "Text editor space data.");
|
||||
@ -848,9 +843,9 @@ static void rna_def_space_text(BlenderRNA *brna)
|
||||
RNA_def_property_ui_text(prop, "Tab Width", "Number of spaces to display tabs with.");
|
||||
RNA_def_property_update(prop, NC_TEXT|ND_DISPLAY, NULL);
|
||||
|
||||
prop= RNA_def_property(srna, "font_size", PROP_ENUM, PROP_NONE);
|
||||
RNA_def_property_enum_sdna(prop, NULL, "lheight");
|
||||
RNA_def_property_enum_items(prop, font_size_items);
|
||||
prop= RNA_def_property(srna, "font_size", PROP_INT, PROP_NONE);
|
||||
RNA_def_property_int_sdna(prop, NULL, "lheight");
|
||||
RNA_def_property_range(prop, 8, 32);
|
||||
RNA_def_property_ui_text(prop, "Font Size", "Font size to use for displaying the text.");
|
||||
RNA_def_property_update(prop, NC_TEXT|ND_DISPLAY, NULL);
|
||||
|
||||
|
@ -268,7 +268,50 @@ static void rna_def_userdef_theme_ui_wcol(BlenderRNA *brna)
|
||||
RNA_def_property_range(prop, -100, 100);
|
||||
RNA_def_property_ui_text(prop, "Shade Down", "");
|
||||
RNA_def_property_update(prop, NC_WINDOW, NULL);
|
||||
}
|
||||
|
||||
static void rna_def_userdef_theme_ui_wcol_state(BlenderRNA *brna)
|
||||
{
|
||||
StructRNA *srna;
|
||||
PropertyRNA *prop;
|
||||
|
||||
srna= RNA_def_struct(brna, "ThemeWidgetStateColors", NULL);
|
||||
RNA_def_struct_sdna(srna, "uiWidgetStateColors");
|
||||
RNA_def_struct_ui_text(srna, "Theme Widget State Color", "Theme settings for widget state colors.");
|
||||
|
||||
prop= RNA_def_property(srna, "inner_anim", PROP_FLOAT, PROP_COLOR);
|
||||
RNA_def_property_array(prop, 3);
|
||||
RNA_def_property_ui_text(prop, "Animated", "");
|
||||
RNA_def_property_update(prop, NC_WINDOW, NULL);
|
||||
|
||||
prop= RNA_def_property(srna, "inner_anim_sel", PROP_FLOAT, PROP_COLOR);
|
||||
RNA_def_property_array(prop, 3);
|
||||
RNA_def_property_ui_text(prop, "Animated Selected", "");
|
||||
RNA_def_property_update(prop, NC_WINDOW, NULL);
|
||||
|
||||
prop= RNA_def_property(srna, "inner_key", PROP_FLOAT, PROP_COLOR);
|
||||
RNA_def_property_array(prop, 3);
|
||||
RNA_def_property_ui_text(prop, "Keyframe", "");
|
||||
RNA_def_property_update(prop, NC_WINDOW, NULL);
|
||||
|
||||
prop= RNA_def_property(srna, "inner_key_sel", PROP_FLOAT, PROP_COLOR);
|
||||
RNA_def_property_array(prop, 3);
|
||||
RNA_def_property_ui_text(prop, "Keyframe Selected", "");
|
||||
RNA_def_property_update(prop, NC_WINDOW, NULL);
|
||||
|
||||
prop= RNA_def_property(srna, "inner_driven", PROP_FLOAT, PROP_COLOR);
|
||||
RNA_def_property_array(prop, 3);
|
||||
RNA_def_property_ui_text(prop, "Driven", "");
|
||||
RNA_def_property_update(prop, NC_WINDOW, NULL);
|
||||
|
||||
prop= RNA_def_property(srna, "inner_driven_sel", PROP_FLOAT, PROP_COLOR);
|
||||
RNA_def_property_array(prop, 3);
|
||||
RNA_def_property_ui_text(prop, "Driven Selected", "");
|
||||
RNA_def_property_update(prop, NC_WINDOW, NULL);
|
||||
|
||||
prop= RNA_def_property(srna, "blend", PROP_FLOAT, PROP_PERCENTAGE);
|
||||
RNA_def_property_ui_text(prop, "Blend", "");
|
||||
RNA_def_property_update(prop, NC_WINDOW, NULL);
|
||||
}
|
||||
|
||||
static void rna_def_userdef_theme_ui(BlenderRNA *brna)
|
||||
@ -277,6 +320,7 @@ static void rna_def_userdef_theme_ui(BlenderRNA *brna)
|
||||
PropertyRNA *prop;
|
||||
|
||||
rna_def_userdef_theme_ui_wcol(brna);
|
||||
rna_def_userdef_theme_ui_wcol_state(brna);
|
||||
|
||||
srna= RNA_def_struct(brna, "ThemeUserInterface", NULL);
|
||||
RNA_def_struct_sdna(srna, "ThemeUI");
|
||||
@ -366,6 +410,12 @@ static void rna_def_userdef_theme_ui(BlenderRNA *brna)
|
||||
RNA_def_property_ui_text(prop, "Scroll Widget Colors", "");
|
||||
RNA_def_property_update(prop, NC_WINDOW, NULL);
|
||||
|
||||
prop= RNA_def_property(srna, "wcol_state", PROP_POINTER, PROP_NEVER_NULL);
|
||||
RNA_def_property_pointer_sdna(prop, NULL, "wcol_state");
|
||||
RNA_def_property_struct_type(prop, "ThemeWidgetStateColors");
|
||||
RNA_def_property_ui_text(prop, "State Colors", "");
|
||||
RNA_def_property_update(prop, NC_WINDOW, NULL);
|
||||
|
||||
prop= RNA_def_property(srna, "icon_file", PROP_STRING, PROP_FILEPATH);
|
||||
RNA_def_property_string_sdna(prop, NULL, "iconfile");
|
||||
RNA_def_property_ui_text(prop, "Icon File", "");
|
||||
|
Loading…
Reference in New Issue
Block a user