style cleanup: interface
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -65,9 +65,9 @@ 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);
|
||||
but->flag &= ~(UI_BUT_ANIMATED | UI_BUT_ANIMATED_KEY | UI_BUT_DRIVEN);
|
||||
|
||||
fcu= ui_but_get_fcurve(but, NULL, &driven);
|
||||
fcu = ui_but_get_fcurve(but, NULL, &driven);
|
||||
|
||||
if (fcu) {
|
||||
if (!driven) {
|
||||
@@ -88,10 +88,10 @@ int ui_but_anim_expression_get(uiBut *but, char *str, size_t maxlen)
|
||||
ChannelDriver *driver;
|
||||
int driven;
|
||||
|
||||
fcu= ui_but_get_fcurve(but, NULL, &driven);
|
||||
fcu = ui_but_get_fcurve(but, NULL, &driven);
|
||||
|
||||
if (fcu && driven) {
|
||||
driver= fcu->driver;
|
||||
driver = fcu->driver;
|
||||
|
||||
if (driver && driver->type == DRIVER_TYPE_PYTHON) {
|
||||
BLI_strncpy(str, driver->expression, maxlen);
|
||||
@@ -108,15 +108,15 @@ int ui_but_anim_expression_set(uiBut *but, const char *str)
|
||||
ChannelDriver *driver;
|
||||
int driven;
|
||||
|
||||
fcu= ui_but_get_fcurve(but, NULL, &driven);
|
||||
fcu = ui_but_get_fcurve(but, NULL, &driven);
|
||||
|
||||
if (fcu && driven) {
|
||||
driver= fcu->driver;
|
||||
driver = fcu->driver;
|
||||
|
||||
if (driver && driver->type == DRIVER_TYPE_PYTHON) {
|
||||
BLI_strncpy_utf8(driver->expression, str, sizeof(driver->expression));
|
||||
driver->flag |= DRIVER_FLAG_RECOMPILE;
|
||||
WM_event_add_notifier(but->block->evil_C, NC_ANIMATION|ND_KEYFRAME, NULL);
|
||||
WM_event_add_notifier(but->block->evil_C, NC_ANIMATION | ND_KEYFRAME, NULL);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -131,7 +131,7 @@ int ui_but_anim_expression_create(uiBut *but, const char *str)
|
||||
ID *id;
|
||||
FCurve *fcu;
|
||||
char *path;
|
||||
short ok=0;
|
||||
short ok = 0;
|
||||
|
||||
/* button must have RNA-pointer to a numeric-capable property */
|
||||
if (ELEM(NULL, but->rnapoin.data, but->rnaprop)) {
|
||||
@@ -143,7 +143,7 @@ int ui_but_anim_expression_create(uiBut *but, const char *str)
|
||||
/* make sure we have animdata for this */
|
||||
// FIXME: until materials can be handled by depsgraph, don't allow drivers to be created for them
|
||||
id = (ID *)but->rnapoin.id.data;
|
||||
if ((id == NULL) || (GS(id->name)==ID_MA) || (GS(id->name)==ID_TE)) {
|
||||
if ((id == NULL) || (GS(id->name) == ID_MA) || (GS(id->name) == ID_TE)) {
|
||||
if (G.f & G_DEBUG)
|
||||
printf("ERROR: create expression failed - invalid id-datablock for adding drivers (%p)\n", id);
|
||||
return 0;
|
||||
@@ -155,7 +155,7 @@ int ui_but_anim_expression_create(uiBut *but, const char *str)
|
||||
/* create driver */
|
||||
fcu = verify_driver_fcurve(id, path, but->rnaindex, 1);
|
||||
if (fcu) {
|
||||
ChannelDriver *driver= fcu->driver;
|
||||
ChannelDriver *driver = fcu->driver;
|
||||
|
||||
if (driver) {
|
||||
/* set type of driver */
|
||||
@@ -167,7 +167,7 @@ int ui_but_anim_expression_create(uiBut *but, const char *str)
|
||||
|
||||
/* updates */
|
||||
driver->flag |= DRIVER_FLAG_RECOMPILE;
|
||||
WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME, NULL);
|
||||
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -183,10 +183,10 @@ void ui_but_anim_autokey(bContext *C, uiBut *but, Scene *scene, float cfra)
|
||||
FCurve *fcu;
|
||||
int driven;
|
||||
|
||||
fcu= ui_but_get_fcurve(but, &action, &driven);
|
||||
fcu = ui_but_get_fcurve(but, &action, &driven);
|
||||
|
||||
if (fcu && !driven) {
|
||||
id= but->rnapoin.id.data;
|
||||
id = but->rnapoin.id.data;
|
||||
|
||||
// TODO: this should probably respect the keyingset only option for anim
|
||||
if (autokeyframe_cfra_can_key(scene, id)) {
|
||||
@@ -194,8 +194,8 @@ void ui_but_anim_autokey(bContext *C, uiBut *but, Scene *scene, float cfra)
|
||||
short flag = ANIM_get_keyframing_flags(scene, 1);
|
||||
|
||||
fcu->flag &= ~FCURVE_SELECTED;
|
||||
insert_keyframe(reports, id, action, ((fcu->grp)?(fcu->grp->name):(NULL)), fcu->rna_path, fcu->array_index, cfra, flag);
|
||||
WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
|
||||
insert_keyframe(reports, id, action, ((fcu->grp) ? (fcu->grp->name) : (NULL)), fcu->rna_path, fcu->array_index, cfra, flag);
|
||||
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -75,15 +75,15 @@
|
||||
#include "interface_intern.h"
|
||||
|
||||
|
||||
#define ICON_IMAGE_W 600
|
||||
#define ICON_IMAGE_H 640
|
||||
#define ICON_IMAGE_W 600
|
||||
#define ICON_IMAGE_H 640
|
||||
|
||||
#define ICON_GRID_COLS 26
|
||||
#define ICON_GRID_ROWS 30
|
||||
#define ICON_GRID_COLS 26
|
||||
#define ICON_GRID_ROWS 30
|
||||
|
||||
#define ICON_GRID_MARGIN 5
|
||||
#define ICON_GRID_W 16
|
||||
#define ICON_GRID_H 16
|
||||
#define ICON_GRID_MARGIN 5
|
||||
#define ICON_GRID_W 16
|
||||
#define ICON_GRID_H 16
|
||||
|
||||
typedef struct IconImage {
|
||||
int w;
|
||||
@@ -93,10 +93,10 @@ typedef struct IconImage {
|
||||
|
||||
typedef void (*VectorDrawFunc)(int x, int y, int w, int h, float alpha);
|
||||
|
||||
#define ICON_TYPE_PREVIEW 0
|
||||
#define ICON_TYPE_TEXTURE 1
|
||||
#define ICON_TYPE_BUFFER 2
|
||||
#define ICON_TYPE_VECTOR 3
|
||||
#define ICON_TYPE_PREVIEW 0
|
||||
#define ICON_TYPE_TEXTURE 1
|
||||
#define ICON_TYPE_BUFFER 2
|
||||
#define ICON_TYPE_VECTOR 3
|
||||
|
||||
typedef struct DrawInfo {
|
||||
int type;
|
||||
@@ -107,7 +107,7 @@ typedef struct DrawInfo {
|
||||
VectorDrawFunc func;
|
||||
} vector;
|
||||
struct {
|
||||
IconImage* image;
|
||||
IconImage *image;
|
||||
} buffer;
|
||||
struct {
|
||||
int x, y, w, h;
|
||||
@@ -145,24 +145,24 @@ static void def_internal_icon(ImBuf *bbuf, int icon_id, int xofs, int yofs, int
|
||||
new_icon->type = 0;
|
||||
|
||||
di = MEM_callocN(sizeof(DrawInfo), "drawinfo");
|
||||
di->type= type;
|
||||
di->type = type;
|
||||
|
||||
if (type == ICON_TYPE_TEXTURE) {
|
||||
di->data.texture.x= xofs;
|
||||
di->data.texture.y= yofs;
|
||||
di->data.texture.w= size;
|
||||
di->data.texture.h= size;
|
||||
di->data.texture.x = xofs;
|
||||
di->data.texture.y = yofs;
|
||||
di->data.texture.w = size;
|
||||
di->data.texture.h = size;
|
||||
}
|
||||
else if (type == ICON_TYPE_BUFFER) {
|
||||
iimg = MEM_mallocN(sizeof(IconImage), "icon_img");
|
||||
iimg->rect = MEM_mallocN(size*size*sizeof(unsigned int), "icon_rect");
|
||||
iimg->rect = MEM_mallocN(size * size * sizeof(unsigned int), "icon_rect");
|
||||
iimg->w = size;
|
||||
iimg->h = size;
|
||||
|
||||
/* Here we store the rect in the icon - same as before */
|
||||
imgsize = bbuf->x;
|
||||
for (y=0; y<size; y++) {
|
||||
memcpy(&iimg->rect[y*size], &bbuf->rect[(y+yofs)*imgsize+xofs], size*sizeof(int));
|
||||
for (y = 0; y < size; y++) {
|
||||
memcpy(&iimg->rect[y * size], &bbuf->rect[(y + yofs) * imgsize + xofs], size * sizeof(int));
|
||||
}
|
||||
|
||||
di->data.buffer.image = iimg;
|
||||
@@ -174,10 +174,10 @@ static void def_internal_icon(ImBuf *bbuf, int icon_id, int xofs, int yofs, int
|
||||
BKE_icon_set(icon_id, new_icon);
|
||||
}
|
||||
|
||||
static void def_internal_vicon( int icon_id, VectorDrawFunc drawFunc)
|
||||
static void def_internal_vicon(int icon_id, VectorDrawFunc drawFunc)
|
||||
{
|
||||
Icon *new_icon = NULL;
|
||||
DrawInfo* di;
|
||||
DrawInfo *di;
|
||||
|
||||
new_icon = MEM_callocN(sizeof(Icon), "texicon");
|
||||
|
||||
@@ -185,7 +185,7 @@ static void def_internal_vicon( int icon_id, VectorDrawFunc drawFunc)
|
||||
new_icon->type = 0;
|
||||
|
||||
di = MEM_callocN(sizeof(DrawInfo), "drawinfo");
|
||||
di->type= ICON_TYPE_VECTOR;
|
||||
di->type = ICON_TYPE_VECTOR;
|
||||
di->data.vector.func = drawFunc;
|
||||
|
||||
new_icon->drawinfo_free = NULL;
|
||||
@@ -196,7 +196,7 @@ static void def_internal_vicon( int icon_id, VectorDrawFunc drawFunc)
|
||||
|
||||
/* Vector Icon Drawing Routines */
|
||||
|
||||
/* Utilities */
|
||||
/* Utilities */
|
||||
|
||||
static void viconutil_set_point(GLint pt[2], int x, int y)
|
||||
{
|
||||
@@ -204,7 +204,7 @@ static void viconutil_set_point(GLint pt[2], int x, int y)
|
||||
pt[1] = y;
|
||||
}
|
||||
|
||||
static void viconutil_draw_tri(GLint (*pts)[2])
|
||||
static void viconutil_draw_tri(GLint(*pts)[2])
|
||||
{
|
||||
glBegin(GL_TRIANGLES);
|
||||
glVertex2iv(pts[0]);
|
||||
@@ -213,41 +213,41 @@ static void viconutil_draw_tri(GLint (*pts)[2])
|
||||
glEnd();
|
||||
}
|
||||
|
||||
static void viconutil_draw_lineloop(GLint (*pts)[2], int numPoints)
|
||||
static void viconutil_draw_lineloop(GLint(*pts)[2], int numPoints)
|
||||
{
|
||||
int i;
|
||||
|
||||
glBegin(GL_LINE_LOOP);
|
||||
for (i=0; i<numPoints; i++) {
|
||||
for (i = 0; i < numPoints; i++) {
|
||||
glVertex2iv(pts[i]);
|
||||
}
|
||||
glEnd();
|
||||
}
|
||||
|
||||
static void viconutil_draw_lineloop_smooth(GLint (*pts)[2], int numPoints)
|
||||
static void viconutil_draw_lineloop_smooth(GLint(*pts)[2], int numPoints)
|
||||
{
|
||||
glEnable(GL_LINE_SMOOTH);
|
||||
viconutil_draw_lineloop(pts, numPoints);
|
||||
glDisable(GL_LINE_SMOOTH);
|
||||
}
|
||||
|
||||
static void viconutil_draw_points(GLint (*pts)[2], int numPoints, int pointSize)
|
||||
static void viconutil_draw_points(GLint(*pts)[2], int numPoints, int pointSize)
|
||||
{
|
||||
int i;
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
for (i=0; i<numPoints; i++) {
|
||||
for (i = 0; i < numPoints; i++) {
|
||||
int x = pts[i][0], y = pts[i][1];
|
||||
|
||||
glVertex2i(x-pointSize,y-pointSize);
|
||||
glVertex2i(x+pointSize,y-pointSize);
|
||||
glVertex2i(x+pointSize,y+pointSize);
|
||||
glVertex2i(x-pointSize,y+pointSize);
|
||||
glVertex2i(x - pointSize, y - pointSize);
|
||||
glVertex2i(x + pointSize, y - pointSize);
|
||||
glVertex2i(x + pointSize, y + pointSize);
|
||||
glVertex2i(x - pointSize, y + pointSize);
|
||||
}
|
||||
glEnd();
|
||||
}
|
||||
|
||||
/* Drawing functions */
|
||||
/* Drawing functions */
|
||||
|
||||
static void vicon_x_draw(int x, int y, int w, int h, float alpha)
|
||||
{
|
||||
@@ -256,48 +256,48 @@ static void vicon_x_draw(int x, int y, int w, int h, float alpha)
|
||||
w -= 6;
|
||||
h -= 6;
|
||||
|
||||
glEnable( GL_LINE_SMOOTH );
|
||||
glEnable(GL_LINE_SMOOTH);
|
||||
|
||||
glLineWidth(2.5);
|
||||
|
||||
glColor4f(0.0, 0.0, 0.0, alpha);
|
||||
glBegin(GL_LINES);
|
||||
glVertex2i(x ,y );
|
||||
glVertex2i(x+w,y+h);
|
||||
glVertex2i(x+w,y );
|
||||
glVertex2i(x ,y+h);
|
||||
glVertex2i(x, y);
|
||||
glVertex2i(x + w, y + h);
|
||||
glVertex2i(x + w, y);
|
||||
glVertex2i(x, y + h);
|
||||
glEnd();
|
||||
|
||||
glLineWidth(1.0);
|
||||
|
||||
glDisable( GL_LINE_SMOOTH );
|
||||
glDisable(GL_LINE_SMOOTH);
|
||||
}
|
||||
|
||||
static void vicon_view3d_draw(int x, int y, int w, int h, float alpha)
|
||||
{
|
||||
int cx = x + w/2;
|
||||
int cy = y + h/2;
|
||||
int d = MAX2(2, h/3);
|
||||
int cx = x + w / 2;
|
||||
int cy = y + h / 2;
|
||||
int d = MAX2(2, h / 3);
|
||||
|
||||
glColor4f(0.5, 0.5, 0.5, alpha);
|
||||
glBegin(GL_LINES);
|
||||
glVertex2i(x , cy-d);
|
||||
glVertex2i(x+w, cy-d);
|
||||
glVertex2i(x , cy+d);
|
||||
glVertex2i(x+w, cy+d);
|
||||
glVertex2i(x, cy - d);
|
||||
glVertex2i(x + w, cy - d);
|
||||
glVertex2i(x, cy + d);
|
||||
glVertex2i(x + w, cy + d);
|
||||
|
||||
glVertex2i(cx-d, y );
|
||||
glVertex2i(cx-d, y+h);
|
||||
glVertex2i(cx+d, y );
|
||||
glVertex2i(cx+d, y+h);
|
||||
glVertex2i(cx - d, y);
|
||||
glVertex2i(cx - d, y + h);
|
||||
glVertex2i(cx + d, y);
|
||||
glVertex2i(cx + d, y + h);
|
||||
glEnd();
|
||||
|
||||
glColor4f(0.0, 0.0, 0.0, alpha);
|
||||
glBegin(GL_LINES);
|
||||
glVertex2i(x , cy);
|
||||
glVertex2i(x+w, cy);
|
||||
glVertex2i(cx, y );
|
||||
glVertex2i(cx, y+h);
|
||||
glVertex2i(x, cy);
|
||||
glVertex2i(x + w, cy);
|
||||
glVertex2i(cx, y);
|
||||
glVertex2i(cx, y + h);
|
||||
glEnd();
|
||||
}
|
||||
|
||||
@@ -305,10 +305,10 @@ static void vicon_edit_draw(int x, int y, int w, int h, float alpha)
|
||||
{
|
||||
GLint pts[4][2];
|
||||
|
||||
viconutil_set_point(pts[0], x+3 , y+3 );
|
||||
viconutil_set_point(pts[1], x+w-3, y+3 );
|
||||
viconutil_set_point(pts[2], x+w-3, y+h-3);
|
||||
viconutil_set_point(pts[3], x+3 , y+h-3);
|
||||
viconutil_set_point(pts[0], x + 3, y + 3);
|
||||
viconutil_set_point(pts[1], x + w - 3, y + 3);
|
||||
viconutil_set_point(pts[2], x + w - 3, y + h - 3);
|
||||
viconutil_set_point(pts[3], x + 3, y + h - 3);
|
||||
|
||||
glColor4f(0.0, 0.0, 0.0, alpha);
|
||||
viconutil_draw_lineloop(pts, 4);
|
||||
@@ -321,9 +321,9 @@ static void vicon_editmode_hlt_draw(int x, int y, int w, int h, float alpha)
|
||||
{
|
||||
GLint pts[3][2];
|
||||
|
||||
viconutil_set_point(pts[0], x+w/2, y+h-2);
|
||||
viconutil_set_point(pts[1], x+3, y+4);
|
||||
viconutil_set_point(pts[2], x+w-3, y+4);
|
||||
viconutil_set_point(pts[0], x + w / 2, y + h - 2);
|
||||
viconutil_set_point(pts[1], x + 3, y + 4);
|
||||
viconutil_set_point(pts[2], x + w - 3, y + 4);
|
||||
|
||||
glColor4f(0.5, 0.5, 0.5, alpha);
|
||||
viconutil_draw_tri(pts);
|
||||
@@ -339,9 +339,9 @@ static void vicon_editmode_dehlt_draw(int x, int y, int w, int h, float UNUSED(a
|
||||
{
|
||||
GLint pts[3][2];
|
||||
|
||||
viconutil_set_point(pts[0], x+w/2, y+h-2);
|
||||
viconutil_set_point(pts[1], x+3, y+4);
|
||||
viconutil_set_point(pts[2], x+w-3, y+4);
|
||||
viconutil_set_point(pts[0], x + w / 2, y + h - 2);
|
||||
viconutil_set_point(pts[1], x + 3, y + 4);
|
||||
viconutil_set_point(pts[2], x + w - 3, y + 4);
|
||||
|
||||
glColor4f(0.0f, 0.0f, 0.0f, 1);
|
||||
viconutil_draw_lineloop_smooth(pts, 3);
|
||||
@@ -353,13 +353,13 @@ static void vicon_editmode_dehlt_draw(int x, int y, int w, int h, float UNUSED(a
|
||||
static void vicon_disclosure_tri_right_draw(int x, int y, int w, int UNUSED(h), float alpha)
|
||||
{
|
||||
GLint pts[3][2];
|
||||
int cx = x+w/2;
|
||||
int cy = y+w/2;
|
||||
int d = w/3, d2 = w/5;
|
||||
int cx = x + w / 2;
|
||||
int cy = y + w / 2;
|
||||
int d = w / 3, d2 = w / 5;
|
||||
|
||||
viconutil_set_point(pts[0], cx-d2, cy+d);
|
||||
viconutil_set_point(pts[1], cx-d2, cy-d);
|
||||
viconutil_set_point(pts[2], cx+d2, cy);
|
||||
viconutil_set_point(pts[0], cx - d2, cy + d);
|
||||
viconutil_set_point(pts[1], cx - d2, cy - d);
|
||||
viconutil_set_point(pts[2], cx + d2, cy);
|
||||
|
||||
glShadeModel(GL_SMOOTH);
|
||||
glBegin(GL_TRIANGLES);
|
||||
@@ -378,13 +378,13 @@ static void vicon_disclosure_tri_right_draw(int x, int y, int w, int UNUSED(h),
|
||||
static void vicon_small_tri_right_draw(int x, int y, int w, int UNUSED(h), float alpha)
|
||||
{
|
||||
GLint pts[3][2];
|
||||
int cx = x+w/2-4;
|
||||
int cy = y+w/2;
|
||||
int d = w/5, d2 = w/7;
|
||||
int cx = x + w / 2 - 4;
|
||||
int cy = y + w / 2;
|
||||
int d = w / 5, d2 = w / 7;
|
||||
|
||||
viconutil_set_point(pts[0], cx-d2, cy+d);
|
||||
viconutil_set_point(pts[1], cx-d2, cy-d);
|
||||
viconutil_set_point(pts[2], cx+d2, cy);
|
||||
viconutil_set_point(pts[0], cx - d2, cy + d);
|
||||
viconutil_set_point(pts[1], cx - d2, cy - d);
|
||||
viconutil_set_point(pts[2], cx + d2, cy);
|
||||
|
||||
glColor4f(0.2f, 0.2f, 0.2f, alpha);
|
||||
|
||||
@@ -400,13 +400,13 @@ static void vicon_small_tri_right_draw(int x, int y, int w, int UNUSED(h), float
|
||||
static void vicon_disclosure_tri_down_draw(int x, int y, int w, int UNUSED(h), float alpha)
|
||||
{
|
||||
GLint pts[3][2];
|
||||
int cx = x+w/2;
|
||||
int cy = y+w/2;
|
||||
int d = w/3, d2 = w/5;
|
||||
int cx = x + w / 2;
|
||||
int cy = y + w / 2;
|
||||
int d = w / 3, d2 = w / 5;
|
||||
|
||||
viconutil_set_point(pts[0], cx+d, cy+d2);
|
||||
viconutil_set_point(pts[1], cx-d, cy+d2);
|
||||
viconutil_set_point(pts[2], cx, cy-d2);
|
||||
viconutil_set_point(pts[0], cx + d, cy + d2);
|
||||
viconutil_set_point(pts[1], cx - d, cy + d2);
|
||||
viconutil_set_point(pts[2], cx, cy - d2);
|
||||
|
||||
glShadeModel(GL_SMOOTH);
|
||||
glBegin(GL_TRIANGLES);
|
||||
@@ -424,16 +424,16 @@ static void vicon_disclosure_tri_down_draw(int x, int y, int w, int UNUSED(h), f
|
||||
|
||||
static void vicon_move_up_draw(int x, int y, int w, int h, float UNUSED(alpha))
|
||||
{
|
||||
int d=-2;
|
||||
int d = -2;
|
||||
|
||||
glEnable(GL_LINE_SMOOTH);
|
||||
glLineWidth(1);
|
||||
glColor3f(0.0, 0.0, 0.0);
|
||||
|
||||
glBegin(GL_LINE_STRIP);
|
||||
glVertex2i(x+w/2-d*2, y+h/2+d);
|
||||
glVertex2i(x+w/2, y+h/2-d + 1);
|
||||
glVertex2i(x+w/2+d*2, y+h/2+d);
|
||||
glVertex2i(x + w / 2 - d * 2, y + h / 2 + d);
|
||||
glVertex2i(x + w / 2, y + h / 2 - d + 1);
|
||||
glVertex2i(x + w / 2 + d * 2, y + h / 2 + d);
|
||||
glEnd();
|
||||
|
||||
glLineWidth(1.0);
|
||||
@@ -442,16 +442,16 @@ static void vicon_move_up_draw(int x, int y, int w, int h, float UNUSED(alpha))
|
||||
|
||||
static void vicon_move_down_draw(int x, int y, int w, int h, float UNUSED(alpha))
|
||||
{
|
||||
int d=2;
|
||||
int d = 2;
|
||||
|
||||
glEnable(GL_LINE_SMOOTH);
|
||||
glLineWidth(1);
|
||||
glColor3f(0.0, 0.0, 0.0);
|
||||
|
||||
glBegin(GL_LINE_STRIP);
|
||||
glVertex2i(x+w/2-d*2, y+h/2+d);
|
||||
glVertex2i(x+w/2, y+h/2-d - 1);
|
||||
glVertex2i(x+w/2+d*2, y+h/2+d);
|
||||
glVertex2i(x + w / 2 - d * 2, y + h / 2 + d);
|
||||
glVertex2i(x + w / 2, y + h / 2 - d - 1);
|
||||
glVertex2i(x + w / 2 + d * 2, y + h / 2 + d);
|
||||
glEnd();
|
||||
|
||||
glLineWidth(1.0);
|
||||
@@ -462,12 +462,15 @@ static void vicon_move_down_draw(int x, int y, int w, int h, float UNUSED(alpha)
|
||||
static void init_brush_icons(void)
|
||||
{
|
||||
|
||||
#define INIT_BRUSH_ICON(icon_id, name) \
|
||||
bbuf = IMB_ibImageFromMemory((unsigned char*)datatoc_ ##name## _png, \
|
||||
datatoc_ ##name## _png_size, IB_rect, "<brush icon>"); \
|
||||
def_internal_icon(bbuf, icon_id, 0, 0, w, ICON_TYPE_BUFFER); \
|
||||
IMB_freeImBuf(bbuf);
|
||||
// end INIT_BRUSH_ICON
|
||||
#define INIT_BRUSH_ICON(icon_id, name) \
|
||||
{ \
|
||||
bbuf = IMB_ibImageFromMemory((unsigned char *)datatoc_ ##name## _png, \
|
||||
datatoc_ ##name## _png_size, \
|
||||
IB_rect, "<brush icon>"); \
|
||||
def_internal_icon(bbuf, icon_id, 0, 0, w, ICON_TYPE_BUFFER); \
|
||||
IMB_freeImBuf(bbuf); \
|
||||
} (void)0
|
||||
/* end INIT_BRUSH_ICON */
|
||||
|
||||
ImBuf *bbuf;
|
||||
const int w = 96;
|
||||
@@ -507,34 +510,34 @@ static void init_brush_icons(void)
|
||||
|
||||
static void init_internal_icons(void)
|
||||
{
|
||||
bTheme *btheme= UI_GetTheme();
|
||||
ImBuf *bbuf= NULL;
|
||||
bTheme *btheme = UI_GetTheme();
|
||||
ImBuf *bbuf = NULL;
|
||||
int x, y, icontype;
|
||||
char iconfilestr[FILE_MAX];
|
||||
|
||||
if ((btheme!=NULL) && btheme->tui.iconfile[0]) {
|
||||
char *icondir= BLI_get_folder(BLENDER_DATAFILES, "icons");
|
||||
if ((btheme != NULL) && btheme->tui.iconfile[0]) {
|
||||
char *icondir = BLI_get_folder(BLENDER_DATAFILES, "icons");
|
||||
if (icondir) {
|
||||
BLI_join_dirfile(iconfilestr, sizeof(iconfilestr), icondir, btheme->tui.iconfile);
|
||||
bbuf = IMB_loadiffname(iconfilestr, IB_rect); /* if the image is missing bbuf will just be NULL */
|
||||
if (bbuf && (bbuf->x < ICON_IMAGE_W || bbuf->y < ICON_IMAGE_H)) {
|
||||
printf("\n***WARNING***\nIcons file %s too small.\nUsing built-in Icons instead\n", iconfilestr);
|
||||
IMB_freeImBuf(bbuf);
|
||||
bbuf= NULL;
|
||||
bbuf = NULL;
|
||||
}
|
||||
}
|
||||
else {
|
||||
printf("%s: 'icons' data path not found, continuing\n", __func__);
|
||||
}
|
||||
}
|
||||
if (bbuf==NULL)
|
||||
bbuf = IMB_ibImageFromMemory((unsigned char*)datatoc_blender_icons_png, datatoc_blender_icons_png_size, IB_rect, "<blender icons>");
|
||||
if (bbuf == NULL)
|
||||
bbuf = IMB_ibImageFromMemory((unsigned char *)datatoc_blender_icons_png, datatoc_blender_icons_png_size, IB_rect, "<blender icons>");
|
||||
|
||||
if (bbuf) {
|
||||
/* free existing texture if any */
|
||||
if (icongltex.id) {
|
||||
glDeleteTextures(1, &icongltex.id);
|
||||
icongltex.id= 0;
|
||||
icongltex.id = 0;
|
||||
}
|
||||
|
||||
/* we only use a texture for cards with non-power of two */
|
||||
@@ -544,8 +547,8 @@ static void init_internal_icons(void)
|
||||
if (icongltex.id) {
|
||||
icongltex.w = bbuf->x;
|
||||
icongltex.h = bbuf->y;
|
||||
icongltex.invw = 1.0f/bbuf->x;
|
||||
icongltex.invh = 1.0f/bbuf->y;
|
||||
icongltex.invw = 1.0f / bbuf->x;
|
||||
icongltex.invh = 1.0f / bbuf->y;
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, icongltex.id);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, bbuf->x, bbuf->y, 0, GL_RGBA, GL_UNSIGNED_BYTE, bbuf->rect);
|
||||
@@ -555,24 +558,24 @@ static void init_internal_icons(void)
|
||||
|
||||
if (glGetError() == GL_OUT_OF_MEMORY) {
|
||||
glDeleteTextures(1, &icongltex.id);
|
||||
icongltex.id= 0;
|
||||
icongltex.id = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (icongltex.id)
|
||||
icontype= ICON_TYPE_TEXTURE;
|
||||
icontype = ICON_TYPE_TEXTURE;
|
||||
else
|
||||
icontype= ICON_TYPE_BUFFER;
|
||||
icontype = ICON_TYPE_BUFFER;
|
||||
|
||||
if (bbuf) {
|
||||
for (y=0; y<ICON_GRID_ROWS; y++) {
|
||||
for (x=0; x<ICON_GRID_COLS; x++) {
|
||||
def_internal_icon(bbuf, BIFICONID_FIRST + y*ICON_GRID_COLS + x,
|
||||
x*(ICON_GRID_W+ICON_GRID_MARGIN)+ICON_GRID_MARGIN,
|
||||
y*(ICON_GRID_H+ICON_GRID_MARGIN)+ICON_GRID_MARGIN, ICON_GRID_W,
|
||||
icontype);
|
||||
for (y = 0; y < ICON_GRID_ROWS; y++) {
|
||||
for (x = 0; x < ICON_GRID_COLS; x++) {
|
||||
def_internal_icon(bbuf, BIFICONID_FIRST + y * ICON_GRID_COLS + x,
|
||||
x * (ICON_GRID_W + ICON_GRID_MARGIN) + ICON_GRID_MARGIN,
|
||||
y * (ICON_GRID_H + ICON_GRID_MARGIN) + ICON_GRID_MARGIN, ICON_GRID_W,
|
||||
icontype);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -597,14 +600,14 @@ static void init_iconfile_list(struct ListBase *list)
|
||||
IconFile *ifile;
|
||||
struct direntry *dir;
|
||||
int restoredir = 1; /* restore to current directory */
|
||||
int totfile, i, index=1;
|
||||
int totfile, i, index = 1;
|
||||
const char *icondir;
|
||||
char olddir[FILE_MAX];
|
||||
|
||||
list->first = list->last = NULL;
|
||||
icondir = BLI_get_folder(BLENDER_DATAFILES, "icons");
|
||||
|
||||
if (icondir==NULL)
|
||||
if (icondir == NULL)
|
||||
return;
|
||||
|
||||
/* since BLI_dir_contents changes the current working directory, restore it
|
||||
@@ -614,7 +617,7 @@ static void init_iconfile_list(struct ListBase *list)
|
||||
totfile = BLI_dir_contents(icondir, &dir);
|
||||
if (restoredir && !chdir(olddir)) {} /* fix warning about checking return value */
|
||||
|
||||
for (i=0; i<totfile; i++) {
|
||||
for (i = 0; i < totfile; i++) {
|
||||
if ( (dir[i].type & S_IFREG) ) {
|
||||
char *filename = dir[i].relname;
|
||||
|
||||
@@ -623,13 +626,13 @@ static void init_iconfile_list(struct ListBase *list)
|
||||
* its possible they change size after blender load anyway. */
|
||||
#if 0
|
||||
int ifilex, ifiley;
|
||||
char iconfilestr[FILE_MAX+16]; /* allow 256 chars for file+dir */
|
||||
ImBuf *bbuf= NULL;
|
||||
char iconfilestr[FILE_MAX + 16]; /* allow 256 chars for file+dir */
|
||||
ImBuf *bbuf = NULL;
|
||||
/* check to see if the image is the right size, continue if not */
|
||||
/* copying strings here should go ok, assuming that we never get back
|
||||
* a complete path to file longer than 256 chars */
|
||||
BLI_join_dirfile(iconfilestr, sizeof(iconfilestr), icondir, filename);
|
||||
bbuf= IMB_loadiffname(iconfilestr, IB_rect);
|
||||
bbuf = IMB_loadiffname(iconfilestr, IB_rect);
|
||||
|
||||
if (bbuf) {
|
||||
ifilex = bbuf->x;
|
||||
@@ -637,7 +640,7 @@ static void init_iconfile_list(struct ListBase *list)
|
||||
IMB_freeImBuf(bbuf);
|
||||
}
|
||||
else {
|
||||
ifilex= ifiley= 0;
|
||||
ifilex = ifiley = 0;
|
||||
}
|
||||
|
||||
/* bad size or failed to load */
|
||||
@@ -645,7 +648,7 @@ static void init_iconfile_list(struct ListBase *list)
|
||||
printf("icon '%s' is wrong size %dx%d\n", iconfilestr, ifilex, ifiley);
|
||||
continue;
|
||||
}
|
||||
#endif /* removed */
|
||||
#endif /* removed */
|
||||
|
||||
/* found a potential icon file, so make an entry for it in the cache list */
|
||||
ifile = MEM_callocN(sizeof(IconFile), "IconFile");
|
||||
@@ -661,9 +664,9 @@ static void init_iconfile_list(struct ListBase *list)
|
||||
}
|
||||
|
||||
/* free temporary direntry structure that's been created by BLI_dir_contents() */
|
||||
i= totfile-1;
|
||||
i = totfile - 1;
|
||||
|
||||
for (; i>=0; i--) {
|
||||
for (; i >= 0; i--) {
|
||||
MEM_freeN(dir[i].relname);
|
||||
MEM_freeN(dir[i].path);
|
||||
if (dir[i].string) {
|
||||
@@ -671,14 +674,14 @@ static void init_iconfile_list(struct ListBase *list)
|
||||
}
|
||||
}
|
||||
free(dir);
|
||||
dir= NULL;
|
||||
dir = NULL;
|
||||
}
|
||||
|
||||
static void free_iconfile_list(struct ListBase *list)
|
||||
{
|
||||
IconFile *ifile=NULL, *next_ifile=NULL;
|
||||
IconFile *ifile = NULL, *next_ifile = NULL;
|
||||
|
||||
for (ifile=list->first; ifile; ifile=next_ifile) {
|
||||
for (ifile = list->first; ifile; ifile = next_ifile) {
|
||||
next_ifile = ifile->next;
|
||||
BLI_freelinkN(list, ifile);
|
||||
}
|
||||
@@ -687,9 +690,9 @@ static void free_iconfile_list(struct ListBase *list)
|
||||
int UI_iconfile_get_index(const char *filename)
|
||||
{
|
||||
IconFile *ifile;
|
||||
ListBase *list=&(iconfilelist);
|
||||
ListBase *list = &(iconfilelist);
|
||||
|
||||
for (ifile=list->first; ifile; ifile=ifile->next) {
|
||||
for (ifile = list->first; ifile; ifile = ifile->next) {
|
||||
if (BLI_path_cmp(filename, ifile->filename) == 0) {
|
||||
return ifile->index;
|
||||
}
|
||||
@@ -700,7 +703,7 @@ int UI_iconfile_get_index(const char *filename)
|
||||
|
||||
ListBase *UI_iconfile_list(void)
|
||||
{
|
||||
ListBase *list=&(iconfilelist);
|
||||
ListBase *list = &(iconfilelist);
|
||||
|
||||
return list;
|
||||
}
|
||||
@@ -711,7 +714,7 @@ void UI_icons_free(void)
|
||||
#ifndef WITH_HEADLESS
|
||||
if (icongltex.id) {
|
||||
glDeleteTextures(1, &icongltex.id);
|
||||
icongltex.id= 0;
|
||||
icongltex.id = 0;
|
||||
}
|
||||
|
||||
free_iconfile_list(&iconfilelist);
|
||||
@@ -740,7 +743,7 @@ static DrawInfo *icon_create_drawinfo(void)
|
||||
DrawInfo *di = NULL;
|
||||
|
||||
di = MEM_callocN(sizeof(DrawInfo), "di_icon");
|
||||
di->type= ICON_TYPE_PREVIEW;
|
||||
di->type = ICON_TYPE_PREVIEW;
|
||||
|
||||
return di;
|
||||
}
|
||||
@@ -753,7 +756,7 @@ int UI_icon_get_width(int icon_id)
|
||||
|
||||
icon = BKE_icon_get(icon_id);
|
||||
|
||||
if (icon==NULL) {
|
||||
if (icon == NULL) {
|
||||
if (G.f & G_DEBUG)
|
||||
printf("%s: Internal error, no icon for icon ID: %d\n", __func__, icon_id);
|
||||
return 0;
|
||||
@@ -778,13 +781,13 @@ int UI_icon_get_height(int icon_id)
|
||||
|
||||
icon = BKE_icon_get(icon_id);
|
||||
|
||||
if (icon==NULL) {
|
||||
if (icon == NULL) {
|
||||
if (G.f & G_DEBUG)
|
||||
printf("%s: Internal error, no icon for icon ID: %d\n", __func__, icon_id);
|
||||
return 0;
|
||||
}
|
||||
|
||||
di = (DrawInfo*)icon->drawinfo;
|
||||
di = (DrawInfo *)icon->drawinfo;
|
||||
|
||||
if (!di) {
|
||||
di = icon_create_drawinfo();
|
||||
@@ -814,7 +817,7 @@ void UI_icons_init(int first_dyn_id)
|
||||
static int preview_render_size(enum eIconSizes size)
|
||||
{
|
||||
switch (size) {
|
||||
case ICON_SIZE_ICON: return 32;
|
||||
case ICON_SIZE_ICON: return 32;
|
||||
case ICON_SIZE_PREVIEW: return PREVIEW_DEFAULT_HEIGHT;
|
||||
}
|
||||
return 0;
|
||||
@@ -822,7 +825,7 @@ static int preview_render_size(enum eIconSizes size)
|
||||
|
||||
/* Create rect for the icon
|
||||
*/
|
||||
static void icon_create_rect(struct PreviewImage* prv_img, enum eIconSizes size)
|
||||
static void icon_create_rect(struct PreviewImage *prv_img, enum eIconSizes size)
|
||||
{
|
||||
unsigned int render_size = preview_render_size(size);
|
||||
|
||||
@@ -835,13 +838,13 @@ static void icon_create_rect(struct PreviewImage* prv_img, enum eIconSizes size)
|
||||
prv_img->h[size] = render_size;
|
||||
prv_img->changed[size] = 1;
|
||||
prv_img->changed_timestamp[size] = 0;
|
||||
prv_img->rect[size] = MEM_callocN(render_size*render_size*sizeof(unsigned int), "prv_rect");
|
||||
prv_img->rect[size] = MEM_callocN(render_size * render_size * sizeof(unsigned int), "prv_rect");
|
||||
}
|
||||
}
|
||||
|
||||
/* only called when icon has changed */
|
||||
/* only call with valid pointer from UI_icon_draw */
|
||||
static void icon_set_image(bContext *C, ID *id, PreviewImage* prv_img, enum eIconSizes size)
|
||||
static void icon_set_image(bContext *C, ID *id, PreviewImage *prv_img, enum eIconSizes size)
|
||||
{
|
||||
if (!prv_img) {
|
||||
if (G.f & G_DEBUG)
|
||||
@@ -852,15 +855,15 @@ static void icon_set_image(bContext *C, ID *id, PreviewImage* prv_img, enum eIco
|
||||
icon_create_rect(prv_img, size);
|
||||
|
||||
ED_preview_icon_job(C, prv_img, id, prv_img->rect[size],
|
||||
prv_img->w[size], prv_img->h[size]);
|
||||
prv_img->w[size], prv_img->h[size]);
|
||||
}
|
||||
|
||||
static void icon_draw_rect(float x, float y, int w, int h, float UNUSED(aspect), int rw, int rh, unsigned int *rect, float alpha, float *rgb, short is_preview)
|
||||
{
|
||||
ImBuf *ima= NULL;
|
||||
ImBuf *ima = NULL;
|
||||
|
||||
/* sanity check */
|
||||
if (w<=0 || h<=0 || w>2000 || h>2000) {
|
||||
if (w <= 0 || h <= 0 || w > 2000 || h > 2000) {
|
||||
printf("%s: icons are %i x %i pixels?\n", __func__, w, h);
|
||||
BLI_assert(!"invalid icon size");
|
||||
return;
|
||||
@@ -877,12 +880,12 @@ static void icon_draw_rect(float x, float y, int w, int h, float UNUSED(aspect),
|
||||
}
|
||||
|
||||
/* rect contains image in 'rendersize', we only scale if needed */
|
||||
if (rw!=w && rh!=h) {
|
||||
if (rw != w && rh != h) {
|
||||
/* first allocate imbuf for scaling and copy preview into it */
|
||||
ima = IMB_allocImBuf(rw, rh, 32, IB_rect);
|
||||
memcpy(ima->rect, rect, rw*rh*sizeof(unsigned int));
|
||||
memcpy(ima->rect, rect, rw * rh * sizeof(unsigned int));
|
||||
IMB_scaleImBuf(ima, w, h); /* scale it */
|
||||
rect= ima->rect;
|
||||
rect = ima->rect;
|
||||
}
|
||||
|
||||
/* draw */
|
||||
@@ -915,10 +918,10 @@ static void icon_draw_texture(float x, float y, float w, float h, int ix, int iy
|
||||
if (rgb) glColor4f(rgb[0], rgb[1], rgb[2], alpha);
|
||||
else glColor4f(1.0f, 1.0f, 1.0f, alpha);
|
||||
|
||||
x1= ix*icongltex.invw;
|
||||
x2= (ix + ih)*icongltex.invw;
|
||||
y1= iy*icongltex.invh;
|
||||
y2= (iy + ih)*icongltex.invh;
|
||||
x1 = ix * icongltex.invw;
|
||||
x2 = (ix + ih) * icongltex.invw;
|
||||
y1 = iy * icongltex.invh;
|
||||
y2 = (iy + ih) * icongltex.invh;
|
||||
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
glBindTexture(GL_TEXTURE_2D, icongltex.id);
|
||||
@@ -928,13 +931,13 @@ static void icon_draw_texture(float x, float y, float w, float h, int ix, int iy
|
||||
glVertex2f(x, y);
|
||||
|
||||
glTexCoord2f(x2, y1);
|
||||
glVertex2f(x+w, y);
|
||||
glVertex2f(x + w, y);
|
||||
|
||||
glTexCoord2f(x2, y2);
|
||||
glVertex2f(x+w, y+h);
|
||||
glVertex2f(x + w, y + h);
|
||||
|
||||
glTexCoord2f(x1, y2);
|
||||
glVertex2f(x, y+h);
|
||||
glVertex2f(x, y + h);
|
||||
glEnd();
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
@@ -953,23 +956,23 @@ static int get_draw_size(enum eIconSizes size)
|
||||
|
||||
static void icon_draw_size(float x, float y, int icon_id, float aspect, float alpha, float *rgb, enum eIconSizes size, int draw_size, int UNUSED(nocreate), short is_preview)
|
||||
{
|
||||
bTheme *btheme= UI_GetTheme();
|
||||
bTheme *btheme = UI_GetTheme();
|
||||
Icon *icon = NULL;
|
||||
DrawInfo *di = NULL;
|
||||
IconImage *iimg;
|
||||
float fdraw_size= is_preview ? draw_size : (draw_size * UI_DPI_ICON_FAC);
|
||||
float fdraw_size = is_preview ? draw_size : (draw_size * UI_DPI_ICON_FAC);
|
||||
int w, h;
|
||||
|
||||
icon = BKE_icon_get(icon_id);
|
||||
alpha *= btheme->tui.icon_alpha;
|
||||
|
||||
if (icon==NULL) {
|
||||
if (icon == NULL) {
|
||||
if (G.f & G_DEBUG)
|
||||
printf("%s: Internal error, no icon for icon ID: %d\n", __func__, icon_id);
|
||||
return;
|
||||
}
|
||||
|
||||
di = (DrawInfo*)icon->drawinfo;
|
||||
di = (DrawInfo *)icon->drawinfo;
|
||||
|
||||
if (!di) {
|
||||
di = icon_create_drawinfo();
|
||||
@@ -979,8 +982,8 @@ static void icon_draw_size(float x, float y, int icon_id, float aspect, float al
|
||||
}
|
||||
|
||||
/* scale width and height according to aspect */
|
||||
w = (int)(fdraw_size/aspect + 0.5f);
|
||||
h = (int)(fdraw_size/aspect + 0.5f);
|
||||
w = (int)(fdraw_size / aspect + 0.5f);
|
||||
h = (int)(fdraw_size / aspect + 0.5f);
|
||||
|
||||
if (di->type == ICON_TYPE_VECTOR) {
|
||||
/* vector icons use the uiBlock transformation, they are not drawn
|
||||
@@ -989,22 +992,22 @@ static void icon_draw_size(float x, float y, int icon_id, float aspect, float al
|
||||
}
|
||||
else if (di->type == ICON_TYPE_TEXTURE) {
|
||||
icon_draw_texture(x, y, (float)w, (float)h, di->data.texture.x, di->data.texture.y,
|
||||
di->data.texture.w, di->data.texture.h, alpha, rgb);
|
||||
di->data.texture.w, di->data.texture.h, alpha, rgb);
|
||||
}
|
||||
else if (di->type == ICON_TYPE_BUFFER) {
|
||||
/* it is a builtin icon */
|
||||
iimg= di->data.buffer.image;
|
||||
iimg = di->data.buffer.image;
|
||||
|
||||
if (!iimg->rect) return; /* something has gone wrong! */
|
||||
if (!iimg->rect) return; /* something has gone wrong! */
|
||||
|
||||
icon_draw_rect(x, y, w, h, aspect, iimg->w, iimg->h, iimg->rect, alpha, rgb, is_preview);
|
||||
}
|
||||
else if (di->type == ICON_TYPE_PREVIEW) {
|
||||
PreviewImage* pi = BKE_previewimg_get((ID*)icon->obj);
|
||||
PreviewImage *pi = BKE_previewimg_get((ID *)icon->obj);
|
||||
|
||||
if (pi) {
|
||||
/* no create icon on this level in code */
|
||||
if (!pi->rect[size]) return; /* something has gone wrong! */
|
||||
if (!pi->rect[size]) return; /* something has gone wrong! */
|
||||
|
||||
/* preview images use premul alpha ... */
|
||||
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
|
||||
@@ -1016,7 +1019,7 @@ static void icon_draw_size(float x, float y, int icon_id, float aspect, float al
|
||||
|
||||
static void ui_id_preview_image_render_size(bContext *C, ID *id, PreviewImage *pi, int size)
|
||||
{
|
||||
if ((pi->changed[size] ||!pi->rect[size])) { /* changed only ever set by dynamic icons */
|
||||
if ((pi->changed[size] || !pi->rect[size])) { /* changed only ever set by dynamic icons */
|
||||
/* create the rect if necessary */
|
||||
icon_set_image(C, id, pi, size);
|
||||
|
||||
@@ -1030,9 +1033,9 @@ static void ui_id_icon_render(bContext *C, ID *id, int big)
|
||||
|
||||
if (pi) {
|
||||
if (big)
|
||||
ui_id_preview_image_render_size(C, id, pi, ICON_SIZE_PREVIEW); /* bigger preview size */
|
||||
ui_id_preview_image_render_size(C, id, pi, ICON_SIZE_PREVIEW); /* bigger preview size */
|
||||
else
|
||||
ui_id_preview_image_render_size(C, id, pi, ICON_SIZE_ICON); /* icon size */
|
||||
ui_id_preview_image_render_size(C, id, pi, ICON_SIZE_ICON); /* icon size */
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1057,7 +1060,7 @@ static void ui_id_brush_render(bContext *C, ID *id)
|
||||
|
||||
static int ui_id_brush_get_icon(bContext *C, ID *id)
|
||||
{
|
||||
Brush *br = (Brush*)id;
|
||||
Brush *br = (Brush *)id;
|
||||
|
||||
if (br->flag & BRUSH_CUSTOM_ICON) {
|
||||
BKE_icon_getid(id);
|
||||
@@ -1076,13 +1079,14 @@ static int ui_id_brush_get_icon(bContext *C, ID *id)
|
||||
if (CTX_wm_view3d(C) && ob) {
|
||||
if (ob->mode & OB_MODE_SCULPT)
|
||||
mode = OB_MODE_SCULPT;
|
||||
else if (ob->mode & (OB_MODE_VERTEX_PAINT|OB_MODE_WEIGHT_PAINT))
|
||||
else if (ob->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT))
|
||||
mode = OB_MODE_VERTEX_PAINT;
|
||||
else if (ob->mode & OB_MODE_TEXTURE_PAINT)
|
||||
mode = OB_MODE_TEXTURE_PAINT;
|
||||
}
|
||||
else if ((sima = CTX_wm_space_image(C)) &&
|
||||
(sima->flag & SI_DRAWTOOL)) {
|
||||
(sima->flag & SI_DRAWTOOL))
|
||||
{
|
||||
mode = OB_MODE_TEXTURE_PAINT;
|
||||
}
|
||||
|
||||
@@ -1109,19 +1113,19 @@ static int ui_id_brush_get_icon(bContext *C, ID *id)
|
||||
|
||||
int ui_id_icon_get(bContext *C, ID *id, int big)
|
||||
{
|
||||
int iconid= 0;
|
||||
int iconid = 0;
|
||||
|
||||
/* icon */
|
||||
switch(GS(id->name)) {
|
||||
switch (GS(id->name)) {
|
||||
case ID_BR:
|
||||
iconid= ui_id_brush_get_icon(C, id);
|
||||
iconid = ui_id_brush_get_icon(C, id);
|
||||
break;
|
||||
case ID_MA: /* fall through */
|
||||
case ID_TE: /* fall through */
|
||||
case ID_IM: /* fall through */
|
||||
case ID_WO: /* fall through */
|
||||
case ID_LA: /* fall through */
|
||||
iconid= BKE_icon_getid(id);
|
||||
iconid = BKE_icon_getid(id);
|
||||
/* checks if not exists, or changed */
|
||||
ui_id_icon_render(C, id, big);
|
||||
break;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -78,7 +78,7 @@ static int eyedropper_init(bContext *C, wmOperator *op)
|
||||
{
|
||||
Eyedropper *eye;
|
||||
|
||||
op->customdata= eye= MEM_callocN(sizeof(Eyedropper), "Eyedropper");
|
||||
op->customdata = eye = MEM_callocN(sizeof(Eyedropper), "Eyedropper");
|
||||
|
||||
uiContextActiveProperty(C, &eye->ptr, &eye->prop, &eye->index);
|
||||
|
||||
@@ -91,7 +91,7 @@ static void eyedropper_exit(bContext *C, wmOperator *op)
|
||||
|
||||
if (op->customdata)
|
||||
MEM_freeN(op->customdata);
|
||||
op->customdata= NULL;
|
||||
op->customdata = NULL;
|
||||
}
|
||||
|
||||
static int eyedropper_cancel(bContext *C, wmOperator *op)
|
||||
@@ -130,12 +130,12 @@ static int eyedropper_modal(bContext *C, wmOperator *op, wmEvent *event)
|
||||
{
|
||||
Eyedropper *eye = (Eyedropper *)op->customdata;
|
||||
|
||||
switch(event->type) {
|
||||
switch (event->type) {
|
||||
case ESCKEY:
|
||||
case RIGHTMOUSE:
|
||||
return eyedropper_cancel(C, op);
|
||||
case LEFTMOUSE:
|
||||
if (event->val==KM_RELEASE) {
|
||||
if (event->val == KM_RELEASE) {
|
||||
eyedropper_sample(C, eye, event->x, event->y);
|
||||
eyedropper_exit(C, op);
|
||||
return OPERATOR_FINISHED;
|
||||
@@ -165,7 +165,7 @@ static int eyedropper_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)
|
||||
}
|
||||
|
||||
/* Repeat operator */
|
||||
static int eyedropper_exec (bContext *C, wmOperator *op)
|
||||
static int eyedropper_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
/* init */
|
||||
if (eyedropper_init(C, op)) {
|
||||
@@ -239,14 +239,14 @@ static int copy_data_path_button_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
PointerRNA ptr;
|
||||
PropertyRNA *prop;
|
||||
char *path;
|
||||
int success= 0;
|
||||
int success = 0;
|
||||
int index;
|
||||
|
||||
/* try to create driver using property retrieved from UI */
|
||||
uiContextActiveProperty(C, &ptr, &prop, &index);
|
||||
|
||||
if (ptr.id.data && ptr.data && prop) {
|
||||
path= RNA_path_from_ID_to_property(&ptr, prop);
|
||||
path = RNA_path_from_ID_to_property(&ptr, prop);
|
||||
|
||||
if (path) {
|
||||
WM_clipboard_text_set(path, FALSE);
|
||||
@@ -255,7 +255,7 @@ static int copy_data_path_button_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
}
|
||||
|
||||
/* since we're just copying, we don't really need to do anything else...*/
|
||||
return (success)? OPERATOR_FINISHED: OPERATOR_CANCELLED;
|
||||
return (success) ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
static void UI_OT_copy_data_path_button(wmOperatorType *ot)
|
||||
@@ -290,7 +290,7 @@ static int reset_default_button_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
PointerRNA ptr;
|
||||
PropertyRNA *prop;
|
||||
int success= 0;
|
||||
int success = 0;
|
||||
int index, all = RNA_boolean_get(op->ptr, "all");
|
||||
|
||||
/* try to reset the nominated setting to its default value */
|
||||
@@ -298,14 +298,14 @@ static int reset_default_button_exec(bContext *C, wmOperator *op)
|
||||
|
||||
/* if there is a valid property that is editable... */
|
||||
if (ptr.data && prop && RNA_property_editable(&ptr, prop)) {
|
||||
if (RNA_property_reset(&ptr, prop, (all)? -1: index)) {
|
||||
if (RNA_property_reset(&ptr, prop, (all) ? -1 : index)) {
|
||||
/* perform updates required for this property */
|
||||
RNA_property_update(C, &ptr, prop);
|
||||
|
||||
/* as if we pressed the button */
|
||||
uiContextActivePropertyHandle(C);
|
||||
|
||||
success= 1;
|
||||
success = 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -313,7 +313,7 @@ static int reset_default_button_exec(bContext *C, wmOperator *op)
|
||||
* edits on the screen or on operator settings.
|
||||
* it might be better to move undo's inline - campbell */
|
||||
if (success) {
|
||||
ID *id= ptr.id.data;
|
||||
ID *id = ptr.id.data;
|
||||
if (id && ID_CHECK_UNDO(id)) {
|
||||
/* do nothing, go ahead with undo */
|
||||
}
|
||||
@@ -323,7 +323,7 @@ static int reset_default_button_exec(bContext *C, wmOperator *op)
|
||||
}
|
||||
/* end hack */
|
||||
|
||||
return (success)? OPERATOR_FINISHED: OPERATOR_CANCELLED;
|
||||
return (success) ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
static void UI_OT_reset_default_button(wmOperatorType *ot)
|
||||
@@ -366,7 +366,7 @@ static int copy_to_selected_button_poll(bContext *C)
|
||||
{
|
||||
PointerRNA ptr;
|
||||
PropertyRNA *prop;
|
||||
int index, success= 0;
|
||||
int index, success = 0;
|
||||
|
||||
uiContextActiveProperty(C, &ptr, &prop, &index);
|
||||
|
||||
@@ -375,9 +375,9 @@ static int copy_to_selected_button_poll(bContext *C)
|
||||
ListBase lb;
|
||||
|
||||
if (copy_to_selected_list(C, &ptr, &lb)) {
|
||||
for (link= lb.first; link; link=link->next)
|
||||
for (link = lb.first; link; link = link->next)
|
||||
if (link->ptr.data != ptr.data && RNA_property_editable(&link->ptr, prop))
|
||||
success= 1;
|
||||
success = 1;
|
||||
|
||||
BLI_freelistN(&lb);
|
||||
}
|
||||
@@ -390,7 +390,7 @@ static int copy_to_selected_button_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
PointerRNA ptr;
|
||||
PropertyRNA *prop;
|
||||
int success= 0;
|
||||
int success = 0;
|
||||
int index, all = RNA_boolean_get(op->ptr, "all");
|
||||
|
||||
/* try to reset the nominated setting to its default value */
|
||||
@@ -402,11 +402,11 @@ static int copy_to_selected_button_exec(bContext *C, wmOperator *op)
|
||||
ListBase lb;
|
||||
|
||||
if (copy_to_selected_list(C, &ptr, &lb)) {
|
||||
for (link= lb.first; link; link=link->next) {
|
||||
for (link = lb.first; link; link = link->next) {
|
||||
if (link->ptr.data != ptr.data && RNA_property_editable(&link->ptr, prop)) {
|
||||
if (RNA_property_copy(&link->ptr, &ptr, prop, (all)? -1: index)) {
|
||||
if (RNA_property_copy(&link->ptr, &ptr, prop, (all) ? -1 : index)) {
|
||||
RNA_property_update(C, &link->ptr, prop);
|
||||
success= 1;
|
||||
success = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -415,7 +415,7 @@ static int copy_to_selected_button_exec(bContext *C, wmOperator *op)
|
||||
}
|
||||
}
|
||||
|
||||
return (success)? OPERATOR_FINISHED: OPERATOR_CANCELLED;
|
||||
return (success) ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
static void UI_OT_copy_to_selected_button(wmOperatorType *ot)
|
||||
@@ -430,7 +430,7 @@ static void UI_OT_copy_to_selected_button(wmOperatorType *ot)
|
||||
ot->exec = copy_to_selected_button_exec;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
||||
/* properties */
|
||||
RNA_def_boolean(ot->srna, "all", 1, "All", "Reset to default values all elements of the array");
|
||||
@@ -460,7 +460,7 @@ static int reports_to_text_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
* - if commandline debug option enabled, show debug reports too
|
||||
* - otherwise, up to info (which is what users normally see)
|
||||
*/
|
||||
str = BKE_reports_string(reports, (G.f & G_DEBUG)? RPT_DEBUG : RPT_INFO);
|
||||
str = BKE_reports_string(reports, (G.f & G_DEBUG) ? RPT_DEBUG : RPT_INFO);
|
||||
|
||||
if (str) {
|
||||
write_text(txt, str);
|
||||
@@ -502,7 +502,7 @@ struct uiEditSourceButStore {
|
||||
} uiEditSourceButStore;
|
||||
|
||||
/* should only ever be set while the edit source operator is running */
|
||||
static struct uiEditSourceStore *ui_editsource_info= NULL;
|
||||
static struct uiEditSourceStore *ui_editsource_info = NULL;
|
||||
|
||||
int UI_editsource_enable_check(void)
|
||||
{
|
||||
@@ -513,7 +513,7 @@ static void ui_editsource_active_but_set(uiBut *but)
|
||||
{
|
||||
BLI_assert(ui_editsource_info == NULL);
|
||||
|
||||
ui_editsource_info= MEM_callocN(sizeof(uiEditSourceStore), __func__);
|
||||
ui_editsource_info = MEM_callocN(sizeof(uiEditSourceStore), __func__);
|
||||
memcpy(&ui_editsource_info->but_orig, but, sizeof(uiBut));
|
||||
|
||||
ui_editsource_info->hash = BLI_ghash_new(BLI_ghashutil_ptrhash,
|
||||
@@ -525,7 +525,7 @@ static void ui_editsource_active_but_clear(void)
|
||||
{
|
||||
BLI_ghash_free(ui_editsource_info->hash, NULL, (GHashValFreeFP)MEM_freeN);
|
||||
MEM_freeN(ui_editsource_info);
|
||||
ui_editsource_info= NULL;
|
||||
ui_editsource_info = NULL;
|
||||
}
|
||||
|
||||
static int ui_editsource_uibut_match(uiBut *but_a, uiBut *but_b)
|
||||
@@ -538,16 +538,16 @@ static int ui_editsource_uibut_match(uiBut *but_a, uiBut *but_b)
|
||||
/* this just needs to be a 'good-enough' comparison so we can know beyond
|
||||
* reasonable doubt that these buttons are the same between redraws.
|
||||
* if this fails it only means edit-source fails - campbell */
|
||||
if ( (but_a->x1 == but_b->x1) &&
|
||||
(but_a->x2 == but_b->x2) &&
|
||||
(but_a->y1 == but_b->y1) &&
|
||||
(but_a->y2 == but_b->y2) &&
|
||||
(but_a->type == but_b->type) &&
|
||||
(but_a->rnaprop == but_b->rnaprop) &&
|
||||
(but_a->optype == but_b->optype) &&
|
||||
(but_a->unit_type == but_b->unit_type) &&
|
||||
strncmp(but_a->drawstr, but_b->drawstr, UI_MAX_DRAW_STR) == 0
|
||||
) {
|
||||
if ((but_a->x1 == but_b->x1) &&
|
||||
(but_a->x2 == but_b->x2) &&
|
||||
(but_a->y1 == but_b->y1) &&
|
||||
(but_a->y2 == but_b->y2) &&
|
||||
(but_a->type == but_b->type) &&
|
||||
(but_a->rnaprop == but_b->rnaprop) &&
|
||||
(but_a->optype == but_b->optype) &&
|
||||
(but_a->unit_type == but_b->unit_type) &&
|
||||
(strncmp(but_a->drawstr, but_b->drawstr, UI_MAX_DRAW_STR) == 0))
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
else {
|
||||
@@ -559,10 +559,10 @@ void UI_editsource_active_but_test(uiBut *but)
|
||||
{
|
||||
extern void PyC_FileAndNum_Safe(const char **filename, int *lineno);
|
||||
|
||||
struct uiEditSourceButStore *but_store= MEM_callocN(sizeof(uiEditSourceButStore), __func__);
|
||||
struct uiEditSourceButStore *but_store = MEM_callocN(sizeof(uiEditSourceButStore), __func__);
|
||||
|
||||
const char *fn;
|
||||
int lineno= -1;
|
||||
int lineno = -1;
|
||||
|
||||
#if 0
|
||||
printf("comparing buttons: '%s' == '%s'\n",
|
||||
@@ -573,12 +573,12 @@ void UI_editsource_active_but_test(uiBut *but)
|
||||
|
||||
if (lineno != -1) {
|
||||
BLI_strncpy(but_store->py_dbg_fn, fn,
|
||||
sizeof(but_store->py_dbg_fn));
|
||||
but_store->py_dbg_ln= lineno;
|
||||
sizeof(but_store->py_dbg_fn));
|
||||
but_store->py_dbg_ln = lineno;
|
||||
}
|
||||
else {
|
||||
but_store->py_dbg_fn[0]= '\0';
|
||||
but_store->py_dbg_ln= -1;
|
||||
but_store->py_dbg_fn[0] = '\0';
|
||||
but_store->py_dbg_ln = -1;
|
||||
}
|
||||
|
||||
BLI_ghash_insert(ui_editsource_info->hash, but, but_store);
|
||||
@@ -589,17 +589,17 @@ void UI_editsource_active_but_test(uiBut *but)
|
||||
static int editsource_text_edit(bContext *C, wmOperator *op,
|
||||
char filepath[FILE_MAX], int line)
|
||||
{
|
||||
struct Main *bmain= CTX_data_main(C);
|
||||
struct Main *bmain = CTX_data_main(C);
|
||||
Text *text;
|
||||
|
||||
for (text=bmain->text.first; text; text=text->id.next) {
|
||||
for (text = bmain->text.first; text; text = text->id.next) {
|
||||
if (text->name && BLI_path_cmp(text->name, filepath) == 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (text == NULL) {
|
||||
text= add_text(filepath, bmain->name);
|
||||
text = add_text(filepath, bmain->name);
|
||||
}
|
||||
|
||||
if (text == NULL) {
|
||||
@@ -610,10 +610,10 @@ static int editsource_text_edit(bContext *C, wmOperator *op,
|
||||
else {
|
||||
/* naughty!, find text area to set, not good behavior
|
||||
* but since this is a dev tool lets allow it - campbell */
|
||||
ScrArea *sa= BKE_screen_find_big_area(CTX_wm_screen(C), SPACE_TEXT, 0);
|
||||
ScrArea *sa = BKE_screen_find_big_area(CTX_wm_screen(C), SPACE_TEXT, 0);
|
||||
if (sa) {
|
||||
SpaceText *st= sa->spacedata.first;
|
||||
st->text= text;
|
||||
SpaceText *st = sa->spacedata.first;
|
||||
st->text = text;
|
||||
}
|
||||
else {
|
||||
BKE_reportf(op->reports, RPT_INFO,
|
||||
@@ -621,7 +621,7 @@ static int editsource_text_edit(bContext *C, wmOperator *op,
|
||||
}
|
||||
|
||||
txt_move_toline(text, line - 1, FALSE);
|
||||
WM_event_add_notifier(C, NC_TEXT|ND_CURSOR, text);
|
||||
WM_event_add_notifier(C, NC_TEXT | ND_CURSOR, text);
|
||||
}
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
@@ -629,13 +629,13 @@ static int editsource_text_edit(bContext *C, wmOperator *op,
|
||||
|
||||
static int editsource_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
uiBut *but= uiContextActiveButton(C);
|
||||
uiBut *but = uiContextActiveButton(C);
|
||||
|
||||
if (but) {
|
||||
GHashIterator ghi;
|
||||
struct uiEditSourceButStore *but_store= NULL;
|
||||
struct uiEditSourceButStore *but_store = NULL;
|
||||
|
||||
ARegion *ar= CTX_wm_region(C);
|
||||
ARegion *ar = CTX_wm_region(C);
|
||||
int ret;
|
||||
|
||||
/* needed else the active button does not get tested */
|
||||
@@ -650,12 +650,12 @@ static int editsource_exec(bContext *C, wmOperator *op)
|
||||
ED_region_do_draw(C, ar);
|
||||
|
||||
for (BLI_ghashIterator_init(&ghi, ui_editsource_info->hash);
|
||||
!BLI_ghashIterator_isDone(&ghi);
|
||||
BLI_ghashIterator_step(&ghi))
|
||||
!BLI_ghashIterator_isDone(&ghi);
|
||||
BLI_ghashIterator_step(&ghi))
|
||||
{
|
||||
uiBut *but= BLI_ghashIterator_getKey(&ghi);
|
||||
uiBut *but = BLI_ghashIterator_getKey(&ghi);
|
||||
if (but && ui_editsource_uibut_match(&ui_editsource_info->but_orig, but)) {
|
||||
but_store= BLI_ghashIterator_getValue(&ghi);
|
||||
but_store = BLI_ghashIterator_getValue(&ghi);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -663,20 +663,20 @@ static int editsource_exec(bContext *C, wmOperator *op)
|
||||
|
||||
if (but_store) {
|
||||
if (but_store->py_dbg_ln != -1) {
|
||||
ret= editsource_text_edit(C, op,
|
||||
but_store->py_dbg_fn,
|
||||
but_store->py_dbg_ln);
|
||||
ret = editsource_text_edit(C, op,
|
||||
but_store->py_dbg_fn,
|
||||
but_store->py_dbg_ln);
|
||||
}
|
||||
else {
|
||||
BKE_report(op->reports, RPT_ERROR,
|
||||
"Active button isn't from a script, cant edit source.");
|
||||
ret= OPERATOR_CANCELLED;
|
||||
"Active button isn't from a script, cant edit source.");
|
||||
ret = OPERATOR_CANCELLED;
|
||||
}
|
||||
}
|
||||
else {
|
||||
BKE_report(op->reports, RPT_ERROR,
|
||||
"Active button match can't be found.");
|
||||
ret= OPERATOR_CANCELLED;
|
||||
"Active button match can't be found.");
|
||||
ret = OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -79,61 +79,61 @@
|
||||
|
||||
static uiStyle *ui_style_new(ListBase *styles, const char *name, short uifont_id)
|
||||
{
|
||||
uiStyle *style= MEM_callocN(sizeof(uiStyle), "new style");
|
||||
uiStyle *style = MEM_callocN(sizeof(uiStyle), "new style");
|
||||
|
||||
BLI_addtail(styles, style);
|
||||
BLI_strncpy(style->name, name, MAX_STYLE_NAME);
|
||||
|
||||
style->panelzoom= 1.0; /* unused */
|
||||
style->panelzoom = 1.0; /* unused */
|
||||
|
||||
style->paneltitle.uifont_id= uifont_id;
|
||||
style->paneltitle.points= 12;
|
||||
style->paneltitle.kerning= 1;
|
||||
style->paneltitle.shadow= 1;
|
||||
style->paneltitle.shadx= 0;
|
||||
style->paneltitle.shady= -1;
|
||||
style->paneltitle.shadowalpha= 0.15f;
|
||||
style->paneltitle.shadowcolor= 1.0f;
|
||||
|
||||
style->grouplabel.uifont_id= uifont_id;
|
||||
style->grouplabel.points= 12;
|
||||
style->grouplabel.kerning= 1;
|
||||
style->grouplabel.shadow= 3;
|
||||
style->grouplabel.shadx= 0;
|
||||
style->grouplabel.shady= -1;
|
||||
style->grouplabel.shadowalpha= 0.25f;
|
||||
|
||||
style->widgetlabel.uifont_id= uifont_id;
|
||||
style->widgetlabel.points= 11;
|
||||
style->widgetlabel.kerning= 1;
|
||||
style->widgetlabel.shadow= 3;
|
||||
style->widgetlabel.shadx= 0;
|
||||
style->widgetlabel.shady= -1;
|
||||
style->widgetlabel.shadowalpha= 0.15f;
|
||||
style->widgetlabel.shadowcolor= 1.0f;
|
||||
|
||||
style->widget.uifont_id= uifont_id;
|
||||
style->widget.points= 11;
|
||||
style->widget.kerning= 1;
|
||||
style->widget.shadowalpha= 0.25f;
|
||||
style->paneltitle.uifont_id = uifont_id;
|
||||
style->paneltitle.points = 12;
|
||||
style->paneltitle.kerning = 1;
|
||||
style->paneltitle.shadow = 1;
|
||||
style->paneltitle.shadx = 0;
|
||||
style->paneltitle.shady = -1;
|
||||
style->paneltitle.shadowalpha = 0.15f;
|
||||
style->paneltitle.shadowcolor = 1.0f;
|
||||
|
||||
style->columnspace= 8;
|
||||
style->templatespace= 5;
|
||||
style->boxspace= 5;
|
||||
style->buttonspacex= 8;
|
||||
style->buttonspacey= 2;
|
||||
style->panelspace= 8;
|
||||
style->panelouter= 4;
|
||||
style->grouplabel.uifont_id = uifont_id;
|
||||
style->grouplabel.points = 12;
|
||||
style->grouplabel.kerning = 1;
|
||||
style->grouplabel.shadow = 3;
|
||||
style->grouplabel.shadx = 0;
|
||||
style->grouplabel.shady = -1;
|
||||
style->grouplabel.shadowalpha = 0.25f;
|
||||
|
||||
style->widgetlabel.uifont_id = uifont_id;
|
||||
style->widgetlabel.points = 11;
|
||||
style->widgetlabel.kerning = 1;
|
||||
style->widgetlabel.shadow = 3;
|
||||
style->widgetlabel.shadx = 0;
|
||||
style->widgetlabel.shady = -1;
|
||||
style->widgetlabel.shadowalpha = 0.15f;
|
||||
style->widgetlabel.shadowcolor = 1.0f;
|
||||
|
||||
style->widget.uifont_id = uifont_id;
|
||||
style->widget.points = 11;
|
||||
style->widget.kerning = 1;
|
||||
style->widget.shadowalpha = 0.25f;
|
||||
|
||||
style->columnspace = 8;
|
||||
style->templatespace = 5;
|
||||
style->boxspace = 5;
|
||||
style->buttonspacex = 8;
|
||||
style->buttonspacey = 2;
|
||||
style->panelspace = 8;
|
||||
style->panelouter = 4;
|
||||
|
||||
return style;
|
||||
}
|
||||
|
||||
static uiFont *uifont_to_blfont(int id)
|
||||
{
|
||||
uiFont *font= U.uifonts.first;
|
||||
uiFont *font = U.uifonts.first;
|
||||
|
||||
for (; font; font= font->next) {
|
||||
if (font->uifont_id==id) {
|
||||
for (; font; font = font->next) {
|
||||
if (font->uifont_id == id) {
|
||||
return font;
|
||||
}
|
||||
}
|
||||
@@ -144,31 +144,31 @@ static uiFont *uifont_to_blfont(int id)
|
||||
|
||||
|
||||
void uiStyleFontDrawExt(uiFontStyle *fs, rcti *rect, const char *str,
|
||||
float *r_xofs, float *r_yofs)
|
||||
float *r_xofs, float *r_yofs)
|
||||
{
|
||||
float height;
|
||||
int xofs=0, yofs;
|
||||
int xofs = 0, yofs;
|
||||
|
||||
uiStyleFontSet(fs);
|
||||
|
||||
height= BLF_ascender(fs->uifont_id);
|
||||
yofs= ceil( 0.5f*(rect->ymax - rect->ymin - height));
|
||||
height = BLF_ascender(fs->uifont_id);
|
||||
yofs = ceil(0.5f * (rect->ymax - rect->ymin - height));
|
||||
|
||||
if (fs->align==UI_STYLE_TEXT_CENTER) {
|
||||
xofs= floor( 0.5f*(rect->xmax - rect->xmin - BLF_width(fs->uifont_id, str)));
|
||||
if (fs->align == UI_STYLE_TEXT_CENTER) {
|
||||
xofs = floor(0.5f * (rect->xmax - rect->xmin - BLF_width(fs->uifont_id, str)));
|
||||
/* don't center text if it chops off the start of the text, 2 gives some margin */
|
||||
if (xofs < 2) {
|
||||
xofs= 2;
|
||||
xofs = 2;
|
||||
}
|
||||
}
|
||||
else if (fs->align==UI_STYLE_TEXT_RIGHT) {
|
||||
xofs= rect->xmax - rect->xmin - BLF_width(fs->uifont_id, str) - 1;
|
||||
else if (fs->align == UI_STYLE_TEXT_RIGHT) {
|
||||
xofs = rect->xmax - rect->xmin - BLF_width(fs->uifont_id, str) - 1;
|
||||
}
|
||||
|
||||
/* clip is very strict, so we give it some space */
|
||||
BLF_clipping(fs->uifont_id, rect->xmin-1, rect->ymin-4, rect->xmax+1, rect->ymax+4);
|
||||
BLF_clipping(fs->uifont_id, rect->xmin - 1, rect->ymin - 4, rect->xmax + 1, rect->ymax + 4);
|
||||
BLF_enable(fs->uifont_id, BLF_CLIPPING);
|
||||
BLF_position(fs->uifont_id, rect->xmin+xofs, rect->ymin+yofs, 0.0f);
|
||||
BLF_position(fs->uifont_id, rect->xmin + xofs, rect->ymin + yofs, 0.0f);
|
||||
|
||||
if (fs->shadow) {
|
||||
BLF_enable(fs->uifont_id, BLF_SHADOW);
|
||||
@@ -186,15 +186,15 @@ void uiStyleFontDrawExt(uiFontStyle *fs, rcti *rect, const char *str,
|
||||
if (fs->kerning == 1)
|
||||
BLF_disable(fs->uifont_id, BLF_KERNING_DEFAULT);
|
||||
|
||||
*r_xofs= xofs;
|
||||
*r_yofs= yofs;
|
||||
*r_xofs = xofs;
|
||||
*r_yofs = yofs;
|
||||
}
|
||||
|
||||
void uiStyleFontDraw(uiFontStyle *fs, rcti *rect, const char *str)
|
||||
{
|
||||
float xofs, yofs;
|
||||
uiStyleFontDrawExt(fs, rect, str,
|
||||
&xofs, &yofs);
|
||||
&xofs, &yofs);
|
||||
}
|
||||
|
||||
/* drawn same as above, but at 90 degree angle */
|
||||
@@ -207,16 +207,16 @@ void uiStyleFontDrawRotated(uiFontStyle *fs, rcti *rect, const char *str)
|
||||
|
||||
uiStyleFontSet(fs);
|
||||
|
||||
height= BLF_ascender(fs->uifont_id);
|
||||
height = BLF_ascender(fs->uifont_id);
|
||||
/* becomes x-offset when rotated */
|
||||
xofs= ceil( 0.5f*(rect->ymax - rect->ymin - height));
|
||||
xofs = ceil(0.5f * (rect->ymax - rect->ymin - height));
|
||||
|
||||
/* ignore UI_STYLE, always aligned to top */
|
||||
|
||||
/* rotate counter-clockwise for now (assumes left-to-right language)*/
|
||||
xofs+= height;
|
||||
yofs= BLF_width(fs->uifont_id, str) + 5;
|
||||
angle= 90.0f;
|
||||
xofs += height;
|
||||
yofs = BLF_width(fs->uifont_id, str) + 5;
|
||||
angle = 90.0f;
|
||||
|
||||
/* translate rect to vertical */
|
||||
txtrect.xmin = rect->xmin - (rect->ymax - rect->ymin);
|
||||
@@ -226,9 +226,9 @@ void uiStyleFontDrawRotated(uiFontStyle *fs, rcti *rect, const char *str)
|
||||
|
||||
/* clip is very strict, so we give it some space */
|
||||
/* clipping is done without rotation, so make rect big enough to contain both positions */
|
||||
BLF_clipping(fs->uifont_id, txtrect.xmin-1, txtrect.ymin-yofs-xofs-4, rect->xmax+1, rect->ymax+4);
|
||||
BLF_clipping(fs->uifont_id, txtrect.xmin - 1, txtrect.ymin - yofs - xofs - 4, rect->xmax + 1, rect->ymax + 4);
|
||||
BLF_enable(fs->uifont_id, BLF_CLIPPING);
|
||||
BLF_position(fs->uifont_id, txtrect.xmin+xofs, txtrect.ymax-yofs, 0.0f);
|
||||
BLF_position(fs->uifont_id, txtrect.xmin + xofs, txtrect.ymax - yofs, 0.0f);
|
||||
|
||||
BLF_enable(fs->uifont_id, BLF_ROTATION);
|
||||
BLF_rotation(fs->uifont_id, angle);
|
||||
@@ -253,7 +253,7 @@ void uiStyleFontDrawRotated(uiFontStyle *fs, rcti *rect, const char *str)
|
||||
|
||||
/* ************** helpers ************************ */
|
||||
/* XXX: read a style configure */
|
||||
uiStyle* UI_GetStyle(void)
|
||||
uiStyle *UI_GetStyle(void)
|
||||
{
|
||||
uiStyle *style = NULL;
|
||||
/* offset is two struct uiStyle pointers */
|
||||
@@ -264,17 +264,17 @@ uiStyle* UI_GetStyle(void)
|
||||
/* temporarily, does widget font */
|
||||
int UI_GetStringWidth(const char *str)
|
||||
{
|
||||
uiStyle *style= UI_GetStyle();
|
||||
uiFontStyle *fstyle= &style->widget;
|
||||
uiStyle *style = UI_GetStyle();
|
||||
uiFontStyle *fstyle = &style->widget;
|
||||
int width;
|
||||
|
||||
if (fstyle->kerning==1) /* for BLF_width */
|
||||
if (fstyle->kerning == 1) /* for BLF_width */
|
||||
BLF_enable(fstyle->uifont_id, BLF_KERNING_DEFAULT);
|
||||
|
||||
uiStyleFontSet(fstyle);
|
||||
width= BLF_width(fstyle->uifont_id, str);
|
||||
width = BLF_width(fstyle->uifont_id, str);
|
||||
|
||||
if (fstyle->kerning==1)
|
||||
if (fstyle->kerning == 1)
|
||||
BLF_disable(fstyle->uifont_id, BLF_KERNING_DEFAULT);
|
||||
|
||||
return width;
|
||||
@@ -283,7 +283,7 @@ int UI_GetStringWidth(const char *str)
|
||||
/* temporarily, does widget font */
|
||||
void UI_DrawString(float x, float y, const char *str)
|
||||
{
|
||||
uiStyle *style= UI_GetStyle();
|
||||
uiStyle *style = UI_GetStyle();
|
||||
|
||||
if (style->widget.kerning == 1)
|
||||
BLF_enable(style->widget.uifont_id, BLF_KERNING_DEFAULT);
|
||||
@@ -302,39 +302,39 @@ void UI_DrawString(float x, float y, const char *str)
|
||||
/* reading without uifont will create one */
|
||||
void uiStyleInit(void)
|
||||
{
|
||||
uiFont *font= U.uifonts.first;
|
||||
uiStyle *style= U.uistyles.first;
|
||||
uiFont *font = U.uifonts.first;
|
||||
uiStyle *style = U.uistyles.first;
|
||||
|
||||
/* recover from uninitialized dpi */
|
||||
if (U.dpi == 0)
|
||||
U.dpi= 72;
|
||||
U.dpi = 72;
|
||||
CLAMP(U.dpi, 48, 128);
|
||||
|
||||
/* default builtin */
|
||||
if (font==NULL) {
|
||||
font= MEM_callocN(sizeof(uiFont), "ui font");
|
||||
if (font == NULL) {
|
||||
font = MEM_callocN(sizeof(uiFont), "ui font");
|
||||
BLI_addtail(&U.uifonts, font);
|
||||
|
||||
BLI_strncpy(font->filename, "default", sizeof(font->filename));
|
||||
font->uifont_id= UIFONT_DEFAULT;
|
||||
font->uifont_id = UIFONT_DEFAULT;
|
||||
}
|
||||
|
||||
for (font= U.uifonts.first; font; font= font->next) {
|
||||
for (font = U.uifonts.first; font; font = font->next) {
|
||||
|
||||
if (font->uifont_id==UIFONT_DEFAULT) {
|
||||
if (font->uifont_id == UIFONT_DEFAULT) {
|
||||
#ifdef WITH_INTERNATIONAL
|
||||
int font_size= datatoc_bfont_ttf_size;
|
||||
unsigned char *font_ttf= (unsigned char*)datatoc_bfont_ttf;
|
||||
int font_size = datatoc_bfont_ttf_size;
|
||||
unsigned char *font_ttf = (unsigned char *)datatoc_bfont_ttf;
|
||||
static int last_font_size = 0;
|
||||
|
||||
/* use unicode font for translation */
|
||||
if (U.transopts & USER_DOTRANSLATE) {
|
||||
font_ttf= BLF_get_unifont(&font_size);
|
||||
font_ttf = BLF_get_unifont(&font_size);
|
||||
|
||||
if (!font_ttf) {
|
||||
/* fall back if not found */
|
||||
font_size= datatoc_bfont_ttf_size;
|
||||
font_ttf= (unsigned char*)datatoc_bfont_ttf;
|
||||
font_size = datatoc_bfont_ttf_size;
|
||||
font_ttf = (unsigned char *)datatoc_bfont_ttf;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -344,15 +344,15 @@ void uiStyleInit(void)
|
||||
last_font_size = font_size;
|
||||
}
|
||||
|
||||
font->blf_id= BLF_load_mem("default", font_ttf, font_size);
|
||||
font->blf_id = BLF_load_mem("default", font_ttf, font_size);
|
||||
#else
|
||||
font->blf_id= BLF_load_mem("default", (unsigned char*)datatoc_bfont_ttf, datatoc_bfont_ttf_size);
|
||||
font->blf_id = BLF_load_mem("default", (unsigned char *)datatoc_bfont_ttf, datatoc_bfont_ttf_size);
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
font->blf_id= BLF_load(font->filename);
|
||||
font->blf_id = BLF_load(font->filename);
|
||||
if (font->blf_id == -1)
|
||||
font->blf_id= BLF_load_mem("default", (unsigned char*)datatoc_bfont_ttf, datatoc_bfont_ttf_size);
|
||||
font->blf_id = BLF_load_mem("default", (unsigned char *)datatoc_bfont_ttf, datatoc_bfont_ttf_size);
|
||||
}
|
||||
|
||||
if (font->blf_id == -1) {
|
||||
@@ -370,26 +370,26 @@ void uiStyleInit(void)
|
||||
}
|
||||
}
|
||||
|
||||
if (style==NULL) {
|
||||
ui_style_new(&U.uistyles, "Default Style", UIFONT_DEFAULT );
|
||||
if (style == NULL) {
|
||||
ui_style_new(&U.uistyles, "Default Style", UIFONT_DEFAULT);
|
||||
}
|
||||
|
||||
// XXX, this should be moved into a style, but for now best only load the monospaced font once.
|
||||
if (blf_mono_font == -1)
|
||||
blf_mono_font= BLF_load_mem_unique("monospace", (unsigned char *)datatoc_bmonofont_ttf, datatoc_bmonofont_ttf_size);
|
||||
blf_mono_font = BLF_load_mem_unique("monospace", (unsigned char *)datatoc_bmonofont_ttf, datatoc_bmonofont_ttf_size);
|
||||
|
||||
BLF_size(blf_mono_font, 12, 72);
|
||||
|
||||
/* second for rendering else we get threading problems */
|
||||
if (blf_mono_font_render == -1)
|
||||
blf_mono_font_render= BLF_load_mem_unique("monospace", (unsigned char *)datatoc_bmonofont_ttf, datatoc_bmonofont_ttf_size);
|
||||
blf_mono_font_render = BLF_load_mem_unique("monospace", (unsigned char *)datatoc_bmonofont_ttf, datatoc_bmonofont_ttf_size);
|
||||
|
||||
BLF_size(blf_mono_font_render, 12, 72);
|
||||
}
|
||||
|
||||
void uiStyleFontSet(uiFontStyle *fs)
|
||||
{
|
||||
uiFont *font= uifont_to_blfont(fs->uifont_id);
|
||||
uiFont *font = uifont_to_blfont(fs->uifont_id);
|
||||
|
||||
BLF_size(font->blf_id, fs->points, U.dpi);
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -53,12 +53,12 @@
|
||||
|
||||
uiBut *uiDefAutoButR(uiBlock *block, PointerRNA *ptr, PropertyRNA *prop, int index, const char *name, int icon, int x1, int y1, int x2, int y2)
|
||||
{
|
||||
uiBut *but=NULL;
|
||||
uiBut *but = NULL;
|
||||
|
||||
switch(RNA_property_type(prop)) {
|
||||
switch (RNA_property_type(prop)) {
|
||||
case PROP_BOOLEAN:
|
||||
{
|
||||
int arraylen= RNA_property_array_length(ptr, prop);
|
||||
int arraylen = RNA_property_array_length(ptr, prop);
|
||||
|
||||
if (arraylen && index == -1)
|
||||
return NULL;
|
||||
@@ -74,7 +74,7 @@ uiBut *uiDefAutoButR(uiBlock *block, PointerRNA *ptr, PropertyRNA *prop, int ind
|
||||
case PROP_INT:
|
||||
case PROP_FLOAT:
|
||||
{
|
||||
int arraylen= RNA_property_array_length(ptr, prop);
|
||||
int arraylen = RNA_property_array_length(ptr, prop);
|
||||
|
||||
if (arraylen && index == -1) {
|
||||
if (ELEM(RNA_property_subtype(prop), PROP_COLOR, PROP_COLOR_GAMMA))
|
||||
@@ -105,12 +105,12 @@ uiBut *uiDefAutoButR(uiBlock *block, PointerRNA *ptr, PropertyRNA *prop, int ind
|
||||
case PROP_POINTER: {
|
||||
PointerRNA pptr;
|
||||
|
||||
pptr= RNA_property_pointer_get(ptr, prop);
|
||||
pptr = RNA_property_pointer_get(ptr, prop);
|
||||
if (!pptr.type)
|
||||
pptr.type= RNA_property_pointer_type(ptr, prop);
|
||||
icon= RNA_struct_ui_icon(pptr.type);
|
||||
pptr.type = RNA_property_pointer_type(ptr, prop);
|
||||
icon = RNA_struct_ui_icon(pptr.type);
|
||||
if (icon == ICON_DOT)
|
||||
icon= 0;
|
||||
icon = 0;
|
||||
|
||||
but = uiDefIconTextButR_prop(block, IDPOIN, 0, icon, name, x1, y1, x2, y2, ptr, prop, index, 0, 0, -1, -1, NULL);
|
||||
break;
|
||||
@@ -123,7 +123,7 @@ uiBut *uiDefAutoButR(uiBlock *block, PointerRNA *ptr, PropertyRNA *prop, int ind
|
||||
break;
|
||||
}
|
||||
default:
|
||||
but= NULL;
|
||||
but = NULL;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -135,47 +135,47 @@ int uiDefAutoButsRNA(uiLayout *layout, PointerRNA *ptr, int (*check_prop)(Pointe
|
||||
uiLayout *split, *col;
|
||||
int flag;
|
||||
const char *name;
|
||||
int tot= 0;
|
||||
int tot = 0;
|
||||
|
||||
assert(ELEM3(label_align, '\0', 'H', 'V'));
|
||||
|
||||
RNA_STRUCT_BEGIN(ptr, prop) {
|
||||
flag= RNA_property_flag(prop);
|
||||
if (flag & PROP_HIDDEN || (check_prop && check_prop(ptr, prop)==FALSE))
|
||||
flag = RNA_property_flag(prop);
|
||||
if (flag & PROP_HIDDEN || (check_prop && check_prop(ptr, prop) == FALSE))
|
||||
continue;
|
||||
|
||||
if (label_align != '\0') {
|
||||
PropertyType type = RNA_property_type(prop);
|
||||
int is_boolean = (type == PROP_BOOLEAN && !RNA_property_array_check(prop));
|
||||
|
||||
name= RNA_property_ui_name(prop);
|
||||
name = RNA_property_ui_name(prop);
|
||||
|
||||
if (label_align=='V') {
|
||||
col= uiLayoutColumn(layout, 1);
|
||||
if (label_align == 'V') {
|
||||
col = uiLayoutColumn(layout, 1);
|
||||
|
||||
if (!is_boolean)
|
||||
uiItemL(col, name, ICON_NONE);
|
||||
}
|
||||
else if (label_align=='H') {
|
||||
else if (label_align == 'H') {
|
||||
split = uiLayoutSplit(layout, 0.5f, 0);
|
||||
|
||||
col= uiLayoutColumn(split, 0);
|
||||
uiItemL(col, (is_boolean)? "": name, ICON_NONE);
|
||||
col= uiLayoutColumn(split, 0);
|
||||
col = uiLayoutColumn(split, 0);
|
||||
uiItemL(col, (is_boolean) ? "" : name, ICON_NONE);
|
||||
col = uiLayoutColumn(split, 0);
|
||||
}
|
||||
else {
|
||||
col= NULL;
|
||||
col = NULL;
|
||||
}
|
||||
|
||||
/* may meed to add more cases here.
|
||||
* don't override enum flag names */
|
||||
* don't override enum flag names */
|
||||
|
||||
/* name is shown above, empty name for button below */
|
||||
name= (flag & PROP_ENUM_FLAG || is_boolean)? NULL: "";
|
||||
name = (flag & PROP_ENUM_FLAG || is_boolean) ? NULL : "";
|
||||
}
|
||||
else {
|
||||
col= layout;
|
||||
name= NULL; /* no smart label alignment, show default name with button */
|
||||
col = layout;
|
||||
name = NULL; /* no smart label alignment, show default name with button */
|
||||
}
|
||||
|
||||
uiItemFullR(col, ptr, prop, -1, 0, 0, name, ICON_NONE);
|
||||
@@ -194,14 +194,14 @@ int uiIconFromID(ID *id)
|
||||
PointerRNA ptr;
|
||||
short idcode;
|
||||
|
||||
if (id==NULL)
|
||||
if (id == NULL)
|
||||
return ICON_NONE;
|
||||
|
||||
idcode= GS(id->name);
|
||||
idcode = GS(id->name);
|
||||
|
||||
/* exception for objects */
|
||||
if (idcode == ID_OB) {
|
||||
ob= (Object*)id;
|
||||
ob = (Object *)id;
|
||||
|
||||
if (ob->type == OB_EMPTY)
|
||||
return ICON_EMPTY_DATA;
|
||||
@@ -213,5 +213,5 @@ int uiIconFromID(ID *id)
|
||||
* will set the right type, also with subclassing */
|
||||
RNA_id_pointer_create(id, &ptr);
|
||||
|
||||
return (ptr.type)? RNA_struct_ui_icon(ptr.type) : ICON_NONE;
|
||||
return (ptr.type) ? RNA_struct_ui_icon(ptr.type) : ICON_NONE;
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user