* Fix issue where it would automatically scroll when collapsing panels.
* Fix panel dragging not taking zoom level into account.
* Fix enum menu having too small default width in headers.
* Fix tooltips not showing shortcuts etc. if there was not tooltip
  defined for the button.
* Fix some refresh issues with color ramps.

* Add a bit more space between columns in the layout engine.
* Make scrollers darker so they are less distracting, and highlight
  instead of reverse shading when dragging.
This commit is contained in:
Brecht Van Lommel 2009-07-23 20:50:24 +00:00
parent 062b1b88ad
commit 0bb50594f9
7 changed files with 60 additions and 29 deletions

@ -724,8 +724,8 @@ static void ui_item_rna_size(uiLayout *layout, char *name, int icon, PropertyRNA
subtype= RNA_property_subtype(prop);
len= RNA_property_array_length(prop);
if(ELEM(type, PROP_STRING, PROP_POINTER) && !name[0])
name= "non-empty";
if(ELEM3(type, PROP_STRING, PROP_POINTER, PROP_ENUM) && !name[0])
name= "non-empty text";
else if(type == PROP_BOOLEAN && !name[0])
icon= ICON_DOT;

@ -1031,6 +1031,9 @@ static void ui_do_drag(const bContext *C, wmEvent *event, Panel *panel)
dx= (event->x-data->startx) & ~(PNL_GRID-1);
dy= (event->y-data->starty) & ~(PNL_GRID-1);
dx *= (float)(ar->v2d.cur.xmax - ar->v2d.cur.xmin)/(float)(ar->winrct.xmax - ar->winrct.xmin);
dy *= (float)(ar->v2d.cur.ymax - ar->v2d.cur.ymin)/(float)(ar->winrct.ymax - ar->winrct.ymin);
if(data->state == PANEL_STATE_DRAG_SCALE) {
panel->sizex = MAX2(data->startsizex+dx, UI_PANEL_MINX);

@ -291,10 +291,13 @@ void ui_remove_temporary_region(bContext *C, bScreen *sc, ARegion *ar)
/************************* Creating Tooltips **********************/
#define MAX_TOOLTIP_LINES 8
typedef struct uiTooltipData {
rcti bbox;
uiFontStyle fstyle;
char lines[5][512];
char lines[MAX_TOOLTIP_LINES][512];
int linedark[MAX_TOOLTIP_LINES];
int totline;
int toth, spaceh, lineh;
} uiTooltipData;
@ -314,7 +317,7 @@ static void ui_tooltip_region_draw(const bContext *C, ARegion *ar)
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);
if(!data->linedark[a]) 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]);
@ -344,22 +347,13 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but)
float x1f, x2f, y1f, y2f;
int x1, x2, y1, y2, winx, winy, ofsx, ofsy, w, h, a;
if(!but->tip || strlen(but->tip)==0)
return NULL;
/* create area region */
ar= ui_add_temporary_region(CTX_wm_screen(C));
memset(&type, 0, sizeof(ARegionType));
type.draw= ui_tooltip_region_draw;
type.free= ui_tooltip_region_free;
ar->type= &type;
/* create tooltip data */
data= MEM_callocN(sizeof(uiTooltipData), "uiTooltipData");
BLI_strncpy(data->lines[0], but->tip, sizeof(data->lines[0]));
data->totline= 1;
if(but->tip && strlen(but->tip)) {
BLI_strncpy(data->lines[data->totline], but->tip, sizeof(data->lines[0]));
data->totline++;
}
if(but->optype && !(but->block->flag & UI_BLOCK_LOOP)) {
/* operator keymap (not menus, they already have it) */
@ -367,6 +361,7 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but)
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->linedark[data->totline]= 1;
data->totline++;
}
}
@ -376,6 +371,7 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but)
ui_get_but_string(but, buf, sizeof(buf));
if(buf[0]) {
BLI_snprintf(data->lines[data->totline], sizeof(data->lines[0]), "Value: %s", buf);
data->linedark[data->totline]= 1;
data->totline++;
}
}
@ -385,14 +381,29 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but)
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->linedark[data->totline]= 1;
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->linedark[data->totline]= 1;
data->totline++;
}
if(data->totline == 0) {
MEM_freeN(data);
return NULL;
}
/* create area region */
ar= ui_add_temporary_region(CTX_wm_screen(C));
memset(&type, 0, sizeof(ARegionType));
type.draw= ui_tooltip_region_draw;
type.free= ui_tooltip_region_free;
ar->type= &type;
/* set font, get bb */
data->fstyle= style->widget; /* copy struct */

@ -122,10 +122,10 @@ static uiStyle *ui_style_new(ListBase *styles, const char *name)
style->widget.kerning= 1;
style->widget.shadowalpha= 0.25f;
style->columnspace= 5;
style->columnspace= 8;
style->templatespace= 5;
style->boxspace= 5;
style->buttonspacex= 5;
style->buttonspacex= 8;
style->buttonspacey= 2;
style->panelspace= 8;
style->panelouter= 4;

@ -972,6 +972,13 @@ static void colorband_pos_cb(bContext *C, void *coba_v, void *unused_v)
break;
}
}
WM_event_add_notifier(C, NC_TEXTURE, NULL);
}
static void colorband_cb(bContext *C, void *coba_v, void *unused_v)
{
WM_event_add_notifier(C, NC_TEXTURE, NULL);
}
static void colorband_add_cb(bContext *C, void *coba_v, void *unused_v)
@ -983,6 +990,7 @@ static void colorband_add_cb(bContext *C, void *coba_v, void *unused_v)
colorband_pos_cb(C, coba, NULL);
ED_undo_push(C, "Add colorband");
WM_event_add_notifier(C, NC_TEXTURE, NULL);
}
static void colorband_del_cb(bContext *C, void *coba_v, void *unused_v)
@ -1000,6 +1008,7 @@ static void colorband_del_cb(bContext *C, void *coba_v, void *unused_v)
ED_undo_push(C, "Delete colorband");
// XXX BIF_preview_changed(ID_TE);
WM_event_add_notifier(C, NC_TEXTURE, NULL);
}
@ -1018,18 +1027,22 @@ static void colorband_buttons_large(uiBlock *block, ColorBand *coba, int xoffs,
uiButSetFunc(bt, colorband_del_cb, coba, NULL);
uiDefButS(block, MENU, redraw, "Interpolation %t|Ease %x1|Cardinal %x3|Linear %x0|B-Spline %x2|Constant %x4",
bt= uiDefButS(block, MENU, redraw, "Interpolation %t|Ease %x1|Cardinal %x3|Linear %x0|B-Spline %x2|Constant %x4",
210+xoffs, 100+yoffs, 90, 20, &coba->ipotype, 0.0, 0.0, 0, 0, "Set interpolation between color stops");
uiButSetFunc(bt, colorband_cb, coba, NULL);
uiBlockEndAlign(block);
uiDefBut(block, BUT_COLORBAND, redraw, "", xoffs,65+yoffs,300,30, coba, 0, 0, 0, 0, "");
bt= uiDefBut(block, BUT_COLORBAND, redraw, "", xoffs,65+yoffs,300,30, coba, 0, 0, 0, 0, "");
uiButSetFunc(bt, colorband_cb, coba, NULL);
cbd= coba->data + coba->cur;
bt= uiDefButF(block, NUM, redraw, "Pos:", 0+xoffs,40+yoffs,100, 20, &cbd->pos, 0.0, 1.0, 10, 0, "The position of the active color stop");
uiButSetFunc(bt, colorband_pos_cb, coba, NULL);
uiDefButF(block, COL, redraw, "", 110+xoffs,40+yoffs,80,20, &(cbd->r), 0, 0, 0, B_BANDCOL, "The color value for the active color stop");
uiDefButF(block, NUMSLI, redraw, "A ", 200+xoffs,40+yoffs,100,20, &cbd->a, 0.0, 1.0, 10, 0, "The alpha value of the active color stop");
bt= uiDefButF(block, COL, redraw, "", 110+xoffs,40+yoffs,80,20, &(cbd->r), 0, 0, 0, B_BANDCOL, "The color value for the active color stop");
uiButSetFunc(bt, colorband_cb, coba, NULL);
bt= uiDefButF(block, NUMSLI, redraw, "A ", 200+xoffs,40+yoffs,100,20, &cbd->a, 0.0, 1.0, 10, 0, "The alpha value of the active color stop");
uiButSetFunc(bt, colorband_cb, coba, NULL);
}

@ -1114,13 +1114,13 @@ static struct uiWidgetColors wcol_scroll= {
{50, 50, 50, 180},
{80, 80, 80, 180},
{100, 100, 100, 180},
{180, 180, 180, 255},
{128, 128, 128, 255},
{0, 0, 0, 255},
{255, 255, 255, 255},
1,
10, -20
5, -5
};
static struct uiWidgetColors wcol_list_item= {
@ -1707,8 +1707,11 @@ void uiWidgetScrollDraw(uiWidgetColors *wcol, rcti *rect, rcti *slider, int stat
wcol->shadetop+= 20; /* XXX violates themes... */
else wcol->shadedown+= 20;
if(state & UI_SCROLL_PRESSED)
SWAP(short, wcol->shadetop, wcol->shadedown);
if(state & UI_SCROLL_PRESSED) {
wcol->inner[0]= wcol->inner[0]>=250? 255 : wcol->inner[0]+5;
wcol->inner[1]= wcol->inner[1]>=250? 255 : wcol->inner[1]+5;
wcol->inner[2]= wcol->inner[2]>=250? 255 : wcol->inner[2]+5;
}
/* draw */
wtb.emboss= 0; /* only emboss once */

@ -1251,13 +1251,14 @@ void ED_region_panels(const bContext *C, ARegion *ar, int vertical, char *contex
else {
v2d->keepofs &= ~V2D_LOCKOFS_X;
v2d->keepofs |= V2D_LOCKOFS_Y;
// don't jump back when panels close or hide
x= MAX2(x, v2d->cur.xmax);
y= -y;
}
UI_view2d_totRect_set(v2d, x, y);
// +V2D_SCROLL_HEIGHT is workaround to set the actual height
UI_view2d_totRect_set(v2d, x, y+V2D_SCROLL_HEIGHT);
/* set the view */
UI_view2d_view_ortho(C, v2d);