UI: various changes

* View2D to region now returns ints instead of shorts.
* Use "Numpad" instead of "Pad" in automatic keymap menu info.
* Menus can now use buttons other than BUTM and SEPR, in
  particular TOG and ROW are now supported instead of flipping
  bits manually.
* Added a simpler uiDefMenu* api for making menus now, and it
  only supports Operator and RNA buttons at the moment, will be
  used in next commit. Not sure how this will evolve .. makes
  menu code look cleaner anyways.
* Ensure that interface code doesn't crash when getting unknown
  Operators and RNA properties, and display their buttons grayed
  out in that case.
This commit is contained in:
Brecht Van Lommel
2009-01-15 04:13:38 +00:00
parent ad50055610
commit f08032e8f9
14 changed files with 267 additions and 154 deletions

View File

@@ -770,7 +770,8 @@ static void gp_strokepoint_convertcoords (bGPDstroke *gps, bGPDspoint *pt, float
VecCopyf(p3d, &pt->x);
}
else {
short mval[2], mx, my;
short mval[2];
int mx, my;
float *fp= give_cursor(NULL, NULL); // XXX should be scene, v3d
float dvec[3];
@@ -778,15 +779,13 @@ static void gp_strokepoint_convertcoords (bGPDstroke *gps, bGPDspoint *pt, float
if (gps->flag & GP_STROKE_2DSPACE) {
// XXX
// View2D *v2d= spacelink_get_view2d(curarea->spacedata.first);
// UI_view2d_view_to_region(v2d, pt->x, pt->y, mval, mval+1);
// UI_view2d_view_to_region(v2d, pt->x, pt->y, &mx, &my);
}
else {
// XXX
// mval[0]= (short)(pt->x / 1000 * curarea->winx);
// mval[1]= (short)(pt->y / 1000 * curarea->winy);
// mx= (short)(pt->x / 1000 * curarea->winx);
// my= (short)(pt->y / 1000 * curarea->winy);
}
mx= mval[0];
my= mval[1];
/* convert screen coordinate to 3d coordinates
* - method taken from editview.c - mouse_cursor()
@@ -1551,7 +1550,7 @@ static void gp_stroke_eraser_dostroke (tGPsdata *p, short mval[], short mvalo[],
{
bGPDspoint *pt1, *pt2;
View3D *v3d= NULL;
short x0=0, y0=0, x1=0, y1=0;
int x0=0, y0=0, x1=0, y1=0;
short xyval[2];
int i;

View File

@@ -268,7 +268,7 @@ uiBut *uiDefButBitS(uiBlock *block, int type, int bit, int retval, char *str, sh
uiBut *uiDefButC(uiBlock *block, int type, int retval, char *str, short x1, short y1, short x2, short y2, char *poin, float min, float max, float a1, float a2, char *tip);
uiBut *uiDefButBitC(uiBlock *block, int type, int bit, int retval, char *str, short x1, short y1, short x2, short y2, char *poin, float min, float max, float a1, float a2, char *tip);
uiBut *uiDefButR(uiBlock *block, int type, int retval, char *str, short x1, short y1, short x2, short y2, struct PointerRNA *ptr, const char *propname, int index, float min, float max, float a1, float a2, char *tip);
uiBut *uiDefButO(struct bContext *C, uiBlock *block, int type, char *opname, int opcontext, char *str, short x1, short y1, short x2, short y2, char *tip);
uiBut *uiDefButO(uiBlock *block, int type, char *opname, int opcontext, char *str, short x1, short y1, short x2, short y2, char *tip);
uiBut *uiDefIconBut(uiBlock *block,
int type, int retval, int icon,
@@ -286,7 +286,7 @@ uiBut *uiDefIconButBitS(uiBlock *block, int type, int bit, int retval, int icon,
uiBut *uiDefIconButC(uiBlock *block, int type, int retval, int icon, short x1, short y1, short x2, short y2, char *poin, float min, float max, float a1, float a2, char *tip);
uiBut *uiDefIconButBitC(uiBlock *block, int type, int bit, int retval, int icon, short x1, short y1, short x2, short y2, char *poin, float min, float max, float a1, float a2, char *tip);
uiBut *uiDefIconButR(uiBlock *block, int type, int retval, int icon, short x1, short y1, short x2, short y2, struct PointerRNA *ptr, const char *propname, int index, float min, float max, float a1, float a2, char *tip);
uiBut *uiDefIconButO(struct bContext *C, uiBlock *block, int type, char *opname, int opcontext, int icon, short x1, short y1, short x2, short y2, char *tip);
uiBut *uiDefIconButO(uiBlock *block, int type, char *opname, int opcontext, int icon, short x1, short y1, short x2, short y2, char *tip);
uiBut *uiDefIconTextBut(uiBlock *block,
int type, int retval, int icon, char *str,
@@ -304,7 +304,7 @@ uiBut *uiDefIconTextButBitS(uiBlock *block, int type, int bit, int retval, int i
uiBut *uiDefIconTextButC(uiBlock *block, int type, int retval, int icon, char *str, short x1, short y1, short x2, short y2, char *poin, float min, float max, float a1, float a2, char *tip);
uiBut *uiDefIconTextButBitC(uiBlock *block, int type, int bit, int retval, int icon, char *str, short x1, short y1, short x2, short y2, char *poin, float min, float max, float a1, float a2, char *tip);
uiBut *uiDefIconTextButR(uiBlock *block, int type, int retval, int icon, char *str, short x1, short y1, short x2, short y2, struct PointerRNA *ptr, const char *propname, int index, float min, float max, float a1, float a2, char *tip);
uiBut *uiDefIconTextButO(struct bContext *C, uiBlock *block, int type, char *opname, int opcontext, int icon, char *str, short x1, short y1, short x2, short y2, char *tip);
uiBut *uiDefIconTextButO(uiBlock *block, int type, char *opname, int opcontext, int icon, char *str, short x1, short y1, short x2, short y2, char *tip);
typedef void (*uiIDPoinFuncFP) (struct bContext *C, char *str, struct ID **idpp);
uiBut *uiDefIDPoinBut(struct uiBlock *block, uiIDPoinFuncFP func, short blocktype, int retval, char *str,
@@ -318,6 +318,11 @@ uiBut *uiDefIconBlockBut(uiBlock *block, uiBlockFuncFP func, void *arg, int retv
void uiDefKeyevtButS(uiBlock *block, int retval, char *str, short x1, short y1, short x2, short y2, short *spoin, char *tip);
uiBut *uiDefMenuButO(uiBlock *block, char *opname, char *name);
uiBut *uiDefMenuSep(uiBlock *block);
uiBut *uiDefMenuSub(uiBlock *block, uiBlockFuncFP func, char *name);
uiBut *uiDefMenuTogR(uiBlock *block, struct PointerRNA *ptr, char *propname, char *propvalue, char *name);
void uiAutoBlock(struct uiBlock *block,
float minx, float miny,
float sizex, float sizey, int flag);

View File

@@ -875,13 +875,6 @@ enum {
};
/* XXX WARNING: previous is saved in file, so do not change order! */
/* theme drawtypes */
#define TH_MINIMAL 0
#define TH_ROUNDSHADED 1
#define TH_ROUNDED 2
#define TH_OLDSKOOL 3
#define TH_SHADED 4
/* specific defines per space should have higher define values */
struct bTheme;

View File

@@ -167,8 +167,8 @@ void UI_view2d_listview_visible_cells(struct View2D *v2d, short columnwidth, sho
/* coordinate conversion */
void UI_view2d_region_to_view(struct View2D *v2d, int x, int y, float *viewx, float *viewy);
void UI_view2d_view_to_region(struct View2D *v2d, float x, float y, short *regionx, short *regiony);
void UI_view2d_to_region_no_clip(struct View2D *v2d, float x, float y, short *regionx, short *region_y);
void UI_view2d_view_to_region(struct View2D *v2d, float x, float y, int *regionx, int *regiony);
void UI_view2d_to_region_no_clip(struct View2D *v2d, float x, float y, int *regionx, int *region_y);
/* utilities */
struct View2D *UI_view2d_fromcontext(const struct bContext *C);

View File

@@ -71,6 +71,10 @@
#include "interface_intern.h"
#define MENU_WIDTH 120
#define MENU_ITEM_HEIGHT 20
#define MENU_SEP_HEIGHT 6
/*
* a full doc with API notes can be found in bf-blender/blender/doc/interface_API.txt
*
@@ -475,6 +479,30 @@ static int ui_but_update_from_old_block(const bContext *C, uiBlock *block, uiBut
return found;
}
static void ui_menu_block_set_keymaps(const bContext *C, uiBlock *block)
{
uiBut *but;
char buf[512], *butstr;
/* XXX bounds? */
for(but=block->buttons.first; but; but=but->next) {
if(but->opname) {
if(WM_key_event_operator_string(C, but->opname, but->opcontext, buf, sizeof(buf))) {
butstr= MEM_mallocN(strlen(but->str)+strlen(buf)+2, "menu_block_set_keymaps");
strcpy(butstr, but->str);
strcat(butstr, "|");
strcat(butstr, buf);
but->str= but->strdata;
BLI_strncpy(but->str, butstr, sizeof(but->strdata));
MEM_freeN(butstr);
ui_check_but(but);
}
}
}
}
void uiEndBlock(const bContext *C, uiBlock *block)
{
uiBut *but;
@@ -494,8 +522,9 @@ void uiEndBlock(const bContext *C, uiBlock *block)
block->oldblock= NULL;
}
/* handle pending stuff */
if(block->flag & UI_BLOCK_LOOP) ui_menu_block_set_keymaps(C, block);
if(block->autofill) ui_autofill(block);
if(block->minx==0.0 && block->maxx==0.0) uiBoundsBlock(block, 0);
if(block->flag & UI_BUT_ALIGN) uiBlockEndAlign(block);
@@ -1489,6 +1518,7 @@ uiBlock *uiBeginBlock(const bContext *C, ARegion *region, char *name, short dt,
block->aspect= 2.0/fabs(getsizex*block->winmat[0][0]);
block->auto_open= 2;
block->flag |= UI_BLOCK_LOOP; /* tag as menu */
}
uiSetCurFont(block, font);
@@ -1676,7 +1706,7 @@ void ui_check_but(uiBut *but)
}
if(but->strwidth==0) but->drawstr[0]= 0;
else if(but->type==BUTM || but->type==BLOCK); // no clip string, uiTextBoundsBlock is used (hack!)
else if(but->block->flag & UI_BLOCK_LOOP); // no clip string, uiTextBoundsBlock is used (hack!)
else {
/* calc but->ofs, to draw the string shorter if too long */
@@ -1714,6 +1744,8 @@ void ui_check_but(uiBut *but)
static int ui_auto_themecol(uiBut *but)
{
if(but->block->flag & UI_BLOCK_LOOP)
return TH_MENU_ITEM;
switch(but->type) {
case BUT:
@@ -1737,8 +1769,6 @@ static int ui_auto_themecol(uiBut *but)
case BLOCK:
case MENU:
case BUTM:
// (weak!) detect if it is a blockloop
if(but->block->dt == UI_EMBOSSP) return TH_MENU_ITEM;
return TH_BUT_POPUP;
case ROUNDBOX:
return TH_PANEL;
@@ -1994,11 +2024,9 @@ static uiBut *ui_def_but(uiBlock *block, int type, int retval, char *str, short
if(block->themecol==TH_AUTO) but->themecol= ui_auto_themecol(but);
else but->themecol= block->themecol;
if(but->type != BUTM) {
but->func= block->func;
but->func_arg1= block->func_arg1;
but->func_arg2= block->func_arg2;
}
but->func= block->func;
but->func_arg1= block->func_arg1;
but->func_arg2= block->func_arg2;
ui_set_embossfunc(but, block->dt);
@@ -2020,7 +2048,7 @@ static uiBut *ui_def_but(uiBlock *block, int type, int retval, char *str, short
rgb_to_hsv(rgb[0], rgb[1], rgb[2], but->hsv, but->hsv+1, but->hsv+2);
}
if ELEM8(but->type, HSVSLI , NUMSLI, MENU, TEX, LABEL, IDPOIN, BLOCK, BUTM) {
if((block->flag & UI_BLOCK_LOOP) || ELEM8(but->type, HSVSLI , NUMSLI, MENU, TEX, LABEL, IDPOIN, BLOCK, BUTM)) {
but->flag |= UI_TEXT_LEFT;
}
@@ -2052,80 +2080,102 @@ uiBut *ui_def_but_rna(uiBlock *block, int type, int retval, char *str, short x1,
int freestr= 0;
prop= RNA_struct_find_property(ptr, propname);
if(!prop)
return NULL;
proptype= RNA_property_type(ptr, prop);
if(prop) {
proptype= RNA_property_type(ptr, prop);
/* use rna values if parameters are not specified */
if(!str) {
if(type == MENU && proptype == PROP_ENUM) {
const EnumPropertyItem *item;
DynStr *dynstr;
int i, totitem;
/* use rna values if parameters are not specified */
if(!str) {
if(type == MENU && proptype == PROP_ENUM) {
const EnumPropertyItem *item;
DynStr *dynstr;
int i, totitem;
RNA_property_enum_items(ptr, prop, &item, &totitem);
RNA_property_enum_items(ptr, prop, &item, &totitem);
dynstr= BLI_dynstr_new();
BLI_dynstr_appendf(dynstr, "%s%%t", RNA_property_ui_name(ptr, prop));
for(i=0; i<totitem; i++)
BLI_dynstr_appendf(dynstr, "|%s %%x%d", item[i].name, item[i].value);
str= BLI_dynstr_get_cstring(dynstr);
BLI_dynstr_free(dynstr);
dynstr= BLI_dynstr_new();
BLI_dynstr_appendf(dynstr, "%s%%t", RNA_property_ui_name(ptr, prop));
for(i=0; i<totitem; i++)
BLI_dynstr_appendf(dynstr, "|%s %%x%d", item[i].name, item[i].value);
str= BLI_dynstr_get_cstring(dynstr);
BLI_dynstr_free(dynstr);
freestr= 1;
}
else
str= (char*)RNA_property_ui_name(ptr, prop);
}
if(!tip)
tip= (char*)RNA_property_ui_description(ptr, prop);
if(min == max || a1 == -1 || a2 == -1) {
if(proptype == PROP_INT) {
int softmin, softmax, step;
RNA_property_int_ui_range(ptr, prop, &softmin, &softmax, &step);
if(min == max) {
min= softmin;
max= softmax;
freestr= 1;
}
if(a1 == -1)
a1= step;
if(a2 == -1)
a2= 0;
else
str= (char*)RNA_property_ui_name(ptr, prop);
}
else if(proptype == PROP_FLOAT) {
float softmin, softmax, step, precision;
RNA_property_float_ui_range(ptr, prop, &softmin, &softmax, &step, &precision);
if(!tip) {
if(type == ROW && proptype == PROP_ENUM) {
const EnumPropertyItem *item;
int i, totitem;
if(min == max) {
min= softmin;
max= softmax;
RNA_property_enum_items(ptr, prop, &item, &totitem);
for(i=0; i<totitem; i++) {
if(item[i].value == (int)max) {
if(item[i].description[0])
tip= (char*)item[i].description;
break;
}
}
}
if(a1 == -1)
a1= step;
if(a2 == -1)
a2= precision;
}
else if(proptype == PROP_STRING) {
min= 0;
max= RNA_property_string_maxlength(ptr, prop);
if(max == 0) /* interface code should ideally support unlimited length */
max= UI_MAX_DRAW_STR;
if(!tip)
tip= (char*)RNA_property_ui_description(ptr, prop);
if(min == max || a1 == -1 || a2 == -1) {
if(proptype == PROP_INT) {
int softmin, softmax, step;
RNA_property_int_ui_range(ptr, prop, &softmin, &softmax, &step);
if(min == max) {
min= softmin;
max= softmax;
}
if(a1 == -1)
a1= step;
if(a2 == -1)
a2= 0;
}
else if(proptype == PROP_FLOAT) {
float softmin, softmax, step, precision;
RNA_property_float_ui_range(ptr, prop, &softmin, &softmax, &step, &precision);
if(min == max) {
min= softmin;
max= softmax;
}
if(a1 == -1)
a1= step;
if(a2 == -1)
a2= precision;
}
else if(proptype == PROP_STRING) {
min= 0;
max= RNA_property_string_maxlength(ptr, prop);
if(max == 0) /* interface code should ideally support unlimited length */
max= UI_MAX_DRAW_STR;
}
}
}
else
str= (char*)propname;
/* now create button */
but= ui_def_but(block, type, retval, str, x1, y1, x2, y2, NULL, min, max, a1, a2, tip);
but->rnapoin= *ptr;
but->rnaprop= prop;
but->rnaindex= index;
if(prop) {
but->rnapoin= *ptr;
but->rnaprop= prop;
but->rnaindex= index;
}
if (!RNA_property_editable(&but->rnapoin, prop)) {
if (!prop || !RNA_property_editable(&but->rnapoin, prop)) {
but->flag |= UI_BUT_DISABLED;
but->lock = 1;
but->lockstr = "";
@@ -2137,33 +2187,27 @@ uiBut *ui_def_but_rna(uiBlock *block, int type, int retval, char *str, short x1,
return but;
}
uiBut *ui_def_but_operator(bContext *C, uiBlock *block, int type, char *opname, int opcontext, char *str, short x1, short y1, short x2, short y2, char *tip)
uiBut *ui_def_but_operator(uiBlock *block, int type, char *opname, int opcontext, char *str, short x1, short y1, short x2, short y2, char *tip)
{
uiBut *but;
char buf[100], *butstr;
wmOperatorType *ot;
ot= WM_operatortype_find(opname);
if(!str) {
wmOperatorType *ot= WM_operatortype_find(opname);
str= (ot)? ot->name: "";
if(ot) str= ot->name;
else str= opname;
}
butstr= str;
if(type == BUTM) {
if(WM_key_event_operator_string(C, opname, opcontext, buf, sizeof(buf))) {
butstr= MEM_mallocN(strlen(str)+strlen(buf)+2, "ui_def_but_operator");
strcpy(butstr, str);
strcat(butstr, "|");
strcat(butstr, buf);
}
}
but= ui_def_but(block, type, -1, butstr, x1, y1, x2, y2, NULL, 0, 0, 0, 0, tip);
but= ui_def_but(block, type, -1, str, x1, y1, x2, y2, NULL, 0, 0, 0, 0, tip);
but->opname= opname;
but->opcontext= opcontext;
if(butstr != str)
MEM_freeN(butstr);
if(!ot) {
but->flag |= UI_BUT_DISABLED;
but->lock = 1;
but->lockstr = "";
}
return but;
}
@@ -2323,11 +2367,11 @@ uiBut *uiDefButR(uiBlock *block, int type, int retval, char *str, short x1, shor
return but;
}
uiBut *uiDefButO(bContext *C, uiBlock *block, int type, char *opname, int opcontext, char *str, short x1, short y1, short x2, short y2, char *tip)
uiBut *uiDefButO(uiBlock *block, int type, char *opname, int opcontext, char *str, short x1, short y1, short x2, short y2, char *tip)
{
uiBut *but;
but= ui_def_but_operator(C, block, type, opname, opcontext, str, x1, y1, x2, y2, tip);
but= ui_def_but_operator(block, type, opname, opcontext, str, x1, y1, x2, y2, tip);
if(but)
ui_check_but(but);
@@ -2400,11 +2444,11 @@ uiBut *uiDefIconButR(uiBlock *block, int type, int retval, int icon, short x1, s
return but;
}
uiBut *uiDefIconButO(bContext *C, uiBlock *block, int type, char *opname, int opcontext, int icon, short x1, short y1, short x2, short y2, char *tip)
uiBut *uiDefIconButO(uiBlock *block, int type, char *opname, int opcontext, int icon, short x1, short y1, short x2, short y2, char *tip)
{
uiBut *but;
but= ui_def_but_operator(C, block, type, opname, opcontext, "", x1, y1, x2, y2, tip);
but= ui_def_but_operator(block, type, opname, opcontext, "", x1, y1, x2, y2, tip);
if(but) {
but->icon= (BIFIconID) icon;
but->flag|= UI_HAS_ICON;
@@ -2484,11 +2528,11 @@ uiBut *uiDefIconTextButR(uiBlock *block, int type, int retval, int icon, char *s
return but;
}
uiBut *uiDefIconTextButO(bContext *C, uiBlock *block, int type, char *opname, int opcontext, int icon, char *str, short x1, short y1, short x2, short y2, char *tip)
uiBut *uiDefIconTextButO(uiBlock *block, int type, char *opname, int opcontext, int icon, char *str, short x1, short y1, short x2, short y2, char *tip)
{
uiBut *but;
but= ui_def_but_operator(C, block, type, opname, opcontext, str, x1, y1, x2, y2, tip);
but= ui_def_but_operator(block, type, opname, opcontext, str, x1, y1, x2, y2, tip);
if(but) {
but->icon= (BIFIconID) icon;
but->flag|= UI_HAS_ICON;
@@ -2499,6 +2543,80 @@ uiBut *uiDefIconTextButO(bContext *C, uiBlock *block, int type, char *opname, in
return but;
}
static int ui_menu_y(uiBlock *block)
{
uiBut *but= block->buttons.last;
if(but) return but->y1;
else return 0;
}
uiBut *uiDefMenuButO(uiBlock *block, char *opname, char *name)
{
int y= ui_menu_y(block) - MENU_ITEM_HEIGHT;
return uiDefIconTextButO(block, BUT, opname, WM_OP_INVOKE_REGION_WIN, ICON_BLANK1, name, 0, y, MENU_WIDTH, MENU_ITEM_HEIGHT-1, NULL);
}
uiBut *uiDefMenuSep(uiBlock *block)
{
int y= ui_menu_y(block) - MENU_SEP_HEIGHT;
return uiDefBut(block, SEPR, 0, "", 0, y, MENU_WIDTH, MENU_SEP_HEIGHT, NULL, 0.0, 0.0, 0, 0, "");
}
uiBut *uiDefMenuSub(uiBlock *block, uiBlockFuncFP func, char *name)
{
int y= ui_menu_y(block) - MENU_ITEM_HEIGHT;
return uiDefIconTextBlockBut(block, func, NULL, ICON_RIGHTARROW_THIN, name, 0, y, MENU_WIDTH, MENU_ITEM_HEIGHT-1, "");
}
uiBut *uiDefMenuTogR(uiBlock *block, PointerRNA *ptr, char *propname, char *propvalue, char *name)
{
uiBut *but;
PropertyRNA *prop;
PropertyType type;
const EnumPropertyItem *item;
int a, value, totitem, icon= ICON_CHECKBOX_DEHLT;
int y= ui_menu_y(block) - MENU_ITEM_HEIGHT;
prop= RNA_struct_find_property(ptr, propname);
if(prop) {
type= RNA_property_type(ptr, prop);
if(type == PROP_BOOLEAN) {
if(RNA_property_boolean_get(ptr, prop))
icon= ICON_CHECKBOX_HLT;
return uiDefIconTextButR(block, TOG, 0, icon, name, 0, y, MENU_WIDTH, MENU_ITEM_HEIGHT-1, ptr, propname, 0, 0, 0, 0, 0, NULL);
}
else if(type == PROP_ENUM) {
RNA_property_enum_items(ptr, prop, &item, &totitem);
value= 0;
for(a=0; a<totitem; a++) {
if(propvalue && strcmp(propvalue, item[a].identifier) == 0) {
value= item[a].value;
if(!name)
name= (char*)item[a].name;
if(RNA_property_enum_get(ptr, prop) == value)
icon= ICON_CHECKBOX_HLT;
break;
}
}
if(a != totitem)
return uiDefIconTextButR(block, ROW, 0, icon, name, 0, y, MENU_WIDTH, MENU_ITEM_HEIGHT-1, ptr, propname, 0, 0, value, 0, 0, NULL);
}
}
/* not found */
uiBlockSetButLock(block, 1, "");
but= uiDefIconTextBut(block, BUT, 0, ICON_BLANK1, propname, 0, y, MENU_WIDTH, MENU_ITEM_HEIGHT, NULL, 0.0, 0.0, 0, 0, "");
uiBlockClearButLock(block);
return but;
}
/* END Button containing both string label and icon */
void uiAutoBlock(uiBlock *block, float minx, float miny, float sizex, float sizey, int flag)

View File

@@ -682,7 +682,7 @@ static void ui_draw_icon(uiBut *but, BIFIconID icon, int blend)
xs= (but->x1+but->x2- height)/2.0;
}
}
else if (but->type==BUTM ) {
else if (but->block->flag & UI_BLOCK_LOOP) {
xs= but->x1+1.0;
}
else if ((but->type==ICONROW) || (but->type==ICONTEXTROW)) {
@@ -2362,7 +2362,7 @@ static void ui_draw_text_icon(uiBut *but)
/* text color, with pulldown item exception */
if(tog3); // color already set
else if(but->dt==UI_EMBOSSP) {
if((but->flag & (UI_SELECT|UI_ACTIVE)) && but->type!=LABEL) { // LABEL = title in pulldowns
if((but->flag & UI_ACTIVE) && but->type!=LABEL) { // LABEL = title in pulldowns
UI_ThemeColorShadeAlpha(TH_MENU_TEXT_HI, 0, alpha_offs);
} else {
UI_ThemeColorShadeAlpha(TH_MENU_TEXT, 0, alpha_offs);

View File

@@ -347,11 +347,8 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but)
if(butregion) {
/* XXX temp, region v2ds can be empty still */
if(butregion->v2d.cur.xmin != butregion->v2d.cur.xmax) {
short tx, ty;
UI_view2d_to_region_no_clip(&butregion->v2d, x1, y1, &tx, &ty);
x1= (int)tx; y1= (int)ty;
UI_view2d_to_region_no_clip(&butregion->v2d, x2, y2, &tx, &ty);
x2= (int)tx; y2= (int)ty;
UI_view2d_to_region_no_clip(&butregion->v2d, x1, y1, &x1, &y1);
UI_view2d_to_region_no_clip(&butregion->v2d, x2, y2, &x2, &y2);
}
x1 += butregion->winrct.xmin;

View File

@@ -25,8 +25,9 @@
* ***** END GPL LICENSE BLOCK *****
*/
#include <string.h>
#include <limits.h>
#include <math.h>
#include <string.h>
#include "MEM_guardedalloc.h"
@@ -1703,7 +1704,7 @@ void UI_view2d_region_to_view(View2D *v2d, int x, int y, float *viewx, float *vi
* - x,y = coordinates to convert
* - regionx,regiony = resultant coordinates
*/
void UI_view2d_view_to_region(View2D *v2d, float x, float y, short *regionx, short *regiony)
void UI_view2d_view_to_region(View2D *v2d, float x, float y, int *regionx, int *regiony)
{
/* set initial value in case coordinate lies outside of bounds */
if (regionx)
@@ -1718,9 +1719,9 @@ void UI_view2d_view_to_region(View2D *v2d, float x, float y, short *regionx, sho
/* check if values are within bounds */
if ((x>=0.0f) && (x<=1.0f) && (y>=0.0f) && (y<=1.0f)) {
if (regionx)
*regionx= (short)(v2d->mask.xmin + x*(v2d->mask.xmax-v2d->mask.xmin));
*regionx= (int)(v2d->mask.xmin + x*(v2d->mask.xmax-v2d->mask.xmin));
if (regiony)
*regiony= (short)(v2d->mask.ymin + y*(v2d->mask.ymax-v2d->mask.ymin));
*regiony= (int)(v2d->mask.ymin + y*(v2d->mask.ymax-v2d->mask.ymin));
}
}
@@ -1730,7 +1731,7 @@ void UI_view2d_view_to_region(View2D *v2d, float x, float y, short *regionx, sho
* - x,y = coordinates to convert
* - regionx,regiony = resultant coordinates
*/
void UI_view2d_to_region_no_clip(View2D *v2d, float x, float y, short *regionx, short *regiony)
void UI_view2d_to_region_no_clip(View2D *v2d, float x, float y, int *regionx, int *regiony)
{
/* step 1: express given coordinates as proportional values */
x= (x - v2d->cur.xmin) / (v2d->cur.xmax - v2d->cur.xmin);
@@ -1740,16 +1741,16 @@ void UI_view2d_to_region_no_clip(View2D *v2d, float x, float y, short *regionx,
x= v2d->mask.xmin + x*(v2d->mask.xmax - v2d->mask.xmin);
y= v2d->mask.ymin + y*(v2d->mask.ymax - v2d->mask.ymin);
/* although we don't clamp to lie within region bounds, we must avoid exceeding size of shorts */
/* although we don't clamp to lie within region bounds, we must avoid exceeding size of ints */
if (regionx) {
if (x < -32760) *regionx= -32760;
else if(x > 32760) *regionx= 32760;
else *regionx= (short)x;
if (x < INT_MIN) *regionx= INT_MIN;
else if(x > INT_MAX) *regionx= INT_MAX;
else *regionx= (int)x;
}
if (regiony) {
if (y < -32760) *regiony= -32760;
else if(y > 32760) *regiony= 32760;
else *regiony= (short)y;
if (y < INT_MIN) *regiony= INT_MIN;
else if(y > INT_MAX) *regiony= INT_MAX;
else *regiony= (int)y;
}
}

View File

@@ -525,7 +525,7 @@ static void draw_seq_text(View2D *v2d, Sequence *seq, float x1, float x2, float
float v1[2], v2[2];
int len, size;
char str[32 + FILE_MAXDIR+FILE_MAXFILE], *strp;
short mval[2];
int mval[2];
v1[1]= y1;
v2[1]= y2;

View File

@@ -302,18 +302,18 @@ static uiBlock *time_framemenu(bContext *C, uiMenuBlockHandle *handle, void *arg
block= uiBeginBlock(C, handle->region, "time_framemenu", UI_EMBOSSP, UI_HELV);
uiBlockSetButmFunc(block, do_time_framemenu, NULL);
uiDefIconTextButO(C, block, BUTM, "MARKER_OT_add", WM_OP_EXEC_REGION_WIN, ICON_BLANK1, "Add Marker",
uiDefIconTextButO(block, BUTM, "MARKER_OT_add", WM_OP_EXEC_REGION_WIN, ICON_BLANK1, "Add Marker",
0, yco-=2, menuwidth, 19, "");
uiDefIconTextButO(C, block, BUTM, "MARKER_OT_duplicate", WM_OP_EXEC_REGION_WIN, ICON_BLANK1, "Duplicate Marker",
uiDefIconTextButO(block, BUTM, "MARKER_OT_duplicate", WM_OP_EXEC_REGION_WIN, ICON_BLANK1, "Duplicate Marker",
0, yco-=20, menuwidth, 19, "");
uiDefIconTextButO(C, block, BUTM, "MARKER_OT_delete", WM_OP_EXEC_REGION_WIN, ICON_BLANK1, "Delete Marker",
uiDefIconTextButO(block, BUTM, "MARKER_OT_delete", WM_OP_EXEC_REGION_WIN, ICON_BLANK1, "Delete Marker",
0, yco-=20, menuwidth, 19, "");
uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Name Marker|Ctrl M",
0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 3, "");
uiDefIconTextButO(C, block, BUTM, "MARKER_OT_move", WM_OP_INVOKE_REGION_WIN, ICON_BLANK1, "Grab/Move Marker",
uiDefIconTextButO(block, BUTM, "MARKER_OT_move", WM_OP_INVOKE_REGION_WIN, ICON_BLANK1, "Grab/Move Marker",
0, yco-=20, menuwidth, 19, "");
uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");

View File

@@ -244,7 +244,7 @@ void projectIntView(TransInfo *t, float *vec, int *adr)
//uvco_to_areaco_noclip(v, adr);
}
else if(t->spacetype==SPACE_IPO) {
short out[2] = {0.0f, 0.0f};
int out[2] = {0, 0};
UI_view2d_view_to_region((View2D *)t->view, vec[0], vec[1], out, out+1);
adr[0]= out[0];

View File

@@ -77,7 +77,7 @@ ListBase *WM_keymap_listbase (struct wmWindowManager *wm, const char *nameid,
int spaceid, int regionid);
char *WM_key_event_string(short type);
char *WM_key_event_operator_string(struct bContext *C, char *opname, int opcontext, char *str, int len);
char *WM_key_event_operator_string(const struct bContext *C, const char *opname, int opcontext, char *str, int len);
/* handlers */

View File

@@ -373,54 +373,54 @@ char *WM_key_event_string(short type)
break;
case PAD2:
return "Pad2";
return "Numpad 2";
break;
case PAD4:
return "Pad4";
return "Numpad 4";
break;
case PAD6:
return "Pad6";
return "Numpad 6";
break;
case PAD8:
return "Pad8";
return "Numpad 8";
break;
case PAD1:
return "Pad1";
return "Numpad 1";
break;
case PAD3:
return "Pad3";
return "Numpad 3";
break;
case PAD5:
return "Pad5";
return "Numpad 5";
break;
case PAD7:
return "Pad7";
return "Numpad 7";
break;
case PAD9:
return "Pad9";
return "Numpad 9";
break;
case PADPERIOD:
return "Padperiod";
return "Numpad .";
break;
case PADSLASHKEY:
return "Padslash";
return "Numpad /";
break;
case PADASTERKEY:
return "Padaster";
return "Numpad *";
break;
case PAD0:
return "Pad0";
return "Numpad 0";
break;
case PADMINUS:
return "Padminus";
return "Numpad -";
break;
case PADENTER:
return "Padenter";
return "Numpad Enter";
break;
case PADPLUSKEY:
return "Padplus";
return "Numpad +";
break;
case F1KEY:
@@ -507,7 +507,7 @@ static char *wm_keymap_item_to_string(wmKeymapItem *kmi, char *str, int len)
return str;
}
char *WM_key_event_operator_string(bContext *C, char *opname, int opcontext, char *str, int len)
char *WM_key_event_operator_string(const bContext *C, const char *opname, int opcontext, char *str, int len)
{
wmEventHandler *handler;
wmKeymapItem *kmi;

View File

@@ -174,7 +174,7 @@ void WM_operator_properties_create(PointerRNA *ptr, const char *opstring)
if(ot)
RNA_pointer_create(NULL, ot->srna, NULL, ptr);
else
memset(ptr, 0, sizeof(*ptr));
RNA_pointer_create(NULL, &RNA_OperatorProperties, NULL, ptr);
}
void WM_operator_properties_free(PointerRNA *ptr)