#ifndef UI_INTERFACE_H
#define UI_INTERFACE_H
+#include "RNA_types.h"
+
/* Struct Declarations */
struct ID;
#define SEARCH_MENU (40<<9)
#define BUT_EXTRA (41<<9)
#define HSVCIRCLE (42<<9)
-#define BUTTYPE (63<<9)
+#define LISTBOX (43<<9)
+#define LISTROW (44<<9)
+#define BUTTYPE (63<<9)
/* Drawing
*
void uiLayoutSetScaleX(uiLayout *layout, float scale);
void uiLayoutSetScaleY(uiLayout *layout, float scale);
-
int uiLayoutGetOperatorContext(uiLayout *layout);
int uiLayoutGetActive(uiLayout *layout);
int uiLayoutGetEnabled(uiLayout *layout);
int uiLayoutGetKeepAspect(uiLayout *layout);
float uiLayoutGetScaleX(uiLayout *layout);
float uiLayoutGetScaleY(uiLayout *layout);
+ListBase *uiLayoutBoxGetList(uiLayout *layout);
/* layout specifiers */
uiLayout *uiLayoutRow(uiLayout *layout, int align);
uiLayout *uiLayoutColumn(uiLayout *layout, int align);
uiLayout *uiLayoutColumnFlow(uiLayout *layout, int number, int align);
uiLayout *uiLayoutBox(uiLayout *layout);
+uiLayout *uiLayoutListBox(uiLayout *layout);
uiLayout *uiLayoutFree(uiLayout *layout, int align);
uiLayout *uiLayoutSplit(uiLayout *layout, float percentage);
void uiTemplateCurveMapping(uiLayout *layout, struct CurveMapping *cumap, int type);
void uiTemplateLayers(uiLayout *layout, struct PointerRNA *ptr, char *propname);
void uiTemplateImageLayers(uiLayout *layout, struct bContext *C, struct Image *ima, struct ImageUser *iuser);
-ListBase uiTemplateList(uiLayout *layout, struct PointerRNA *ptr, char *propname, struct PointerRNA *activeptr, char *activeprop, int rows, int columns, int compact);
void uiTemplateRunningJobs(uiLayout *layout, struct bContext *C);
void uiTemplateOperatorSearch(uiLayout *layout);
void uiTemplateHeader3D(uiLayout *layout, struct bContext *C);
+typedef struct uiListItem {
+ struct uiListItem *next, *prev;
+
+ struct PointerRNA data;
+ uiLayout *layout;
+} uiListItem;
+
+ListBase uiTemplateList(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, char *propname, struct PointerRNA *activeptr, char *activeprop, int rows, int type);
+
/* items */
void uiItemO(uiLayout *layout, char *name, int icon, char *opname);
void uiItemEnumO(uiLayout *layout, char *name, int icon, char *opname, char *propname, int value);
if(value==0.0) push= 1;
break;
case ROW:
+ case LISTROW:
if(value == but->hardmax) push= 1;
break;
case COL:
freestr= 1;
}
- else if(type == ROW && proptype == PROP_ENUM) {
+ else if(ELEM(type, ROW, LISTROW) && proptype == PROP_ENUM) {
EnumPropertyItem *item;
int i, totitem, free;
RNA_property_int_range(ptr, prop, &hardmin, &hardmax);
RNA_property_int_ui_range(ptr, prop, &softmin, &softmax, &step);
- if(type != ROW && min == max) {
+ if(!ELEM(type, ROW, LISTROW) && min == max) {
min= hardmin;
max= hardmax;
}
RNA_property_float_range(ptr, prop, &hardmin, &hardmax);
RNA_property_float_ui_range(ptr, prop, &softmin, &softmax, &step, &precision);
- if(type != ROW && min == max) {
+ if(!ELEM(type, ROW, LISTROW) && min == max) {
min= hardmin;
max= hardmax;
}
glGetMaterialfv(GL_FRONT, GL_DIFFUSE, diff);
/* backdrop */
- glColor3ubv(wcol->inner);
+ glColor3ubv((unsigned char*)wcol->inner);
uiSetRoundBox(15);
gl_round_box(GL_POLYGON, rect->xmin, rect->ymin, rect->xmax, rect->ymax, 5.0f);
/* AA circle */
glEnable(GL_BLEND);
glEnable(GL_LINE_SMOOTH );
- glColor3ubv(wcol->inner);
+ glColor3ubv((unsigned char*)wcol->inner);
glutil_draw_lined_arc(0.0f, M_PI*2.0, 100.0f, 32);
glDisable(GL_BLEND);
glDisable(GL_LINE_SMOOTH );
if(cumap->flag & CUMA_DO_CLIP) {
glColor3ubvShade(wcol->inner, -20);
glRectf(rect->xmin, rect->ymin, rect->xmax, rect->ymax);
- glColor3ubv(wcol->inner);
+ glColor3ubv((unsigned char*)wcol->inner);
glRectf(rect->xmin + zoomx*(cumap->clipr.xmin-offsx),
rect->ymin + zoomy*(cumap->clipr.ymin-offsy),
rect->xmin + zoomx*(cumap->clipr.xmax-offsx),
rect->ymin + zoomy*(cumap->clipr.ymax-offsy));
}
else {
- glColor3ubv(wcol->inner);
+ glColor3ubv((unsigned char*)wcol->inner);
glRectf(rect->xmin, rect->ymin, rect->xmax, rect->ymax);
}
}*/
/* the curve */
- glColor3ubv(wcol->item);
+ glColor3ubv((unsigned char*)wcol->item);
glEnable(GL_LINE_SMOOTH);
glEnable(GL_BLEND);
glBegin(GL_LINE_STRIP);
glScissor(scissor[0], scissor[1], scissor[2], scissor[3]);
/* outline */
- glColor3ubv(wcol->outline);
+ glColor3ubv((unsigned char*)wcol->outline);
fdrawbox(rect->xmin, rect->ymin, rect->xmax, rect->ymax);
}
{
while(but->prev) {
but= but->prev;
- if(but->type!=LABEL && but->type!=SEPR && but->type!=ROUNDBOX) return but;
+ if(!ELEM4(but->type, LABEL, SEPR, ROUNDBOX, LISTBOX)) return but;
}
return NULL;
}
{
while(but->next) {
but= but->next;
- if(but->type!=LABEL && but->type!=SEPR && but->type!=ROUNDBOX) return but;
+ if(!ELEM4(but->type, LABEL, SEPR, ROUNDBOX, LISTBOX)) return but;
}
return NULL;
}
but= block->buttons.first;
while(but) {
- if(but->type!=LABEL && but->type!=SEPR && but->type!=ROUNDBOX) return but;
+ if(!ELEM4(but->type, LABEL, SEPR, ROUNDBOX, LISTBOX)) return but;
but= but->next;
}
return NULL;
but= block->buttons.last;
while(but) {
- if(but->type!=LABEL && but->type!=SEPR && but->type!=ROUNDBOX) return but;
+ if(!ELEM4(but->type, LABEL, SEPR, ROUNDBOX, LISTBOX)) return but;
but= but->prev;
}
return NULL;
uiAfterFunc *after;
char *str= NULL;
- if ELEM5(but->type, BLOCK, BUT, LABEL, PULLDOWN, ROUNDBOX);
+ if ELEM6(but->type, BLOCK, BUT, LABEL, PULLDOWN, ROUNDBOX, LISTBOX);
else {
/* define which string to use for undo */
if ELEM(but->type, LINK, INLINK) str= "Add button link";
/* states of other row buttons */
for(bt= block->buttons.first; bt; bt= bt->next)
- if(bt!=but && bt->poin==but->poin && bt->type==ROW)
+ if(bt!=but && bt->poin==but->poin && ELEM(bt->type, ROW, LISTROW))
ui_check_but(bt);
ui_apply_but_func(C, but);
ui_apply_but_TOG(C, block, but, data);
break;
case ROW:
+ case LISTROW:
ui_apply_but_ROW(C, block, but, data);
break;
case SCROLL:
uiBut *but;
/* label and roundbox can overlap real buttons (backdrops...) */
- if(actbut->type==LABEL && actbut->type==ROUNDBOX)
+ if(ELEM4(actbut->type, LABEL, SEPR, ROUNDBOX, LISTBOX))
return;
for(but= actbut->next; but; but= but->next) {
uiBut *but;
/* label and roundbox can overlap real buttons (backdrops...) */
- if(actbut->type==LABEL && actbut->type==ROUNDBOX)
+ if(ELEM4(actbut->type, LABEL, SEPR, ROUNDBOX, LISTBOX))
return;
for(but= actbut->prev; but; but= but->prev) {
retval= ui_do_but_SLI(C, block, but, data, event);
break;
case ROUNDBOX:
+ case LISTBOX:
case LABEL:
case TOG3:
case ROW:
+ case LISTROW:
retval= ui_do_but_EXIT(C, but, data, event);
break;
case TEX:
ui_window_to_block(ar, block, &mx, &my);
for(but=block->buttons.first; but; but= but->next) {
- if(ELEM3(but->type, LABEL, ROUNDBOX, SEPR))
+ if(ELEM4(but->type, LABEL, ROUNDBOX, SEPR, LISTBOX))
continue;
if(but->flag & UI_HIDDEN)
continue;
UI_WTYPE_RGB_PICKER,
UI_WTYPE_NORMAL,
UI_WTYPE_BOX,
- UI_WTYPE_SCROLL
+ UI_WTYPE_SCROLL,
+ UI_WTYPE_LISTITEM
} uiWidgetTypeEnum;
typedef struct uiLayoutItemBx {
uiLayout litem;
uiBut *roundbox;
+ ListBase items;
} uiLayoutItemBx;
typedef struct uiLayoutItemSplt {
{
int variable = ui_layout_vary_direction(layout) == UI_ITEM_VARY_X;
- if(icon && strcmp(name, "") == 0)
+ if(icon && !name[0])
return UI_UNIT_X; /* icon only */
else if(icon)
return (variable)? UI_GetStringWidth(name) + 4 + UI_UNIT_X: 10*UI_UNIT_X; /* icon + text */
subtype= RNA_property_subtype(prop);
len= RNA_property_array_length(prop);
- if(ELEM(type, PROP_STRING, PROP_POINTER) && strcmp(name, "") == 0)
+ if(ELEM(type, PROP_STRING, PROP_POINTER) && !name[0])
name= "non-empty";
+ else if(type == PROP_BOOLEAN && !name[0])
+ icon= ICON_DOT;
w= ui_text_icon_width(layout, name, icon);
h= UI_UNIT_Y;
/* increase height for arrays */
if(index == RNA_NO_INDEX && len > 0) {
- if(strcmp(name, "") == 0 && icon == 0)
+ if(!name[0] && icon == 0)
h= 0;
if(type == PROP_BOOLEAN && len == 20)
return &flow->litem;
}
-uiLayout *uiLayoutBox(uiLayout *layout)
+static uiLayout *ui_layout_box(uiLayout *layout, int type)
{
uiLayoutItemBx *box;
uiBlockSetCurLayout(layout->root->block, &box->litem);
- box->roundbox= uiDefBut(layout->root->block, ROUNDBOX, 0, "", 0, 0, 0, 0, NULL, 0.0, 0.0, 0, 0, "");
+ box->roundbox= uiDefBut(layout->root->block, type, 0, "", 0, 0, 0, 0, NULL, 0.0, 0.0, 0, 0, "");
return &box->litem;
}
+uiLayout *uiLayoutBox(uiLayout *layout)
+{
+ return ui_layout_box(layout, ROUNDBOX);
+}
+
+uiLayout *uiLayoutListBox(uiLayout *layout)
+{
+ return ui_layout_box(layout, LISTBOX);
+}
+
+ListBase *uiLayoutBoxGetList(uiLayout *layout)
+{
+ uiLayoutItemBx *box= (uiLayoutItemBx*)layout;
+ return &box->items;
+}
+
uiLayout *uiLayoutFree(uiLayout *layout, int align)
{
uiLayout *litem;
ui_layout_free((uiLayout*)item);
}
+ if(layout->item.type == ITEM_LAYOUT_BOX)
+ BLI_freelistN(&((uiLayoutItemBx*)layout)->items);
+
MEM_freeN(layout);
}
style->paneltitle.uifont_id= UIFONT_DEFAULT;
style->paneltitle.points= 12;
- style->paneltitle.kerning= 0;
+ style->paneltitle.kerning= 1;
style->paneltitle.shadow= 5;
style->paneltitle.shadx= 2;
style->paneltitle.shady= -2;
style->grouplabel.uifont_id= UIFONT_DEFAULT;
style->grouplabel.points= 12;
- style->grouplabel.kerning= 0;
+ style->grouplabel.kerning= 1;
style->grouplabel.shadow= 3;
style->grouplabel.shadx= 1;
style->grouplabel.shady= -1;
style->widgetlabel.uifont_id= UIFONT_DEFAULT;
style->widgetlabel.points= 11;
- style->widgetlabel.kerning= 0;
+ style->widgetlabel.kerning= 1;
style->widgetlabel.shadow= 3;
style->widgetlabel.shadx= 1;
style->widgetlabel.shady= -1;
style->widget.uifont_id= UIFONT_DEFAULT;
style->widget.points= 11;
- style->widget.kerning= 0;
+ style->widget.kerning= 1;
style->widget.shadowalpha= 0.25f;
style->columnspace= 5;
/* ID listbase */
for(id= lb->first; id; id= id->next) {
- iconid= ui_id_icon_get(scene, id);
+ if(BLI_strcasestr(id->name+2, str)) {
+ iconid= ui_id_icon_get(scene, id);
- if(BLI_strcasestr(id->name+2, str))
if(!uiSearchItemAdd(items, id->name+2, id, iconid))
break;
+ }
}
}
/************************* List Template **************************/
-ListBase uiTemplateList(uiLayout *layout, PointerRNA *ptr, char *propname, PointerRNA *activeptr, char *activepropname, int rows, int columns, int compact)
+#if 0
+static void list_item_add(ListBase *lb, ListBase *itemlb, uiLayout *layout, PointerRNA *data)
{
CollectionPointerLink *link;
+ uiListItem *item;
+
+ /* add to list to store in box */
+ item= MEM_callocN(sizeof(uiListItem), "uiListItem");
+ item->layout= layout;
+ item->data= *data;
+ BLI_addtail(itemlb, item);
+
+ /* add to list to return from function */
+ link= MEM_callocN(sizeof(CollectionPointerLink), "uiTemplateList return");
+ RNA_pointer_create(NULL, &RNA_UIListItem, item, &link->ptr);
+ BLI_addtail(lb, link);
+}
+#endif
+
+ListBase uiTemplateList(uiLayout *layout, bContext *C, PointerRNA *ptr, char *propname, PointerRNA *activeptr, char *activepropname, int rows, int listtype)
+{
+ //Scene *scene= CTX_data_scene(C);
PropertyRNA *prop= NULL, *activeprop;
PropertyType type, activetype;
StructRNA *ptype;
- uiLayout *box, *row, *col;
+ uiLayout *box, *row, *col, *subrow;
uiBlock *block;
uiBut *but;
Panel *pa;
- ListBase lb;
+ ListBase lb, *itemlb;
char *name, str[32];
int icon=0, i= 0, activei= 0, len, items, found, min, max;
/* get active data */
activei= RNA_property_int_get(activeptr, activeprop);
- if(compact) {
+ if(listtype == 'i') {
+ box= uiLayoutListBox(layout);
+ col= uiLayoutColumn(box, 1);
+ row= uiLayoutRow(col, 0);
+
+ itemlb= uiLayoutBoxGetList(box);
+
+ if(ptr->data && prop) {
+ /* create list items */
+ RNA_PROP_BEGIN(ptr, itemptr, prop) {
+ /* create button */
+ if(i == 9)
+ row= uiLayoutRow(col, 0);
+
+ if(RNA_struct_is_a(itemptr.type, &RNA_TextureSlot)) {
+#if 0
+ MTex *mtex= itemptr.data;
+
+ if(mtex && mtex->tex)
+ icon= ui_id_icon_get(scene, &mtex->tex->id);
+#endif
+ }
+
+ uiDefIconButR(block, LISTROW, 0, icon, 0,0,UI_UNIT_X*10,UI_UNIT_Y, activeptr, activepropname, 0, 0, i, 0, 0, "");
+
+ //list_item_add(&lb, itemlb, uiLayoutRow(row, 1), &itemptr);
+
+ i++;
+ }
+ RNA_PROP_END;
+ }
+ }
+ else if(listtype == 'c') {
/* compact layout */
found= 0;
MEM_freeN(name);
/* add to list to return */
- link= MEM_callocN(sizeof(CollectionPointerLink), "uiTemplateList return");
- link->ptr= itemptr;
- BLI_addtail(&lb, link);
+ //list_item_add(&lb, itemlb, uiLayoutRow(row, 1), &itemptr);
}
i++;
uiButSetFlag(but, UI_BUT_DISABLED);
}
else {
- /* default rows/columns */
+ /* default rows */
if(rows == 0)
rows= 5;
- if(columns == 0)
- columns= 1;
/* layout */
- box= uiLayoutBox(layout);
+ box= uiLayoutListBox(layout);
row= uiLayoutRow(box, 0);
col = uiLayoutColumn(row, 1);
- uiBlockSetEmboss(block, UI_EMBOSSN);
-
/* init numbers */
RNA_property_int_range(activeptr, activeprop, &min, &max);
len= max - min + 1;
- items= rows*columns;
+ items= CLAMPIS(len, rows, 5);
pa->list_scroll= MIN2(pa->list_scroll, len-items);
pa->list_scroll= MAX2(pa->list_scroll, 0);
+ itemlb= uiLayoutBoxGetList(box);
+
if(ptr->data && prop) {
/* create list items */
RNA_PROP_BEGIN(ptr, itemptr, prop) {
if(i >= pa->list_scroll && i<pa->list_scroll+items) {
name= RNA_struct_name_get_alloc(&itemptr, NULL, 0);
+ subrow= uiLayoutRow(col, 0);
+
/* create button */
- but= uiDefIconTextButR(block, ROW, 0, icon, (name)? name: "", 0,0,UI_UNIT_X*10,UI_UNIT_Y, activeptr, activepropname, 0, 0, i, 0, 0, "");
+ if(!icon || icon == ICON_DOT)
+ but= uiDefButR(block, LISTROW, 0, (name)? name: "", 0,0,UI_UNIT_X*10,UI_UNIT_Y, activeptr, activepropname, 0, 0, i, 0, 0, "");
+ else
+ but= uiDefIconTextButR(block, LISTROW, 0, icon, (name)? name: "", 0,0,UI_UNIT_X*10,UI_UNIT_Y, activeptr, activepropname, 0, 0, i, 0, 0, "");
uiButSetFlag(but, UI_ICON_LEFT|UI_TEXT_LEFT);
+ /* XXX hardcoded */
+ if(itemptr.type == &RNA_MeshTextureFaceLayer || itemptr.type == &RNA_MeshColorLayer) {
+ uiBlockSetEmboss(block, UI_EMBOSSN);
+ uiItemR(subrow, "", ICON_SCENE, &itemptr, "active_render", 0, 0, 0);
+ uiBlockSetEmboss(block, UI_EMBOSS);
+ }
+
if(name)
MEM_freeN(name);
/* add to list to return */
- link= MEM_callocN(sizeof(CollectionPointerLink), "uiTemplateList return");
- link->ptr= itemptr;
- BLI_addtail(&lb, link);
+ //list_item_add(&lb, itemlb, subrow, &itemptr);
}
i++;
i++;
}
- uiBlockSetEmboss(block, UI_EMBOSS);
-
/* add scrollbar */
if(len > items) {
col= uiLayoutColumn(row, 0);
static void round_box_shade_col4(char *col1, char *col2, float fac)
{
int faci, facm;
- char col[4];
+ unsigned char col[4];
faci= floor(255.1f*fac);
facm= 255-faci;
if(wcol->shaded==0) {
/* filled center, solid */
- glColor4ubv(wcol->inner);
+ glColor4ubv((unsigned char*)wcol->inner);
glBegin(GL_POLYGON);
for(a=0; a<wtb->totvert; a++)
glVertex2fv(wtb->inner_v[a]);
height= ICON_HEIGHT;
/* calculate blend color */
- if ELEM3(but->type, TOG, ROW, TOGN) {
+ if ELEM4(but->type, TOG, ROW, TOGN, LISTROW) {
if(but->flag & UI_SELECT);
else if(but->flag & UI_ACTIVE);
else blend= -60;
but->drawstr[selend_tmp]= ch;
- glColor3ubv(wcol->item);
+ glColor3ubv((unsigned char*)wcol->item);
glRects(rect->xmin+selsta_draw+1, rect->ymin+2, rect->xmin+selwidth_draw+1, rect->ymax-2);
}
} else {
if(cpoin) *cpoin= 0;
}
- glColor3ubv(wcol->text);
+ glColor3ubv((unsigned char*)wcol->text);
uiStyleFontDraw(fstyle, rect, but->drawstr+but->ofs);
/* part text right aligned */
10, -20
};
+static struct uiWidgetColors wcol_list_item= {
+ {0, 0, 0, 255},
+ {0, 0, 0, 0},
+ {86, 128, 194, 255},
+ {0, 0, 0, 255},
+
+ {0, 0, 0, 255},
+ {0, 0, 0, 255},
+
+ 0,
+ 0, 0
+};
+
/* free wcol struct to play with */
static struct uiWidgetColors wcol_tmp= {
{0, 0, 0, 255},
tui->wcol_menu_item= wcol_menu_item;
tui->wcol_box= wcol_box;
tui->wcol_scroll= wcol_scroll;
+ tui->wcol_list_item= wcol_list_item;
tui->wcol_state= wcol_state;
}
{
rcti rect1;
double value;
- float fac, size;
+ float fac, size, min;
int horizontal;
/* calculate slider part */
fac= (rect->xmax - rect->xmin)/(size);
rect1.xmin= rect1.xmin + ceil(fac*(value - but->softmin));
rect1.xmax= rect1.xmin + ceil(fac*(but->a1 - but->softmin));
+
+ /* ensure minimium size */
+ min= rect->ymax - rect->ymin;
+
+ if(rect1.xmax - rect1.xmin < min) {
+ rect1.xmax= rect1.xmin + min;
+
+ if(rect1.xmax > rect->xmax) {
+ rect1.xmax= rect->xmax;
+ rect1.xmin= MAX2(rect1.xmax - min, rect->xmin);
+ }
+ }
}
else {
fac= (rect->ymax - rect->ymin)/(size);
rect1.ymax= rect1.ymax - ceil(fac*(value - but->softmin));
rect1.ymin= rect1.ymax - ceil(fac*(but->a1 - but->softmin));
+
+ /* ensure minimium size */
+ min= rect->xmax - rect->xmin;
+
+ if(rect1.ymax - rect1.ymin < min) {
+ rect1.ymax= rect1.ymin + min;
+
+ if(rect1.ymax > rect->ymax) {
+ rect1.ymax= rect->ymax;
+ rect1.ymin= MAX2(rect1.ymax - min, rect->ymin);
+ }
+ }
}
if(state & UI_SELECT)
else
state= 0;
uiWidgetScrollDraw(wcol, rect, &rect1, state);
-
}
static void widget_link(uiBut *but, uiWidgetColors *wcol, rcti *rect, int state, int roundboxalign)
widgetbase_draw(&wtb, wcol);
}
+static void widget_list_itembut(uiWidgetColors *wcol, rcti *rect, int state, int roundboxalign)
+{
+ uiWidgetBase wtb;
+
+ widget_init(&wtb);
+
+ /* rounded, but no outline */
+ wtb.outline= 0;
+ round_box_edges(&wtb, 15, rect, 4.0f);
+
+ widgetbase_draw(&wtb, wcol);
+}
static void widget_optionbut(uiWidgetColors *wcol, rcti *rect, int state, int roundboxalign)
{
case UI_WTYPE_OPTION:
wt.wcol_theme= &btheme->tui.wcol_option;
wt.draw= widget_optionbut;
- wt.state= widget_state_label;
break;
case UI_WTYPE_RADIO:
wt.state= widget_state_nothing;
wt.custom= widget_scroll;
break;
+
+ case UI_WTYPE_LISTITEM:
+ wt.wcol_theme= &btheme->tui.wcol_list_item;
+ wt.draw= widget_list_itembut;
+ break;
}
return &wt;
case ROW:
wt= widget_type(UI_WTYPE_RADIO);
break;
+
+ case LISTROW:
+ wt= widget_type(UI_WTYPE_LISTITEM);
+ break;
case TEX:
wt= widget_type(UI_WTYPE_NAME);
break;
case ROUNDBOX:
+ case LISTBOX:
wt= widget_type(UI_WTYPE_BOX);
break;
rect->xmax -= BLF_width(cpoin+1) + 10;
}
- glColor3ubv(wt->wcol.text);
+ glColor3ubv((unsigned char*)wt->wcol.text);
uiStyleFontDraw(fstyle, rect, name);
/* part text right aligned */
uiWidgetColors wcol_radio, wcol_option, wcol_toggle;
uiWidgetColors wcol_num, wcol_numslider;
uiWidgetColors wcol_menu, wcol_pulldown, wcol_menu_back, wcol_menu_item;
- uiWidgetColors wcol_box, wcol_scroll;
+ uiWidgetColors wcol_box, wcol_scroll, wcol_list_item;
uiWidgetStateColors wcol_state;
return pt->py_srna;
}
-static StructRNA* rna_Panel_refine(struct PointerRNA *ptr)
+static StructRNA* rna_Panel_refine(PointerRNA *ptr)
{
Panel *hdr= (Panel*)ptr->data;
return (hdr->type && hdr->type->py_srna)? hdr->type->py_srna: &RNA_Panel;
return ht->py_srna;
}
-static StructRNA* rna_Header_refine(struct PointerRNA *htr)
+static StructRNA* rna_Header_refine(PointerRNA *htr)
{
Header *hdr= (Header*)htr->data;
return (hdr->type && hdr->type->py_srna)? hdr->type->py_srna: &RNA_Header;
return mt->py_srna;
}
-static StructRNA* rna_Menu_refine(struct PointerRNA *mtr)
+static StructRNA* rna_Menu_refine(PointerRNA *mtr)
{
Menu *hdr= (Menu*)mtr->data;
return (hdr->type && hdr->type->py_srna)? hdr->type->py_srna: &RNA_Menu;
}
-static int rna_UILayout_active_get(struct PointerRNA *ptr)
+static int rna_UILayout_active_get(PointerRNA *ptr)
{
return uiLayoutGetActive(ptr->data);
}
-static void rna_UILayout_active_set(struct PointerRNA *ptr, int value)
+static void rna_UILayout_active_set(PointerRNA *ptr, int value)
{
uiLayoutSetActive(ptr->data, value);
}
-static void rna_UILayout_op_context_set(struct PointerRNA *ptr, int value)
+static void rna_UILayout_op_context_set(PointerRNA *ptr, int value)
{
uiLayoutSetOperatorContext(ptr->data, value);
}
-static int rna_UILayout_op_context_get(struct PointerRNA *ptr)
+static int rna_UILayout_op_context_get(PointerRNA *ptr)
{
return uiLayoutGetOperatorContext(ptr->data);
}
-static int rna_UILayout_enabled_get(struct PointerRNA *ptr)
+static int rna_UILayout_enabled_get(PointerRNA *ptr)
{
return uiLayoutGetEnabled(ptr->data);
}
-static void rna_UILayout_enabled_set(struct PointerRNA *ptr, int value)
+static void rna_UILayout_enabled_set(PointerRNA *ptr, int value)
{
uiLayoutSetEnabled(ptr->data, value);
}
-static int rna_UILayout_red_alert_get(struct PointerRNA *ptr)
+#if 0
+static int rna_UILayout_red_alert_get(PointerRNA *ptr)
{
return uiLayoutGetRedAlert(ptr->data);
}
-static void rna_UILayout_red_alert_set(struct PointerRNA *ptr, int value)
+static void rna_UILayout_red_alert_set(PointerRNA *ptr, int value)
{
uiLayoutSetRedAlert(ptr->data, value);
}
-static int rna_UILayout_keep_aspect_get(struct PointerRNA *ptr)
+static int rna_UILayout_keep_aspect_get(PointerRNA *ptr)
{
return uiLayoutGetKeepAspect(ptr->data);
}
-static void rna_UILayout_keep_aspect_set(struct PointerRNA *ptr, int value)
+static void rna_UILayout_keep_aspect_set(PointerRNA *ptr, int value)
{
uiLayoutSetKeepAspect(ptr->data, value);
}
+#endif
-static int rna_UILayout_alignment_get(struct PointerRNA *ptr)
+static int rna_UILayout_alignment_get(PointerRNA *ptr)
{
return uiLayoutGetAlignment(ptr->data);
}
-static void rna_UILayout_alignment_set(struct PointerRNA *ptr, int value)
+static void rna_UILayout_alignment_set(PointerRNA *ptr, int value)
{
uiLayoutSetAlignment(ptr->data, value);
}
-static float rna_UILayout_scale_x_get(struct PointerRNA *ptr)
+static float rna_UILayout_scale_x_get(PointerRNA *ptr)
{
return uiLayoutGetScaleX(ptr->data);
}
-static void rna_UILayout_scale_x_set(struct PointerRNA *ptr, float value)
+static void rna_UILayout_scale_x_set(PointerRNA *ptr, float value)
{
uiLayoutSetScaleX(ptr->data, value);
}
-static float rna_UILayout_scale_y_get(struct PointerRNA *ptr)
+static float rna_UILayout_scale_y_get(PointerRNA *ptr)
{
return uiLayoutGetScaleY(ptr->data);
}
-static void rna_UILayout_scale_y_set(struct PointerRNA *ptr, float value)
+static void rna_UILayout_scale_y_set(PointerRNA *ptr, float value)
{
uiLayoutSetScaleY(ptr->data, value);
}
+static PointerRNA rna_UIListItem_layout_get(PointerRNA *ptr)
+{
+ uiListItem *item= (uiListItem*)ptr->data;
+ PointerRNA newptr;
+ RNA_pointer_create(NULL, &RNA_UILayout, item->layout, &newptr);
+ return newptr;
+}
+
+static PointerRNA rna_UIListItem_data_get(PointerRNA *ptr)
+{
+ uiListItem *item= (uiListItem*)ptr->data;
+ return item->data;
+}
+
#else // RNA_RUNTIME
static void rna_def_ui_layout(BlenderRNA *brna)
{WM_OP_EXEC_AREA, "EXEC_AREA", 0, "Exec Area", ""},
{WM_OP_EXEC_SCREEN, "EXEC_SCREEN", 0, "Exec Screen", ""},
{0, NULL, 0, NULL, NULL}};
+
+ /* layout */
srna= RNA_def_struct(brna, "UILayout", NULL);
RNA_def_struct_sdna(srna, "uiLayout");
prop= RNA_def_property(srna, "enabled", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_funcs(prop, "rna_UILayout_enabled_get", "rna_UILayout_enabled_set");
+#if 0
prop= RNA_def_property(srna, "red_alert", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_funcs(prop, "rna_UILayout_red_alert_get", "rna_UILayout_red_alert_set");
+#endif
prop= RNA_def_property(srna, "alignment", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_items(prop, alignment_items);
RNA_def_property_enum_funcs(prop, "rna_UILayout_alignment_get", "rna_UILayout_alignment_set", NULL);
+#if 0
prop= RNA_def_property(srna, "keep_aspect", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_funcs(prop, "rna_UILayout_keep_aspect_get", "rna_UILayout_keep_aspect_set");
+#endif
prop= RNA_def_property(srna, "scale_x", PROP_FLOAT, PROP_UNSIGNED);
RNA_def_property_float_funcs(prop, "rna_UILayout_scale_x_get", "rna_UILayout_scale_x_set", NULL);
RNA_def_property_float_funcs(prop, "rna_UILayout_scale_y_get", "rna_UILayout_scale_y_set", NULL);
RNA_api_ui_layout(srna);
+
+ /* list item */
+
+ srna= RNA_def_struct(brna, "UIListItem", NULL);
+ RNA_def_struct_ui_text(srna, "UI List Item", "User interface list.");
+
+ prop= RNA_def_property(srna, "layout", PROP_POINTER, PROP_NONE);
+ RNA_def_property_struct_type(prop, "UILayout");
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_property_pointer_funcs(prop, "rna_UIListItem_layout_get", NULL, NULL);
+
+ prop= RNA_def_property(srna, "data", PROP_POINTER, PROP_NONE);
+ RNA_def_property_struct_type(prop, "AnyType");
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_property_pointer_funcs(prop, "rna_UIListItem_data_get", NULL, NULL);
}
static void rna_def_panel(BlenderRNA *brna)
{'v', "VECTOR", 0, "Vector", ""},
{'c', "COLOR", 0, "Color", ""},
{0, NULL, 0, NULL, NULL}};
+
+ static EnumPropertyItem list_type_items[] = {
+ {0, "DEFAULT", 0, "None", ""},
+ {'c', "COMPACT", 0, "Compact", ""},
+ {'i', "ICONS", 0, "Icons", ""},
+ {0, NULL, 0, NULL, NULL}};
/* simple layout specifiers */
func= RNA_def_function(srna, "row", "uiLayoutRow");
RNA_def_property_flag(parm, PROP_REQUIRED);
func= RNA_def_function(srna, "template_list", "uiTemplateList");
+ RNA_def_function_flag(func, FUNC_USE_CONTEXT);
api_ui_item_rna_common(func);
parm= RNA_def_pointer(func, "active_data", "AnyType", "", "Data from which to take property for the active element.");
RNA_def_property_flag(parm, PROP_REQUIRED|PROP_RNAPTR);
parm= RNA_def_string(func, "active_property", "", 0, "", "Identifier of property in data, for the active element.");
RNA_def_property_flag(parm, PROP_REQUIRED);
parm= RNA_def_int(func, "rows", 5, 0, INT_MAX, "", "Number of rows to display.", 0, INT_MAX);
- parm= RNA_def_int(func, "columns", 5, 0, INT_MAX, "", "Number of columns to display.", 0, INT_MAX);
- parm= RNA_def_boolean(func, "compact", 0, "", "Use compact, single row list template.");
+ parm= RNA_def_enum(func, "type", list_type_items, 0, "Type", "Type of list to use.");
parm= RNA_def_collection(func, "items", 0, "", "Items visible in the list.");
RNA_def_function_return(func, parm);
RNA_def_property_ui_text(prop, "Scroll Widget Colors", "");
RNA_def_property_update(prop, NC_WINDOW, NULL);
+ prop= RNA_def_property(srna, "wcol_list_item", PROP_POINTER, PROP_NEVER_NULL);
+ RNA_def_property_pointer_sdna(prop, NULL, "wcol_list_item");
+ RNA_def_property_struct_type(prop, "ThemeWidgetColors");
+ RNA_def_property_ui_text(prop, "List Item 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");