void gui_draw(struct gui *G) { dword x=0; dword entry=0; dword cy=4; dword cx=3; byte *text; gui_base(G); current=G->first; G->tmp=(G->gui1)+(cy*G->width)+cx; while((current)&&(cy<G->height)) { text=current->item; for(x=0;x<8;x++) { G->rc=x; if(G->select==entry) { gui_text(G,text,G->scol); } else { gui_text(G,text,G->bkcol); } cy++; G->tmp=(G->tmp)+(G->width); } current=current->next; entry++; } gui_render(&gui_bitmap); }
void gui_bankinfo(int row, const char *label, const char *text) { int y0 = BANKINFO_Y; if(!row && !label && !text) { gui_bar(6, BANKINFO_Y, screen->w - 12, FONT_CH * 7 + 12, fwc, screen); return; } gui_text(12, y0 + 6 + FONT_CH * row, label, screen); gui_text(12 + 12 * FONT_CW, y0 + 6 + FONT_CH * row, text, screen); }
void gui_message(const char *message, int curspos) { int y0 = screen->h - FONT_CH - 12; SDL_Rect r; r.x = 10; r.y = y0 - 2; r.w = screen->w - 20; r.h = FONT_CH + 4; SDL_FillRect(screen, &r, SDL_MapRGB(screen->format, 0, 0, 0)); gui_dirty(&r); if(message) { free(message_text); message_text = strdup(message); } if(message_text) gui_text(12, y0, message_text, screen); if(curspos >= 0) gui_text(12 + FONT_CW * curspos, y0, "\007", screen); }
void gui_draw_screen(void) { int w; fwc = SDL_MapRGB(screen->format, 0, 128, 0); /* Clear */ SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 0, 48, 0)); gui_dirty(NULL); gui_logo(fwc); /* Oscilloscope frames */ w = (screen->w - 270) / 2 - 8; gui_bar(270 - 2, 8 - 2, w + 4, 128 + 4, fwc, screen); gui_bar(270 + w + 8 - 2, 8 - 2, w + 4, 128 + 4, fwc, screen); /* Song info panel */ gui_bar(6, 54, 258, 4 * FONT_CH + 12 + 8, fwc, screen); gui_cpuload(0); gui_voices(0); gui_instructions(0); /* Instructions */ gui_bar(6, 150, screen->w - 12, FONT_CH * 8 + 12, fwc, screen); gui_text(12, 156, "\005\001\003ESC to quit " "\005R to reload sounds\n" "\005\001\002F1..\005\001\003F12 for chromatic " "playing\n" "\005\001\005Shift or \005\001\004Ctrl for " "legato mode on the F keys\n" "\005*/\005/ to increase/decrease modulation\n" "\005\001\004PgUp/\005\001\004PgDn to " "shift one octave up/down\n" "\005P/\005Y to start/stop sound " "\005K to kill all sounds\n" "\005\001\003End/\005\001\004Home or " "\005\001\003Del/\005\001\003Ins to " "select next/previous bank\n" "\005+/\005- to select next/previous bank object\n", screen); gui_bankinfo(0, NULL, NULL); /* Message bar */ gui_bar(6, screen->h - FONT_CH - 12 - 6, screen->w - 12, FONT_CH + 12, fwc, screen); gui_message(NULL, -1); }
static void gui_logo(Uint32 c) { gui_bar(6, 6, 258, 44, c, screen); if(logo) { SDL_Rect r; r.x = 7; r.y = 7; r.w = logo->w; SDL_BlitSurface(logo, NULL, screen, &r); gui_dirty(&r); } else { gui_text(18, 17, " Audiality 2", screen); gui_box(6 + 3, 6 + 3, 258 - 6, 44 - 6, c, screen); } }
void gui_instructions(int v) { char buf[32]; snprintf(buf, sizeof(buf), "I/s: %8.1d", v); gui_text(12, 60 + FONT_CH * 2, buf, screen); }
void gui_voices(int v) { char buf[32]; snprintf(buf, sizeof(buf), " Voices: %4.1d", v); gui_text(12, 60 + FONT_CH, buf, screen); }
void gui_cpuload(int v) { char buf[32]; snprintf(buf, sizeof(buf), "CPULoad: %3.1d%%", v); gui_text(12, 60, buf, screen); }
uint8_t gui_draw_list() { if(gui_CurList == 0) return 0; SSD1306_DrawFilledRectangle(gui_CurList->x, gui_CurList->y, gui_CurList->w, gui_CurList->h, 0); SSD1306_DrawRectangle(gui_CurList->x, gui_CurList->y, gui_CurList->w, gui_CurList->h, 1); uint8_t ry = gui_CurList->y + 2; if(gui_CurList->header != 0) { gui_text(gui_CurList->header, gui_CurList->x + 1, gui_CurList->y, 1); ry += GUI_DefFont.FontHeight; } uint8_t maxC = ((gui_CurList->h - 3) / GUI_DefFont.FontHeight) - (gui_CurList->header != 0); uint16_t i; if(maxC >= gui_CurList->ItemsCount) { for(i = 0; i < gui_CurList->ItemsCount; i++) { if(i != gui_CurList->selectedItem) gui_lable(gui_CurList->items[i].text, gui_CurList->x + 1, ry + i*GUI_DefFont.FontHeight, gui_CurList->w - 3, GUI_DefFont.FontHeight, 0, 0); else { gui_lable(gui_CurList->items[i].getScrollOffset(), gui_CurList->x +1 , ry + i*GUI_DefFont.FontHeight, gui_CurList->w - 3, GUI_DefFont.FontHeight, 1, 0); } } } else { if(gui_CurList->ItemsCount - 1 - gui_CurList->selectedItem < maxC / 2) { for(i = gui_CurList->ItemsCount - maxC; i < gui_CurList->ItemsCount; i++) { if(i != gui_CurList->selectedItem) gui_lable(gui_CurList->items[i].text, gui_CurList->x + 1, ry + (i - gui_CurList->ItemsCount + maxC)*GUI_DefFont.FontHeight, gui_CurList->w - 3, GUI_DefFont.FontHeight, 0, 0); else gui_lable(gui_CurList->items[i].getScrollOffset(), gui_CurList->x + 1, ry + (i - gui_CurList->ItemsCount + maxC)*GUI_DefFont.FontHeight, gui_CurList->w - 3, GUI_DefFont.FontHeight, 1, 0); } } else if(gui_CurList->selectedItem < maxC / 2) { for(i = 0; i < maxC; i++) { if(i != gui_CurList->selectedItem) gui_lable(gui_CurList->items[i].text, gui_CurList->x + 1, ry + i*GUI_DefFont.FontHeight, gui_CurList->w - 3, GUI_DefFont.FontHeight, 0, 0); else gui_lable(gui_CurList->items[i].getScrollOffset(), gui_CurList->x + 1, ry + i*GUI_DefFont.FontHeight, gui_CurList->w - 3, GUI_DefFont.FontHeight, 1, 0); } } else { for(i = gui_CurList->selectedItem - maxC/2; i < gui_CurList->selectedItem - maxC/2 + maxC; i++) { if(i != gui_CurList->selectedItem) gui_lable(gui_CurList->items[i].text, gui_CurList->x + 1, ry + (i - gui_CurList->selectedItem + maxC/2)*GUI_DefFont.FontHeight, gui_CurList->w - 3, GUI_DefFont.FontHeight, 0, 0); else gui_lable(gui_CurList->items[i].getScrollOffset(), gui_CurList->x + 1, ry + (i - gui_CurList->selectedItem + maxC/2)*GUI_DefFont.FontHeight, gui_CurList->w - 3, GUI_DefFont.FontHeight, 1, 0); } } } uint8_t sli_h = gui_CurList->h / gui_CurList->ItemsCount; if(sli_h < 10) sli_h = 10; uint8_t yy = ((gui_CurList->h) * gui_CurList->selectedItem) / gui_CurList->ItemsCount; SSD1306_DrawLine(gui_CurList->x, ry - 2, gui_CurList->x + gui_CurList->w, ry - 2, 1); SSD1306_DrawLine(gui_CurList->x + gui_CurList->w - 1, gui_CurList->y + yy, gui_CurList->x + gui_CurList->w - 1, gui_CurList->y + yy + sli_h, 1); return 0; }