gui_console* gui_console_init ( char* name, double x, double y, double w, double h ) { gui_console* gc = malloc(sizeof(gui_console)); gc->name = malloc(strlen(name)); strcpy(gc->name, name); gc->bounds = _gui_box_init(x, y, w, h); char tname[1024]; sprintf(tname, "%s TEXTBOX", name); gc->out = gui_textbox_init(tname,x,y,w,h,GUI_CONSOLE_TEXTPT); sprintf(tname, "%s TEXT INPUT", name); gc->in = gui_textin_init(tname, x, y, w, h); sprintf(tname, "%s SUBMIT BUTTON", name); gc->submit = gui_button_init(name, x, y, w, h); gc->settings = hashtable_init(0); return gc; }
int main (int argc, char **argv) { int i, i2, row = 127; char bmp_hdr[54]; unsigned char buff[3]; FILE *file; oled_init(); oled_write_c(0xae); /* Display off */ oled_clear(); file = fopen("/root/splash.bmp", "rb"); fread(&bmp_hdr, 1, 54, file); for (i = 0; i < 128; i++) { for (i2 = 0; i2 < 128; i2++) { fread(&buff, 1, 3, file); frame_buffer[row][i2][0] = buff[2] / 4; frame_buffer[row][i2][1] = buff[1] / 4; frame_buffer[row][i2][2] = buff[0] / 4; } row--; } gui_textbox_t txtLoading; strcpy(txtLoading.text, "Loading..."); txtLoading.x = oled_screenwidth / 2; txtLoading.y = 100; txtLoading.maxwidth = 0; txtLoading.align = 2; txtLoading.mode = 0; txtLoading.color[0] = 17; txtLoading.color[1] = 27; txtLoading.color[2] = 45; gui_textbox_init(&txtLoading); //gui_textbox_draw(&txtLoading); oled_flush(); oled_write_c(0xaf); /* Display on */ return 0; }
void gui_init(event_bus *eb, mouse_state *ms, int w, int h) { // set up globals gui_eventbus = eb; gui_w = w; gui_h = h; gui_mousestate = ms; gui_aspectratio = (double)w/(double)h; gui_mousex = gui_aspectratio*(double)gui_mousestate->x/(double)gui_w; gui_mousey = 1.0-(double)gui_mousestate->y/(double)gui_h; gui_dials = calloc(SDR_NUMDIALS, sizeof(float)); // Set GUI colours color **cols = malloc(sizeof(color*)*6); cols[0] = color_new3(0.02, 0.18, 0.3); cols[1] = color_new3(0.8, 0.3, 0.1); cols[2] = color_new3(0.95, 0.95, 0.9); cols[3] = color_new3(0.08, 0.1, 0.1); cols[4] = color_new3(0.016, 0.2, 0.2); cols[5] = color_new3(0, 0, 0); gui_colors = color_newpack(cols, 6); // Set up GUI gui_fontinfo = font_init("extremeradcool", gui_colors->colors[2]); gui_div *dddials[SDR_NUMDIALS]; gui_contenttype ddtypes[SDR_NUMDIALS]; vec2 ddpos[SDR_NUMDIALS]; void (*ddevents[SDR_NUMDIALS])(void *) = { _updatedial0, _updatedial1, _updatedial2, _updatedial3, _updatedial4, _updatedial5, _updatedial6 }; static char ddnames[SDR_NUMDIALS][32] = { "Oftenality", "Affection", "Spiralitude", "Boxulation", "Nonstraightness", "Wanderlust", "Zoom" }; for(int i=0; i<SDR_NUMDIALS; i++) { gui_textbox *text = gui_textbox_init( ddnames[i], gui_fontinfo, 0.035, 0.0, 0.0 ); text->bounds->visible = 0; gui_slider *slider = gui_slider_initwithe( 0.5, 0.01, GUI_SLIDER_HORZ, bus_newevent(gui_eventbus), ddevents[i] ); dddials[i] = gui_div_initwith( GUI_DIV_HORZ, gui_container_initwith(1, 1, text, GUI_CONTENTTYPE_TEXTBOX, 0, 0.5), gui_container_initwith(1, 1, slider, GUI_CONTENTTYPE_SLIDER, 0.1, 0.1 ) ); dddials[i]->visible = 0; ddtypes[i] = GUI_CONTENTTYPE_DIV; ddpos[i].x = 0.5; ddpos[i].y = 0.5; } gui_container *dialdiv = gui_container_initmany( 1, 1, GUI_DIV_HORZ, (void **)dddials, ddtypes, ddpos, SDR_NUMDIALS ); gui_container *buttondiv = gui_container_initwith(1, 1, gui_div_initwith( GUI_DIV_VERT, gui_container_initwith(1, 1, gui_button_initwithfe( "Reset", gui_fontinfo, bus_newevent(gui_eventbus), NULL, _resettexture, 0.03 ), GUI_CONTENTTYPE_BUTTON, 0.5, 0.5 ), gui_container_initwith(1, 1, gui_button_initwithfe( "Quit", gui_fontinfo, bus_newevent(gui_eventbus), NULL, _quitthisshit, 0.03 ), GUI_CONTENTTYPE_BUTTON, 0.5, 0.5 ) ), GUI_CONTENTTYPE_DIV, 0.5, 0.5 ); ((gui_div *)(buttondiv->content))->visible = 0; gui_container *rightpane = gui_container_initwith(1, 1, gui_div_initwith(GUI_DIV_HORZ, dialdiv, buttondiv ), GUI_CONTENTTYPE_DIV, 0, 0.1 ); gui_message = malloc(512); sprintf(gui_message, "aass"); gui_container *leftpane = gui_container_initwith(1, 1, // gui_textbox_init( // gui_message, // gui_fontinfo, // 0.02, // 1.0, 0.1 // ), NULL, GUI_CONTENTTYPE_NULL, 0.0, 0.0 ); leftpane->visible = 1; gui_maingui = gui_container_initwith(gui_aspectratio, 1.0, gui_div_initwith(GUI_DIV_VERT, leftpane, rightpane ), GUI_CONTENTTYPE_DIV, 0.8, 0.9 ); // pc = gui_container_init(gui_aspectratio, 0.5); bus_subscribe(eb, mouse_event_up, (void *)gui_mouseupevent); bus_subscribe(eb, mouse_event_move, (void *)gui_mousemoveevent); }