style cleanup

This commit is contained in:
Campbell Barton 2012-05-24 13:18:53 +00:00
parent 39ff86eb32
commit 9abd6e7651
9 changed files with 787 additions and 742 deletions

@ -309,8 +309,7 @@ int processEvent(GHOST_EventHandle hEvent, GHOST_TUserDataPtr userData)
{
view_rotz += 5.f;
}
else
{
else {
view_rotz -= 5.f;
}
}
@ -356,8 +355,7 @@ int processEvent(GHOST_EventHandle hEvent, GHOST_TUserDataPtr userData)
FALSE /* stereo flag */);
}
else
{
else {
GHOST_EndFullScreen(shSystem);
sFullScreenWindow = 0;
}
@ -380,8 +378,7 @@ int processEvent(GHOST_EventHandle hEvent, GHOST_TUserDataPtr userData)
{
sTestTimer = GHOST_InstallTimer(shSystem, 0, 1000, testTimerProc, NULL);
}
else
{
else {
GHOST_RemoveTimer(shSystem, sTestTimer);
sTestTimer = 0;
}
@ -414,8 +411,7 @@ int processEvent(GHOST_EventHandle hEvent, GHOST_TUserDataPtr userData)
{
sExitRequested = 1;
}
else
{
else {
if (sGearsTimer)
{
GHOST_RemoveTimer(shSystem, sGearsTimer);
@ -547,8 +543,7 @@ static void gearsTimerProc(GHOST_TimerTaskHandle hTask, GHOST_TUns64 time)
/* Running full screen */
GHOST_InvalidateWindow(sFullScreenWindow);
}
else
{
else {
if (GHOST_ValidWindow(shSystem, hWindow))
{
GHOST_InvalidateWindow(hWindow);

@ -27,37 +27,47 @@
#include "Basic.h"
int min_i(int a, int b) {
int min_i(int a, int b)
{
return (a < b) ? a : b;
}
int max_i(int a, int b) {
int max_i(int a, int b)
{
return (b < a) ? a : b;
}
int clamp_i(int val, int min, int max) {
int clamp_i(int val, int min, int max)
{
return min_i(max_i(val, min), max);
}
float min_f(float a, float b) {
float min_f(float a, float b)
{
return (a < b) ? a : b;
}
float max_f(float a, float b) {
float max_f(float a, float b)
{
return (b < a) ? a : b;
}
float clamp_f(float val, float min, float max) {
float clamp_f(float val, float min, float max)
{
return min_f(max_f(val, min), max);
}
void rect_copy(int dst[2][2], int src[2][2]) {
void rect_copy(int dst[2][2], int src[2][2])
{
dst[0][0] = src[0][0], dst[0][1] = src[0][1];
dst[1][0] = src[1][0], dst[1][1] = src[1][1];
}
int rect_contains_pt(int rect[2][2], int pt[2]){
int rect_contains_pt(int rect[2][2], int pt[2])
{
return ((rect[0][0] <= pt[0] && pt[0] <= rect[1][0]) &&
(rect[0][1] <= pt[1] && pt[1] <= rect[1][1]));
}
int rect_width(int rect[2][2]) {
int rect_width(int rect[2][2])
{
return (rect[1][0] - rect[0][0]);
}
int rect_height(int rect[2][2]) {
int rect_height(int rect[2][2])
{
return (rect[1][1] - rect[0][1]);
}

@ -152,7 +152,8 @@ static void mainwindow_do_draw(MainWindow *mw) {
if (mw->lmbut[0]) {
glClearColor(0.5, 0.5, 0.5, 1);
} else {
}
else {
glClearColor(1, 1, 1, 1);
}
glClear(GL_COLOR_BUFFER_BIT);
@ -239,9 +240,11 @@ static void mainwindow_do_button(MainWindow *mw, int which, int press) {
mw->lmbut[0] = press;
mw->tmouse[0] = mw->lmouse[0], mw->tmouse[1] = mw->lmouse[1];
GHOST_InvalidateWindow(mw->win);
} else if (which==GHOST_kButtonMaskLeft) {
}
else if (which == GHOST_kButtonMaskLeft) {
mw->lmbut[1] = press;
} else if (which==GHOST_kButtonMaskLeft) {
}
else if (which == GHOST_kButtonMaskLeft) {
mw->lmbut[2] = press;
}
}
@ -312,7 +315,8 @@ MainWindow *mainwindow_new(MultiTestApp *app) {
GHOST_InstallTimer(sys, 1000, 10000, mainwindow_timer_proc, mw);
return mw;
} else {
}
else {
return NULL;
}
}
@ -421,7 +425,8 @@ static void loggerwindow_do_draw(LoggerWindow *lw) {
if (scrollbar_is_scrolling(lw->scroll)) {
glColor3f(0.6, 0.7, 0.5);
} else {
}
else {
glColor3f(0.9, 0.9, 0.92);
}
rect_bevel_smooth(sb_thumb, 1);
@ -447,7 +452,8 @@ static void loggerwindow_do_draw(LoggerWindow *lw) {
if (lw->fonttexid == -1) {
glRasterPos2i(x_pos, y_pos);
BMF_DrawString(lw->font, line);
} else {
}
else {
BMF_DrawStringTexture(lw->font, line, x_pos, y_pos, 0.0);
}
#else
@ -485,16 +491,19 @@ static void loggerwindow_do_button(LoggerWindow *lw, int which, int press) {
GHOST_SetCursorShape(lw->win, GHOST_kStandardCursorUpDown);
GHOST_InvalidateWindow(lw->win);
}
} else {
}
else {
if (scrollbar_is_scrolling(lw->scroll)) {
scrollbar_stop_scrolling(lw->scroll);
GHOST_SetCursorShape(lw->win, GHOST_kStandardCursorDefault);
GHOST_InvalidateWindow(lw->win);
}
}
} else if (which==GHOST_kButtonMaskMiddle) {
}
else if (which == GHOST_kButtonMaskMiddle) {
lw->lmbut[1] = press;
} else if (which==GHOST_kButtonMaskRight) {
}
else if (which == GHOST_kButtonMaskRight) {
lw->lmbut[2] = press;
}
}
@ -582,7 +591,8 @@ LoggerWindow *loggerwindow_new(MultiTestApp *app) {
loggerwindow_do_reshape(lw);
return lw;
} else {
}
else {
return NULL;
}
}
@ -748,7 +758,8 @@ ExtraWindow *extrawindow_new(MultiTestApp *app) {
GHOST_SetWindowUserData(ew->win, windowdata_new(ew, extrawindow_handle));
return ew;
} else {
}
else {
return NULL;
}
}
@ -788,7 +799,8 @@ static int multitest_event_handler(GHOST_EventHandle evt, GHOST_TUserDataPtr dat
WindowData *wb = GHOST_GetWindowUserData(win);
windowdata_handle(wb, evt);
} else {
}
else {
GHOST_TEventType type = GHOST_GetEventType(evt);
/* GHOST_kEventQuit are the only 'system' events,
@ -851,7 +863,8 @@ void multitestapp_free_extrawindow(MultiTestApp *app) {
void multitestapp_toggle_extra_window(MultiTestApp *app) {
if (app->extra) {
multitestapp_free_extrawindow(app);
} else {
}
else {
app->extra = extrawindow_new(app);
}
}

@ -45,19 +45,23 @@ struct _ScrollBar {
float scrolloffs;
};
static int scrollbar_get_thumbH(ScrollBar *sb) {
static int scrollbar_get_thumbH(ScrollBar *sb)
{
int scrollable_h = rect_height(sb->rect) - 2 * sb->inset;
return clamp_i(sb->thumbpct * scrollable_h, sb->minthumb, scrollable_h);
}
static int scrollbar_get_thumbableH(ScrollBar *sb) {
static int scrollbar_get_thumbableH(ScrollBar *sb)
{
int scrollable_h = rect_height(sb->rect) - 2 * sb->inset;
int thumb_h = scrollbar_get_thumbH(sb);
return scrollable_h - thumb_h;
}
static float scrollbar_co_to_pos(ScrollBar *sb, int yco) {
static float scrollbar_co_to_pos(ScrollBar *sb, int yco)
{
int thumb_h = scrollbar_get_thumbH(sb);
int thumbable_h = scrollbar_get_thumbableH(sb);
int thumbable_y = (sb->rect[0][1] + sb->inset) + thumb_h / 2;
@ -67,7 +71,8 @@ static float scrollbar_co_to_pos(ScrollBar *sb, int yco) {
/**/
ScrollBar *scrollbar_new(int inset, int minthumb) {
ScrollBar *scrollbar_new(int inset, int minthumb)
{
ScrollBar *sb = MEM_callocN(sizeof(*sb), "scrollbar_new");
sb->inset = inset;
sb->minthumb = minthumb;
@ -75,7 +80,8 @@ ScrollBar *scrollbar_new(int inset, int minthumb) {
return sb;
}
void scrollbar_get_thumb(ScrollBar *sb, int thumb_r[2][2]) {
void scrollbar_get_thumb(ScrollBar *sb, int thumb_r[2][2])
{
int thumb_h = scrollbar_get_thumbH(sb);
int thumbable_h = scrollbar_get_thumbableH(sb);
@ -86,14 +92,16 @@ void scrollbar_get_thumb(ScrollBar *sb, int thumb_r[2][2]) {
thumb_r[1][1] = thumb_r[0][1] + thumb_h;
}
int scrollbar_is_scrolling(ScrollBar *sb) {
int scrollbar_is_scrolling(ScrollBar *sb)
{
return sb->scrolling;
}
int scrollbar_contains_pt(ScrollBar *sb, int pt[2]) {
return rect_contains_pt(sb->rect, pt);
}
void scrollbar_start_scrolling(ScrollBar *sb, int yco) {
void scrollbar_start_scrolling(ScrollBar *sb, int yco)
{
int thumb_h_2 = scrollbar_get_thumbH(sb) / 2;
int thumbable_h = scrollbar_get_thumbableH(sb);
float npos = scrollbar_co_to_pos(sb, yco);
@ -106,36 +114,45 @@ void scrollbar_start_scrolling(ScrollBar *sb, int yco) {
sb->scrolling = 1;
sb->thumbpos = clamp_f(npos + sb->scrolloffs, 0.0, 1.0);
}
void scrollbar_keep_scrolling(ScrollBar *sb, int yco) {
void scrollbar_keep_scrolling(ScrollBar *sb, int yco)
{
float npos = scrollbar_co_to_pos(sb, yco);
sb->thumbpos = clamp_f(npos + sb->scrolloffs, 0.0, 1.0);
}
void scrollbar_stop_scrolling(ScrollBar *sb) {
void scrollbar_stop_scrolling(ScrollBar *sb)
{
sb->scrolling = 0;
sb->scrolloffs = 0.0;
}
void scrollbar_set_thumbpct(ScrollBar *sb, float pct) {
void scrollbar_set_thumbpct(ScrollBar *sb, float pct)
{
sb->thumbpct = pct;
}
void scrollbar_set_thumbpos(ScrollBar *sb, float pos) {
void scrollbar_set_thumbpos(ScrollBar *sb, float pos)
{
sb->thumbpos = clamp_f(pos, 0.0, 1.0);
}
void scrollbar_set_rect(ScrollBar *sb, int rect[2][2]) {
void scrollbar_set_rect(ScrollBar *sb, int rect[2][2])
{
rect_copy(sb->rect, rect);
}
float scrollbar_get_thumbpct(ScrollBar *sb) {
float scrollbar_get_thumbpct(ScrollBar *sb)
{
return sb->thumbpct;
}
float scrollbar_get_thumbpos(ScrollBar *sb) {
float scrollbar_get_thumbpos(ScrollBar *sb)
{
return sb->thumbpos;
}
void scrollbar_get_rect(ScrollBar *sb, int rect_r[2][2]) {
void scrollbar_get_rect(ScrollBar *sb, int rect_r[2][2])
{
rect_copy(rect_r, sb->rect);
}
void scrollbar_free(ScrollBar *sb) {
void scrollbar_free(ScrollBar *sb)
{
MEM_freeN(sb);
}

@ -35,7 +35,8 @@
#include "Util.h"
void* memdbl(void *mem, int *size_pr, int item_size) {
void *memdbl(void *mem, int *size_pr, int item_size)
{
int cur_size = *size_pr;
int new_size = cur_size ? (cur_size * 2) : 1;
void *nmem = MEM_mallocN(new_size * item_size, "memdbl");
@ -47,7 +48,8 @@ void* memdbl(void *mem, int *size_pr, int item_size) {
return nmem;
}
char* string_dup(char *str) {
char *string_dup(char *str)
{
int len = strlen(str);
char *nstr = MEM_mallocN(len + 1, "string_dup");
@ -56,7 +58,8 @@ char* string_dup(char *str) {
return nstr;
}
void fatal(char *fmt, ...) {
void fatal(char *fmt, ...)
{
va_list ap;
fprintf(stderr, "FATAL: ");

@ -38,7 +38,8 @@ struct _WindowData {
WindowDataHandler handler;
};
WindowData *windowdata_new(void *data, WindowDataHandler handler) {
WindowData *windowdata_new(void *data, WindowDataHandler handler)
{
WindowData *wb = MEM_mallocN(sizeof(*wb), "windowdata_new");
wb->data = data;
wb->handler = handler;
@ -46,10 +47,12 @@ WindowData *windowdata_new(void *data, WindowDataHandler handler) {
return wb;
}
void windowdata_handle(WindowData *wb, GHOST_EventHandle evt) {
void windowdata_handle(WindowData *wb, GHOST_EventHandle evt)
{
wb->handler(wb->data, evt);
}
void windowdata_free(WindowData *wb) {
void windowdata_free(WindowData *wb)
{
MEM_freeN(wb);
}

@ -155,7 +155,8 @@ static void rectcpy(ImBuf *dbuf, ImBuf *sbuf,
if (dbuf->rect_float) sfrect += 4 * tmp;
else srect += tmp;
srcx = sbuf->x;
} else{
}
else {
if (dbuf->rect_float) sfrect = dfrect;
else srect = drect;
srcx = destx;
@ -166,7 +167,8 @@ static void rectcpy(ImBuf *dbuf, ImBuf *sbuf,
memcpy(dfrect, sfrect, 4 * width * sizeof(float));
dfrect += destx;
sfrect += srcx;
} else {
}
else {
memcpy(drect, srect, width * sizeof(int));
drect += destx;
srect += srcx;
@ -189,7 +191,8 @@ static void fill_out(ImBuf *out, float r, float g, float b, float a)
rectf[3] = a;
rectf += 4;
}
} else {
}
else {
for (x = 0; x < tot; x++) {
rect[0] = (int)(r * 255);
rect[1] = (int)(g * 255);
@ -230,7 +233,8 @@ void plugin_seq_doit(Cast *cast, float facf0, float facf1, int sx, int sy, ImBuf
if (cast->wrap) f2 += 1.0;
lr = drand48() > 0.5;
t1 = facf0;
} else t1 = facf1;
}
else t1 = facf1;
t2 = 1.0 - t1;
t3 = 3.0 * (f1 * t1 * t1 * t2 + f2 * t1 * t2 * t2);