Window::Window(int rows, int cols, int ypos, int xpos, const std::string& title) : _rows(rows), _cols(cols), _ypos(ypos), _xpos(xpos), _title(title) { _wptr = newwin(_rows, _cols, _ypos, _xpos); draw_title(); scrollok(_wptr, true); }
void jWap_titleHandler (JC_CHAR *pmTitle) { mmi_trace (1, "JDD_LOG: jWap_titleHandler @@@") ; if(!pmTitle) return; //PARAM_INTENTIONALLY_NOT_USED (pvArg) ; if(NULL != g_pstJWapAppInfo->pszTitleString) { jdd_MemFree(g_pstJWapAppInfo->pszTitleString) ; g_pstJWapAppInfo->pszTitleString = JC_NULL ; ChangeTitleString (NULL) ; } g_pstJWapAppInfo->pszTitleString = (JC_CHAR*)jdd_MemAlloc(jc_wstrlen(pmTitle)+1,sizeof(JC_CHAR)) ; jc_wstrcpy(g_pstJWapAppInfo->pszTitleString,pmTitle) ; if(g_pstJWapAppInfo->bIsPriMmiActive) { ChangeTitleString ((U8*)g_pstJWapAppInfo->pszTitleString) ; draw_title(); } }
int main(void) { int i; srand((unsigned)time(NULL)); setcursortype(NOCURSOR); draw_title(); reset(); while (1) { for (i = 0; i<5; i++) //블록이 한칸떨어지는동안 5번 키입력받을 수 있음 { process_key(); //키입력확인 draw_game(); Sleep(speed); if (crush_on&&check_crush(bx, by + 1, b_rotation) == false) Sleep(100); //블록이 충돌중인경우 추가로 이동및 회전할 시간을 갖음 if (space_key_on == 1) //스페이스바를 누른경우(hard drop) 추가로 이동및 회전할수 없음 break; { space_key_on = 0; break; } } move_down(); check_level_up(); check_game_over(); if (new_block_on == 1) new_block(); // 뉴 블럭 flag가 있는 경우 새로운 블럭 생성 } }
void dialog_frame::draw() { //draw background draw_background(); //draw frame border draw_border(); //draw title if (!title_.empty()) { draw_title(&video_); } //draw buttons SDL_Rect buttons_area = dim_.button_row; if(buttons_ != NULL) { #ifdef OK_BUTTON_ON_RIGHT std::reverse(buttons_->begin(),buttons_->end()); #endif for(std::vector<button*>::const_iterator b = buttons_->begin(); b != buttons_->end(); ++b) { (**b).set_location(buttons_area.x, buttons_area.y); buttons_area.x += (**b).width() + ButtonHPadding; } } if(help_button_ != NULL) { help_button_->set_location(dim_.interior.x+ButtonHPadding, buttons_area.y); } }
void call_list_draw_header(PANEL *panel) { const char *infile, *coldesc; int height, width, colpos, collen, i; // Get panel info call_list_info_t *info = call_list_info(panel); // Let's draw the fixed elements of the screen WINDOW *win = panel_window(panel); getmaxyx(win, height, width); // Draw panel title draw_title(panel, "sngrep - SIP messages flow viewer"); // Draw a Panel header lines clear_line(win, 1); if ((infile = capture_get_infile())) mvwprintw(win, 1, width - strlen(infile) - 11, "Filename: %s", infile); mvwprintw(win, 2, 2, "Display Filter: "); mvwprintw(win, 1, 2, "Current Mode: %s", capture_get_status_desc()); // Reverse colors on monochrome terminals if (!has_colors()) wattron(win, A_REVERSE); // Draw columns titles wattron(win, A_BOLD | COLOR_PAIR(CP_DEF_ON_CYAN)); mvwprintw(win, 3, 0, "%*s", width, ""); for (colpos = 6, i = 0; i < info->columncnt; i++) { // Get current column width collen = info->columns[i].width; // Get current column title coldesc = sip_attr_get_title(info->columns[i].id); // Check if the column will fit in the remaining space of the screen if (colpos + strlen(coldesc) >= width) break; mvwprintw(win, 3, colpos, "%.*s", collen, coldesc); colpos += collen + 1; } // Print Autoscroll indicator if (info->autoscroll) mvwprintw(win, 3, 0, "A"); wattroff(win, A_BOLD | A_REVERSE | COLOR_PAIR(CP_DEF_ON_CYAN)); // Get filter call counters sip_calls_stats(&info->callcnt, &info->dispcallcnt); // Print calls count (also filtered) mvwprintw(win, 1, 35, "%*s", 35, ""); if (info->callcnt != info->dispcallcnt) { mvwprintw(win, 1, 35, "Dialogs: %d (%d displayed)", info->callcnt, info->dispcallcnt); } else { mvwprintw(win, 1, 35, "Dialogs: %d", info->callcnt); } }
void Renderer::Pass2(const Pipeline &pipeline, const PipelineContext &pipelineContext) { //BEGIN PASS 2 // //end of texture rendering //now we copy the texture from the FBO or framebuffer to //video texture memory and render fullscreen. /** Reset the viewport size */ #ifdef USE_FBO if (renderTarget->renderToTexture) { glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, this->renderTarget->fbuffer[1]); glViewport(0, 0, this->renderTarget->texsize, this->renderTarget->texsize); } else #endif glViewport(0, 0, this->vw, this->vh); glBindTexture(GL_TEXTURE_2D, this->renderTarget->textureID[0]); glMatrixMode(GL_PROJECTION); glLoadIdentity(); #ifdef USE_GLES1 glOrthof(-0.5, 0.5, -0.5, 0.5, -40, 40); #else glOrtho(-0.5, 0.5, -0.5, 0.5, -40, 40); #endif glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glLineWidth(this->renderTarget->texsize < 512 ? 1 : this->renderTarget->texsize / 512.0); CompositeOutput(pipeline, pipelineContext); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glTranslatef(-0.5, -0.5, 0); // When console refreshes, there is a chance the preset has been changed by the user refreshConsole(); draw_title_to_screen(false); if (this->showhelp % 2) draw_help(); if (this->showtitle % 2) draw_title(); if (this->showfps % 2) draw_fps(this->realfps); if (this->showpreset % 2) draw_preset(); if (this->showstats % 2) draw_stats(); glTranslatef(0.5, 0.5, 0); #ifdef USE_FBO if (renderTarget->renderToTexture) glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); #endif }
/* void draw_title (ESContext *esContext, char *text) { */ int tclcmd_draw_title (ClientData cdata, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { int len = 0; if (objc != 2) { Tcl_WrongNumArgs (interp, 1, objv, "{ESContext *esContext} { char *text}"); return TCL_ERROR; } char arg_text[1024]; strncpy(arg_text, Tcl_GetStringFromObj(objv[1], &len), 1024); draw_title(GlobalesContext, arg_text); return TCL_OK; }
void jWap_PopupCallBack() { INT iErr ; ST_BE_PAGE_CONTENT stPageCont ; jc_memset (&stPageCont, 0, sizeof (ST_BE_PAGE_CONTENT)) ; mmi_trace (1, "JDD_LOG: jWap_PopupCallBack starts") ; if((!isInWapApp())||isInCall()) { GoBackHistory(); mmi_trace (1, "JDD_LOG: go back screen ignoring") ; return; } if (E_WAP_EXIT_KEY_END == g_pstJWapAppInfo->stWapState.eWapExitKeyPressed) { mmi_trace (1, "JDD_LOG: aborting screen ignoring") ; return; } iErr = jdi_BEGetPageContent (g_pstJWapAppInfo->hBECore, &stPageCont) ; if (iErr) { // There is no content displayed on Primary MMI jWap_options_quit_handler () ; } else { if (!jWap_isBack ()) { //ChangeRightSoftkey (STR_GLOBAL_QUIT, 0) ; //This is the first page. Remove RSK ClearKeyHandler (KEY_RSK, KEY_EVENT_DOWN) ; } else { // There are more than 1 page. Set to "Back" ChangeRightSoftkey (STR_GLOBAL_BACK, 0) ; SetRightSoftkeyFunction (jWap_back, KEY_EVENT_UP) ; } ChangeLeftSoftkey (STR_GLOBAL_OPTIONS, 0) ; SetLeftSoftkeyFunction (jWap_options_handler, KEY_EVENT_UP) ; ChangeTitleIcon (IMG_ID_JATAAYU_WAP_END_ANIMATION_GIF) ; //setup_scrolling_title () ; draw_title () ; jmms_goto_primaryMMI(); } mmi_trace (1, "@@@ jWap_PopupCallBack end @@@") ; }
static bool_t draw_cb (GtkWidget * widget, cairo_t * cr) { g_return_val_if_fail (area, FALSE); clear (widget, cr); draw_album_art (cr); draw_title (cr); return TRUE; }
static void stats_display_layout(uint8_t in_place) { uint8_t cur_stats_height; cur_stats_height = current_screen->get_height(); cur_stats_height = cur_stats_height > max_n_lines? max_n_lines: cur_stats_height; display_lock(); if (!in_place) { // moving existing windows does not work delwin(win_txt); delwin(win_general); delwin(win_title); delwin(win_tabs); delwin(win_cmd); delwin(win_txt); delwin(win_help); clear(); } if (!in_place) { win_stat = create_subwindow(cur_stats_height + 2, 0, 4, 0); win_tabs = create_subwindow(1, 0, 1, 0); win_general = create_subwindow(2, 0, 2, 0); win_title = create_subwindow(1, 0, 0, 0); win_cmd = create_subwindow(1, 0, cur_stats_height + 2 + 4, 0); win_txt_height = LINES - cur_stats_height - 2 - 3 - 3; win_txt = create_subwindow(win_txt_height, 0, cur_stats_height + 4 + 3, 0); win_help = create_subwindow(1, 0, LINES - 1, 0); } draw_title(); draw_general_frame(); /* Command line */ wbkgd(win_cmd, COLOR_PAIR(BLACK_ON_YELLOW)); idlok(win_cmd, FALSE); /* Move cursor at insertion point */ leaveok(win_cmd, FALSE); draw_status_bar(); draw_log_window(); /* Draw everything to the screen */ refresh(); current_screen->draw_frame(&screen_state); display_unlock(); refresh_cmd_win(); display_stats(); }
/*************************************************************************** * All Local Function Definitions ***************************************************************************/ void jWap_endDispHandler (ST_BE_END_PAGE_INFO* pstCallbackInfo) { mmi_trace (1, "JDD_LOG: jWap_endDispHandler rCode [%X], eStatus [%d], rPageStatusCode [%X], bRequestPending [%d]", -pstCallbackInfo->rCode, pstCallbackInfo->eStatus, -pstCallbackInfo->rPageStatusCode, pstCallbackInfo->bRequestPending) ; /* See whether Authorization Info is set */ if (g_pstJWapAppInfo->pstFetchReq) { DisplayPopupCallBack((PU8)GetString(STR_ID_WAP_AUTHORIZATION), IMG_GLOBAL_INFO, 1, \ 3000, 1, jWap_showAuthUserNameScreen); //Last argument is tone id. 1 = ERROR tone } else if (!pstCallbackInfo->stNavg.bBackNavigation && GetActiveScreenId() == SCR_ID_WAP_HOMEPAGE_SCREEN) { /* This is the first page. Remove LSK */ ClearKeyHandler (KEY_RSK, KEY_EVENT_DOWN) ; ChangeRightSoftkey (0, 0) ; ChangeLeftSoftkey (STR_GLOBAL_OPTIONS, 0) ; SetLeftSoftkeyFunction (jWap_options_handler, KEY_EVENT_UP) ; ChangeTitleIcon (IMG_ID_JATAAYU_WAP_END_ANIMATION_GIF) ; draw_title () ; } else if(GetActiveScreenId() == SCR_ID_WAP_HOMEPAGE_SCREEN) { /* There are more than 1 page. Set to "Back" */ ChangeRightSoftkey (STR_GLOBAL_BACK, 0) ; SetRightSoftkeyFunction (jWap_back, KEY_EVENT_UP); ChangeLeftSoftkey (STR_GLOBAL_OPTIONS, 0) ; SetLeftSoftkeyFunction (jWap_options_handler, KEY_EVENT_UP) ; ChangeTitleIcon (IMG_ID_JATAAYU_WAP_END_ANIMATION_GIF) ; draw_title () ; } }
void mmi_EntrySECSETFDNDetails_hdlr(S32 index) { switch(index) { case 0: ChangeTitleString((PU8)GetString(STR_ID_PHB_NAME)); break; case 1: ChangeTitleString((PU8)GetString(STR_ID_PHB_MOBILE_NUMBER)); break; default: break; } draw_title(); }
INT jWap_beginDispHandler () { /* Disable LSK when fetching is in progress */ if(GetActiveScreenId() == SCR_ID_WAP_HOMEPAGE_SCREEN) { ClearKeyHandler (KEY_LSK, KEY_EVENT_DOWN) ; ChangeLeftSoftkey (0, 0) ; /* Set RSK to cancel */ ChangeRightSoftkey (STR_GLOBAL_CANCEL, KEY_EVENT_UP) ; SetRightSoftkeyFunction (jWap_priMmi_cancel_handler, KEY_EVENT_UP) ; ChangeTitleIcon (IMG_ID_JATAAYU_WAP_ANIMATION_GIF) ; draw_title(); } return (JC_OK) ; }
void Operation::on_begin_print(const Glib::RefPtr<Gtk::PrintContext>& print) { width_ = print->get_width(); height_ = print->get_height(); //Get a Cairo Context, which is used as a drawing board: Cairo::RefPtr<Cairo::Context> cairo = print->get_cairo_context(); cairo->select_font_face( "Sans", Cairo::FONT_SLANT_NORMAL, Cairo::FONT_WEIGHT_NORMAL); //We'll use black letters: cairo->set_source_rgb( 0, 0, 0); draw_title(print); draw_patient_info(print); draw_study_info(print); }
void draw(Game_Data *data) { switch(current_state) { case GAME: draw_game(data); break; case TITLE: draw_title(data); break; case MENU: draw_menu(data); break; case GAME_OVER: draw_game_over(data); break; case OUT_OF_MEMORY: draw_oom(data); break; } }
void screen_graph(ESContext *esContext) { uint16_t n = 0; draw_title(esContext, "Graph (Test-Page)"); for (n = 0; n < 10; n++) { graph_data[n][graph_pointer] = rand(); } graph_data[0][graph_pointer] = (uint8_t)(ModelData[ModelActive].gyro_x / 4.0 + 128); graph_data[1][graph_pointer] = (uint8_t)(ModelData[ModelActive].gyro_y / 4.0 + 128); graph_data[2][graph_pointer] = (uint8_t)(ModelData[ModelActive].gyro_z / 4.0 + 128); graph_data[3][graph_pointer] = (uint8_t)(ModelData[ModelActive].acc_x * 128.0 + 128); graph_data[4][graph_pointer] = (uint8_t)(ModelData[ModelActive].acc_y * 128.0 + 128); if (graph_pointer < graph_size) { graph_pointer++; } else { graph_pointer = 0; } for (n = 0; n < 10; n++) { draw_graph_value(esContext, -1.2, 0.8, 1.2, 0.8 + 0.10, 0.001, graph_data[n], graph_size, graph_pointer, n * 25, n * 25, n * 25, 255); draw_graph_value(esContext, -1.2, -0.8 + (float)n * 0.12, 1.2, -0.8 + (float)n * 0.12 + 0.10, 0.001, graph_data[n], graph_size, graph_pointer, 255 - n * 25, n * 25, n * 125, 255); } draw_rect_f3(esContext, -1.2, 0.8, 0.001, 1.2, 0.8 + 0.10, 0.001, 255, 255, 255, 255); }
void title_tick() { if (!title.in_multiload) { if (title.seldelay > 0) { ClearScreen(BLACK); title.seldelay--; if (!title.seldelay) selectoption(title.selchoice); return; } handle_input(); draw_title(); } else { ClearScreen(BLACK); if (!textbox.SaveSelect.IsVisible()) { // selection was made, and settings.last_save_slot is now set appropriately sound(SND_MENU_SELECT); textbox.SetVisible(false); title.selchoice = 1; title.seldelay = SELECT_LOAD_DELAY; title.in_multiload = false; } else { textbox.Draw(); } } }
void BeyeContext::main_loop() { __filesize_t OldCurrFilePos; /** means previous File position */ int ch; __filesize_t savep = 0,cfp,nfp,flen; unsigned long lwidth; plugin_position rc; Search& s = search(); bm_file().seek(LastOffset,binary_stream::Seek_Set); drawPrompt(); rc.textshift=0; rc = active_mode().paint(KE_SUPERKEY,rc.textshift); bm_file().seek(LastOffset,binary_stream::Seek_Set); draw_title(rc.lastbyte); while(1) { unsigned che; ch = GetEvent(drawPrompt,MainActionFromMenu,NULL); nfp = cfp = OldCurrFilePos = tell(); flen = flength(); lwidth = active_mode().curr_line_width(); che = ch & 0x00FF; if(((che >= '0' && che <= '9') || (che >= 'A' && che <= 'Z') || (che >= 'a' && che <= 'z') || ch == KE_BKSPACE) && (active_mode().flags() & Plugin::UseCodeGuide) == Plugin::UseCodeGuide) { nfp = codeguider().get_go_address(ch); goto GO; } switch(ch) { case KE_CTL_F(1): if(active_mode().action_F1()) { ch = KE_SUPERKEY; drawPrompt(); } break; case KE_CTL_F(2): if(active_mode().action_F2()) { ch = KE_SUPERKEY; drawPrompt(); } break; case KE_CTL_F(3): if(active_mode().action_F3()) { ch = KE_SUPERKEY; drawPrompt(); } break; case KE_CTL_F(4): if(active_mode().action_F4()) { ch = KE_SUPERKEY; drawPrompt(); } break; case KE_CTL_F(5): if(active_mode().action_F5()) { ch = KE_SUPERKEY; drawPrompt(); } break; case KE_CTL_F(6): if(active_mode().action_F6()) { ch = KE_SUPERKEY; drawPrompt(); } break; case KE_CTL_F(7): if(active_mode().action_F7()) { ch = KE_SUPERKEY; drawPrompt(); } break; case KE_CTL_F(8): if(active_mode().action_F8()) { ch = KE_SUPERKEY; drawPrompt(); } break; case KE_CTL_F(9): if(active_mode().action_F9()) { ch = KE_SUPERKEY; drawPrompt(); } break; case KE_CTL_F(10): if(active_mode().action_F10()) { ch = KE_SUPERKEY; drawPrompt(); } break; case KE_ALT_F(1): nfp=bin_format().action_F1(); break; case KE_ALT_F(2): nfp=bin_format().action_F2(); break; case KE_ALT_F(3): nfp=bin_format().action_F3(); break; case KE_ALT_F(4): nfp=bin_format().action_F4(); break; case KE_ALT_F(5): nfp=bin_format().action_F5(); break; case KE_ALT_F(6): nfp=bin_format().action_F6(); break; case KE_ALT_F(7): nfp=bin_format().action_F7(); break; case KE_ALT_F(8): nfp=bin_format().action_F8(); break; case KE_ALT_F(9): nfp=bin_format().action_F9(); break; case KE_ALT_F(10): nfp=bin_format().action_F10(); break; case KE_SUPERKEY: goto DRAW; case KE_F(1) : About(); continue; default : continue; case KE_SHIFT_F(1): active_mode().help(); break; case KE_F(10): case KE_ESCAPE : return; case KE_ENTER: quick_select_mode(); drawPrompt(); ch = KE_SUPERKEY; break; case KE_F(2): if(select_mode()) ch = KE_SUPERKEY; break; case KE_F(3): if(new_source()) { ch = KE_SUPERKEY; s.reset(); PaintTitle(); } break; case KE_F(4): __filesize_t sfp; sfp = tell(); active_mode().misckey_action(); ch = KE_SUPERKEY; PaintTitle(); drawPrompt(); bm_file().seek(sfp,binary_stream::Seek_Set); break; case KE_F(5): { static __filesize_t shift = 0; static unsigned long flags = GJDLG_FILE_TOP; if(GetJumpDlg(&shift,&flags)) { switch(flags&0xFF) { default: case GJDLG_PERCENTS: shift=shift>100?100:shift; nfp = flength()*shift/100; break; case GJDLG_FILE_TOP: nfp = shift; break; case GJDLG_RELATIVE: nfp += (long)shift; break; case GJDLG_REL_EOF: nfp = flength()+(long)shift; break; case GJDLG_VIRTUAL: __filesize_t temp_fp; nfp = shift; temp_fp = bin_format().va2pa(shift); if(temp_fp==Plugin::Bad_Address) ErrMessageBox(NOT_ENTRY,""); else nfp = temp_fp; break; } if((active_mode().flags() & Plugin::UseCodeGuide) == Plugin::UseCodeGuide) codeguider().add_back_address(); ch = KE_SUPERKEY; } } break; case KE_SHIFT_F(5): { WhereAMI wami(beye_context()); nfp = wami.run(nfp); } break; case KE_F(6): bm_file().reread(); s.reset(); ch = KE_SUPERKEY; PaintTitle(); break; case KE_SHIFT_F(6): select_sysinfo(); break; case KE_F(7): nfp = s.run(false); ch = KE_JUSTFIND; break; case KE_SHIFT_F(7): nfp = s.run(true); ch = KE_JUSTFIND; break; case KE_F(8): nfp = bin_format().show_header(); break; case KE_SHIFT_F(8): select_tool(); break; case KE_F(9): { class Setup* setup = new class Setup(*this); setup->run(); delete setup; } break; case KE_SHIFT_F(10): if(FileUtils()) { s.reset(); ch = KE_SUPERKEY; PaintTitle(); } break; case KE_HOME: rc.textshift = 0; break; case KE_END: rc.textshift = active_mode().get_max_line_length() - tconsole().vio_width()/2; break; case KE_UPARROW: nfp = cfp - active_mode().prev_line_width(); break; case KE_DOWNARROW: nfp = cfp + active_mode().curr_line_width(); break; case KE_RIGHTARROW: if((active_mode().flags() & Plugin::Text) == Plugin::Text) rc.textshift+=active_mode().get_symbol_size(); else nfp = cfp + active_mode().get_symbol_size(); break; case KE_LEFTARROW: if((active_mode().flags() & Plugin::Text) == Plugin::Text) rc.textshift-=active_mode().get_symbol_size(); else nfp = cfp - active_mode().get_symbol_size(); if(rc.textshift < 0) rc.textshift = 0; break; case KE_CTL_RIGHTARROW: if((active_mode().flags() & Plugin::Text) == Plugin::Text) rc.textshift+=8*active_mode().get_symbol_size(); else nfp = cfp + 8*active_mode().get_symbol_size(); break; case KE_CTL_LEFTARROW: if((active_mode().flags() & Plugin::Text) == Plugin::Text) rc.textshift-=8*active_mode().get_symbol_size(); else nfp = cfp - 8*active_mode().get_symbol_size(); if(rc.textshift < 0) rc.textshift = 0; break; case KE_PGUP: nfp = cfp - active_mode().prev_page_size(); break; case KE_PGDN: nfp = cfp + active_mode().curr_page_size(); break; case KE_CTL_PGUP: nfp = 0; break; case KE_CTL_PGDN: nfp = flen; break; case KE_CTL_(O): /** User screen */ { unsigned evt; main_wnd().hide(); title_wnd().hide(); do { evt = GetEvent(drawEmptyPrompt,NULL,NULL); } while(!(evt == KE_ESCAPE || evt == KE_F(10) || evt == KE_CTL_(O))); main_wnd().show(); title_wnd().show(); } continue; } GO: if(cfp != nfp && nfp != Plugin::Bad_Address) { unsigned long twidth = ( active_mode().flags() & Plugin::Text ) == Plugin::Text ? active_mode().get_symbol_size() : ( active_mode().flags() & Plugin::Disasm ) == Plugin::Disasm ? 1 : lwidth; __filesize_t p = flen - twidth; if((__fileoff_t)nfp < 0) nfp = 0; if(nfp > 0) if(nfp > p) nfp = p; } bm_file().seek(nfp,binary_stream::Seek_Set); DRAW: if((active_mode().flags() & Plugin::Text) != Plugin::Text) savep = tell(); rc = active_mode().paint(ch,rc.textshift); if((active_mode().flags() & Plugin::Text) != Plugin::Text) bm_file().seek(savep,binary_stream::Seek_Set); draw_title(rc.lastbyte); } }
void ResourcePixmap::draw_data(Edit *edit, int64_t edit_x, int64_t edit_w, int64_t pixmap_x, int64_t pixmap_w, int64_t pixmap_h, int mode, int indexes_only) { // Get new areas to fill in relative to pixmap // Area to redraw relative to pixmap int refresh_x = 0; int refresh_w = 0; // Ignore if called by resourcethread. if(mode == 3) return; int y = 0; if(mwindow->edl->session->show_titles) y += mwindow->theme->get_image("title_bg_data")->get_h(); Track *track = edit->edits->track; // If index can't be drawn, don't do anything. int need_redraw = 0; int64_t index_zoom = 0; if(indexes_only) { IndexFile indexfile(mwindow); if(!indexfile.open_index(edit->asset)) { index_zoom = edit->asset->index_zoom; indexfile.close_index(); } if(index_zoom) { if(data_type == TRACK_AUDIO) { double asset_over_session = (double)edit->asset->sample_rate / mwindow->edl->session->sample_rate; asset_over_session; if(index_zoom <= mwindow->edl->local_session->zoom_sample * asset_over_session) need_redraw = 1; } } if(!need_redraw) return; } // Redraw everything if(edit->startsource != this->startsource || /* Incremental drawing is not possible with resource thread */ (data_type == TRACK_AUDIO /* && edit->asset->sample_rate != source_samplerate*/ ) || (data_type == TRACK_VIDEO /* && !EQUIV(edit->asset->frame_rate, source_framerate) */ ) || mwindow->edl->session->sample_rate != project_samplerate || mwindow->edl->session->frame_rate != project_framerate || mwindow->edl->local_session->zoom_sample != zoom_sample || mwindow->edl->local_session->zoom_track != zoom_track || this->pixmap_h != pixmap_h || (data_type == TRACK_AUDIO && mwindow->edl->local_session->zoom_y != zoom_y) || (mode == 2) || need_redraw) { // Shouldn't draw at all if zoomed in below index zoom. refresh_x = 0; refresh_w = pixmap_w; } else { // Start translated right if(pixmap_w == this->pixmap_w && edit_x < this->edit_x && edit_w != pixmap_w) { refresh_w = this->edit_x - edit_x; refresh_x = this->pixmap_w - refresh_w; // Moved completely off the pixmap if(refresh_w > this->pixmap_w) { refresh_w = this->pixmap_w; refresh_x = 0; } else { copy_area(refresh_w, y, refresh_x, mwindow->edl->local_session->zoom_track, 0, y); } } else // Start translated left if(pixmap_w == this->pixmap_w && edit_x > this->edit_x && edit_w != pixmap_w) { refresh_x = 0; refresh_w = edit_x - this->edit_x; // Moved completely off the pixmap if(refresh_w > this->pixmap_w) { refresh_w = this->pixmap_w; } else { copy_area(0, y, this->pixmap_w - refresh_w, mwindow->edl->local_session->zoom_track, refresh_w, y); } } else // Start translated right and pixmap came off of right side if(pixmap_w < this->pixmap_w && edit_x < this->edit_x && this->edit_x + edit_w > this->pixmap_x + this->pixmap_w) { refresh_w = (this->edit_x + edit_w) - (this->pixmap_x + this->pixmap_w); refresh_x = pixmap_w - refresh_w; if(refresh_w >= pixmap_w) { refresh_x = 0; refresh_w = pixmap_w; } else { copy_area(this->edit_x - edit_x, y, pixmap_w - refresh_w, mwindow->edl->local_session->zoom_track, 0, y); } } else // Start translated right and reduced in size on the right. if(pixmap_w < this->pixmap_w && edit_x < this->edit_x) { refresh_x = 0; refresh_w = 0; copy_area(this->pixmap_w - pixmap_w, y, pixmap_w, mwindow->edl->local_session->zoom_track, 0, y); } else // Start translated left and pixmap came off left side if(edit_x >= 0 && this->edit_x < 0) { refresh_x = 0; refresh_w = -this->edit_x; if(refresh_w > pixmap_w) { refresh_w = pixmap_w; } else { copy_area(0, y, this->pixmap_w, mwindow->edl->local_session->zoom_track, refresh_w, y); } } else // Start translated left and reduced in size on the right if(pixmap_w < this->pixmap_w && edit_x > this->edit_x) { refresh_x = 0; refresh_w = 0; } else // Start translated right and left went into left side. if(pixmap_w > this->pixmap_w && edit_x < 0 && this->edit_x > 0) { refresh_w = pixmap_w - (edit_x + this->pixmap_w); refresh_x = pixmap_w - refresh_w; // Moved completely off new pixmap if(refresh_w > pixmap_w) { refresh_w = pixmap_w; refresh_x = 0; } else { copy_area(-edit_x, y, refresh_x, mwindow->edl->local_session->zoom_track, 0, y); } } else // Start translated right and increased in size on the right if(pixmap_w > this->pixmap_w && edit_x <= this->edit_x) { refresh_w = pixmap_w - this->pixmap_w; refresh_x = pixmap_w - refresh_w; } else // Start translated left and increased in size on the right if(pixmap_w > this->pixmap_w && edit_x > this->edit_x) { refresh_x = 0; refresh_w = edit_x - this->edit_x; // Moved completely off new pixmap if(refresh_w > this->pixmap_w) { refresh_w = pixmap_w; refresh_x = 0; } // Shift and insert else { copy_area(0, y, this->pixmap_w, mwindow->edl->local_session->zoom_track, refresh_w, y); } } } // Update pixmap settings this->edit_id = edit->id; this->startsource = edit->startsource; this->source_framerate = edit->asset->frame_rate; this->source_samplerate = edit->asset->sample_rate; this->project_framerate = edit->edl->session->frame_rate; this->project_samplerate = edit->edl->session->sample_rate; this->edit_x = edit_x; this->pixmap_x = pixmap_x; this->pixmap_w = pixmap_w; this->pixmap_h = pixmap_h; this->zoom_sample = mwindow->edl->local_session->zoom_sample; this->zoom_track = mwindow->edl->local_session->zoom_track; this->zoom_y = mwindow->edl->local_session->zoom_y; // Draw in new background if(refresh_w > 0) mwindow->theme->draw_resource_bg(canvas, this, edit_x, edit_w, pixmap_x, refresh_x, y, refresh_x + refresh_w, mwindow->edl->local_session->zoom_track + y); //printf("ResourcePixmap::draw_data 70\n"); // Draw media if(track->draw) { switch(track->data_type) { case TRACK_AUDIO: draw_audio_resource(edit, refresh_x, refresh_w); break; case TRACK_VIDEO: draw_video_resource(edit, edit_x, edit_w, pixmap_x, pixmap_w, refresh_x, refresh_w, mode); break; } } // Draw title if(mwindow->edl->session->show_titles) draw_title(edit, edit_x, edit_w, pixmap_x, pixmap_w); }
/* * Display a dialog box for entering a date */ int dialog_calendar(const char *title, const char *subtitle, int height, int width, int day, int month, int year) { BOX dy_box, mn_box, yr_box; int fkey; int key = 0; int key2; int step; int button = 0; int result = DLG_EXIT_UNKNOWN; WINDOW *dialog; time_t now_time = time((time_t *) 0); struct tm current; STATES state = 0; const char **buttons = dlg_ok_labels(); char *prompt = strclone(subtitle); dlg_does_output(); now_time = time((time_t *) 0); current = *localtime(&now_time); if (day < 0) day = current.tm_mday; if (month < 0) month = current.tm_mon + 1; if (year < 0) year = current.tm_year + 1900; /* compute a struct tm that matches the day/month/year parameters */ if (((year -= 1900) > 0) && (year < 200)) { /* ugly, but I'd like to run this on older machines w/o mktime -TD */ for (;;) { if (year > current.tm_year) { now_time += ONE_DAY * days_in_year(¤t, 0); } else if (year < current.tm_year) { now_time -= ONE_DAY * days_in_year(¤t, -1); } else if (month > current.tm_mon + 1) { now_time += ONE_DAY * days_in_month(¤t, 0); } else if (month < current.tm_mon + 1) { now_time -= ONE_DAY * days_in_month(¤t, -1); } else if (day > current.tm_mday) { now_time += ONE_DAY; } else if (day < current.tm_mday) { now_time -= ONE_DAY; } else { break; } current = *localtime(&now_time); } } auto_size(title, prompt, &height, &width, 0, 0); height += MIN_HIGH; if (width < MIN_WIDE) width = MIN_WIDE; print_size(height, width); ctl_size(height, width); /* FIXME: how to make this resizable? */ dialog = new_window(height, width, box_y_ordinate(height), box_x_ordinate(width)); draw_box(dialog, 0, 0, height, width, dialog_attr, border_attr); draw_bottom_box(dialog); draw_title(dialog, title); wattrset(dialog, dialog_attr); print_autowrap(dialog, prompt, height, width); /* compute positions of day, month and year boxes */ memset(&dy_box, 0, sizeof(dy_box)); memset(&mn_box, 0, sizeof(mn_box)); memset(&yr_box, 0, sizeof(yr_box)); if (init_object(&dy_box, dialog, (width - DAY_WIDE) / 2, (height - (DAY_HIGH + BTN_HIGH + (4 * MARGIN))), DAY_WIDE, DAY_HIGH + (2 * MARGIN), draw_day, 'D') < 0 || DrawObject(&dy_box) < 0) return DLG_EXIT_ERROR; if (init_object(&mn_box, dialog, dy_box.x, dy_box.y - (HDR_HIGH + 2 * MARGIN), (DAY_WIDE / 2) - MARGIN, HDR_HIGH, draw_month, 'M') < 0 || DrawObject(&mn_box) < 0) return DLG_EXIT_ERROR; if (init_object(&yr_box, dialog, dy_box.x + mn_box.width + 2, mn_box.y, mn_box.width, mn_box.height, draw_year, 'Y') < 0 || DrawObject(&yr_box) < 0) return DLG_EXIT_ERROR; while (result == DLG_EXIT_UNKNOWN) { BOX *obj = (state == sDAY ? &dy_box : (state == sMONTH ? &mn_box : (state == sYEAR ? &yr_box : 0))); button = (state < 0) ? 0 : state; dlg_draw_buttons(dialog, height - 2, 0, buttons, button, FALSE, width); if (obj != 0) dlg_set_focus(dialog, obj->window); key = mouse_wgetch(dialog, &fkey); if ((key2 = dlg_char_to_button(key, buttons)) >= 0) { result = key2; } else { /* handle non-functionkeys */ if (!fkey) { fkey = TRUE; switch (key) { case ' ': case '\n': case '\r': key = KEY_ENTER; break; case TAB: key = KEY_RIGHT; break; case CHR_PREVIOUS: case CHR_NEXT: case CHR_BACKSPACE: case 'h': case 'j': case 'k': case 'l': /* treat these as function-keys */ break; case ESC: result = DLG_EXIT_ESC; fkey = FALSE; break; default: fkey = FALSE; break; } } /* handle functionkeys */ if (fkey) { switch (key) { case M_EVENT + 'D': state = sDAY; break; case M_EVENT + 'M': state = sMONTH; break; case M_EVENT + 'Y': state = sYEAR; break; case KEY_ENTER: result = dlg_ok_buttoncode(button); break; case KEY_LEFT: case KEY_BTAB: state = dlg_prev_ok_buttonindex(state, sMONTH); break; case KEY_RIGHT: state = dlg_next_ok_buttonindex(state, sMONTH); break; default: step = 0; key2 = -1; if (key >= M_EVENT) { if ((key2 = dlg_ok_buttoncode(key - M_EVENT)) >= 0) { result = key2; break; } else if (key >= (M_EVENT + KEY_MAX)) { state = sDAY; obj = &dy_box; key2 = 1; step = (key - (M_EVENT + KEY_MAX) - day_cell_number(¤t)); } } if (obj != 0) { if (key2 < 0) step = next_or_previous(key, (obj == &dy_box)); if (step != 0) { struct tm old = current; /* see comment regarding mktime -TD */ if (obj == &dy_box) { now_time += ONE_DAY * step; } else if (obj == &mn_box) { if (step > 0) now_time += ONE_DAY * days_in_month(¤t, 0); else now_time -= ONE_DAY * days_in_month(¤t, -1); } else if (obj == &yr_box) { if (step > 0) now_time += (ONE_DAY * days_in_year(¤t, 0)); else now_time -= (ONE_DAY * days_in_year(¤t, -1)); } current = *localtime(&now_time); if (obj != &dy_box && (current.tm_mday != old.tm_mday || current.tm_mon != old.tm_mon || current.tm_year != old.tm_year)) DrawObject(&dy_box); if (obj != &mn_box && current.tm_mon != old.tm_mon) DrawObject(&mn_box); if (obj != &yr_box && current.tm_year != old.tm_year) DrawObject(&yr_box); (void) DrawObject(obj); } } break; } } } } del_window(dialog); sprintf(dialog_vars.input_result, "%02d/%02d/%0d\n", current.tm_mday, current.tm_mon + 1, current.tm_year + 1900); mouse_free_regions(); free(prompt); return result; }
/* * Display a menu for choosing among a number of options */ int dialog_menu(const char *title, const char *cprompt, int height, int width, int menu_height, int item_no, const char **items) { int i, j, x, y, cur_x, cur_y, box_x, box_y; int key = 0; int button = 0; int choice = dlg_default_item(items, MENUBOX_TAGS); int scrollamt = 0; int max_choice, min_width; int found; int use_width, name_width, text_width; WINDOW *dialog, *menu; char *prompt = strclone(cprompt); const char **buttons = dlg_ok_labels(); tab_correct_str(prompt); if (menu_height == 0) { min_width = calc_listw(item_no, items, MENUBOX_TAGS) + 10; /* calculate height without items (4) */ auto_size(title, prompt, &height, &width, 4, MAX(26, min_width)); calc_listh(&height, &menu_height, item_no); } else { auto_size(title, prompt, &height, &width, 4 + menu_height, 26); } print_size(height, width); ctl_size(height, width); max_choice = MIN(menu_height, item_no); x = box_x_ordinate(width); y = box_y_ordinate(height); dialog = new_window(height, width, y, x); mouse_setbase(x, y); draw_box(dialog, 0, 0, height, width, dialog_attr, border_attr); draw_bottom_box(dialog); draw_title(dialog, title); wattrset(dialog, dialog_attr); print_autowrap(dialog, prompt, height, width); menu_width = width - 6; getyx(dialog, cur_y, cur_x); box_y = cur_y + 1; box_x = (width - menu_width) / 2 - 1; /* create new window for the menu */ menu = sub_window(dialog, menu_height, menu_width, y + box_y + 1, x + box_x + 1); /* draw a box around the menu items */ draw_box(dialog, box_y, box_x, menu_height + 2, menu_width + 2, menubox_border_attr, menubox_attr); name_width = 0; text_width = 0; /* Find length of longest item to center menu */ for (i = 0; i < item_no; i++) { name_width = MAX(name_width, (int) strlen(ItemName(i))); text_width = MAX(text_width, (int) strlen(ItemText(i))); } /* If the name+text is wider than the list is allowed, then truncate * one or both of them. If the name is no wider than 1/4 of the list, * leave it intact. */ use_width = (menu_width - 2); if (text_width + name_width > use_width) { int need = 0.25 * use_width; if (name_width > need) { int want = use_width * ((double) name_width) / (text_width + name_width); name_width = (want > need) ? want : need; } text_width = use_width - name_width; } tag_x = (use_width - text_width - name_width) / 2; item_x = name_width + tag_x + 2; if (choice - scrollamt >= max_choice) { scrollamt = choice - (max_choice - 1); choice = max_choice - 1; } /* Print the menu */ for (i = 0; i < max_choice; i++) print_item(menu, ItemData(i + scrollamt), i, i == choice); (void) wnoutrefresh(menu); /* register the new window, along with its borders */ mouse_mkbigregion(box_y, box_x, menu_height + 2, menu_width + 2, item_no, item_x, /* the threshold */ 1 /* dirty mode */ ); dlg_draw_arrows(dialog, scrollamt, scrollamt + max_choice < item_no, box_x + tag_x + 1, box_y, box_y + menu_height + 1); dlg_draw_buttons(dialog, height - 2, 0, buttons, button, FALSE, width); wtimeout(dialog, WTIMEOUT_VAL); while (key != ESC) { key = mouse_wgetch(dialog); /* Check if key pressed matches first character of any item tag in menu */ for (i = 0; i < max_choice; i++) if (toupper(key) == toupper(UCH(ItemName(scrollamt + i)[0]))) break; /* * Check if key pressed matches first character of any item tag in * list. If there is more than one match, we will cycle through * each one as the same key is pressed repeatedly. */ found = FALSE; for (j = scrollamt + choice + 1; j < item_no; j++) { if (toupper(key) == toupper(UCH(ItemName(j)[0]))) { found = TRUE; i = j - scrollamt; break; } } if (!found) { for (j = 0; j <= scrollamt + choice; j++) { if (toupper(key) == toupper(UCH(ItemName(j)[0]))) { found = TRUE; i = j - scrollamt; break; } } } /* * A single digit (1-9) positions the selection to that line in the * current screen. */ if (!found && (key <= '9') && (key > '0') && (key - '1' <= max_choice)) { found = TRUE; i = key - '1'; } if (!found) { found = TRUE; switch (key) { case KEY_HOME: i = -scrollamt; break; case KEY_LL: case KEY_END: i = item_no - 1 - scrollamt; break; case KEY_PPAGE: if (choice) i = 0; else if (scrollamt != 0) i = -MIN(scrollamt, max_choice); else continue; break; case KEY_NPAGE: i = MIN(choice + max_choice, item_no - scrollamt - 1); break; case KEY_UP: case '-': i = choice - 1; if (choice == 0 && scrollamt == 0) continue; break; case KEY_DOWN: case '+': i = choice + 1; if (scrollamt + choice >= item_no - 1) continue; break; default: found = FALSE; break; } } if (found) { if (i != choice) { getyx(dialog, cur_y, cur_x); if (i < 0 || i >= max_choice) { #if defined(NCURSES_VERSION_MAJOR) && NCURSES_VERSION_MAJOR < 5 /* * Using wscrl to assist ncurses scrolling is not needed * in version 5.x */ if (i == -1) { if (menu_height > 1) { /* De-highlight current first item */ print_item(menu, ItemData(scrollamt), 0, FALSE); scrollok(menu, TRUE); wscrl(menu, -1); scrollok(menu, FALSE); } scrollamt--; print_item(menu, ItemData(scrollamt), 0, TRUE); } else if (i == max_choice) { if (menu_height > 1) { /* De-highlight current last item before scrolling up */ print_item(menu, ItemData(scrollamt + max_choice - 1), max_choice - 1, FALSE); scrollok(menu, TRUE); wscrl(menu, 1); scrollok(menu, FALSE); } scrollamt++; print_item(menu, ItemData(scrollamt + max_choice - 1), max_choice - 1, TRUE); } else #endif { if (i < 0) { scrollamt += i; choice = 0; } else { choice = max_choice - 1; scrollamt += (i - max_choice + 1); } for (i = 0; i < max_choice; i++) { print_item(menu, ItemData(scrollamt + i), i, i == choice); } } (void) wnoutrefresh(menu); dlg_draw_arrows(dialog, scrollamt, scrollamt + choice < item_no - 1, box_x + tag_x + 1, box_y, box_y + menu_height + 1); } else { /* De-highlight current item */ print_item(menu, ItemData(scrollamt + choice), choice, FALSE); /* Highlight new item */ choice = i; print_item(menu, ItemData(scrollamt + choice), choice, TRUE); (void) wnoutrefresh(menu); (void) wmove(dialog, cur_y, cur_x); wrefresh(dialog); } } continue; /* wait for another key press */ } switch (key) { case M_EVENT + 'O': del_window(dialog); return scrollamt + choice; case M_EVENT + 'C': del_window(dialog); return -2; case M_EVENT + 'o': /* mouse enter... */ case M_EVENT + 'c': /* use the code for toggling */ button = (key == M_EVENT + 'o'); /* FALLTHRU */ case ' ': case KEY_BTAB: case TAB: case KEY_LEFT: case KEY_RIGHT: if (!dialog_vars.nocancel) button = !button; dlg_draw_buttons(dialog, height - 2, 0, buttons, button, FALSE, width); break; case '\n': del_window(dialog); return (button ? -2 : (scrollamt + choice)); } } del_window(dialog); return -1; /* ESC pressed */ }
void list_draw(struct screen *display, struct gui_synclist *list) { struct viewport list_icons; int start, end, line_height, style, i; const int screen = display->screen_type; const int list_start_item = list->start_item[screen]; const int icon_width = get_icon_width(screen) + ICON_PADDING; const bool scrollbar_in_left = (global_settings.scrollbar == SCROLLBAR_LEFT); const bool show_cursor = !global_settings.cursor_style && list->show_selection_marker; struct viewport *parent = (list->parent[screen]); #ifdef HAVE_LCD_COLOR unsigned char cur_line = 0; #endif int item_offset; bool show_title; struct viewport *list_text_vp = &list_text[screen]; line_height = font_get(parent->font)->height; display->set_viewport(parent); display->clear_viewport(); display->scroll_stop(list_text_vp); *list_text_vp = *parent; if ((show_title = draw_title(display, list))) { list_text_vp->y += line_height; list_text_vp->height -= line_height; } const int nb_lines = viewport_get_nb_lines(list_text_vp); start = list_start_item; end = start + nb_lines; #ifdef HAVE_TOUCHSCREEN if (list->selected_item == 0 || (list->nb_items < nb_lines)) y_offset = 0; /* reset in case it's a new list */ int draw_offset = y_offset; /* draw some extra items to not have empty lines at the top and bottom */ if (y_offset > 0) { /* make it negative for more consistent apparence when switching * directions */ draw_offset -= line_height; if (start > 0) start--; } else if (y_offset < 0) end++; #else #define draw_offset 0 #endif /* draw the scrollbar if its needed */ if (global_settings.scrollbar && nb_lines < list->nb_items) { struct viewport vp = *list_text_vp; vp.width = SCROLLBAR_WIDTH; vp.height = line_height * nb_lines; vp.x = parent->x; list_text_vp->width -= SCROLLBAR_WIDTH; if (scrollbar_in_left) list_text_vp->x += SCROLLBAR_WIDTH; else vp.x += list_text_vp->width; display->set_viewport(&vp); gui_scrollbar_draw(display, (scrollbar_in_left? 0: 1), 0, SCROLLBAR_WIDTH-1, vp.height, list->nb_items, list_start_item, list_start_item + nb_lines, VERTICAL); } else if (show_title) { /* shift everything a bit in relation to the title... */ if (!VP_IS_RTL(list_text_vp) && scrollbar_in_left) { list_text_vp->width -= SCROLLBAR_WIDTH; list_text_vp->x += SCROLLBAR_WIDTH; } else if (VP_IS_RTL(list_text_vp) && !scrollbar_in_left) { list_text_vp->width -= SCROLLBAR_WIDTH; } } /* setup icon placement */ list_icons = *list_text_vp; int icon_count = (list->callback_get_item_icon != NULL) ? 1 : 0; if (show_cursor) icon_count++; if (icon_count) { list_icons.width = icon_width * icon_count; list_text_vp->width -= list_icons.width + ICON_PADDING; if (VP_IS_RTL(&list_icons)) list_icons.x += list_text_vp->width + ICON_PADDING; else list_text_vp->x += list_icons.width + ICON_PADDING; } for (i=start; i<end && i<list->nb_items; i++) { /* do the text */ unsigned const char *s; char entry_buffer[MAX_PATH]; unsigned char *entry_name; int text_pos = 0; int line = i - start; s = list->callback_get_item_name(i, list->data, entry_buffer, sizeof(entry_buffer)); entry_name = P2STR(s); display->set_viewport(list_text_vp); style = STYLE_DEFAULT; /* position the string at the correct offset place */ int item_width,h; display->getstringsize(entry_name, &item_width, &h); item_offset = gui_list_get_item_offset(list, item_width, text_pos, display, list_text_vp); #ifdef HAVE_LCD_COLOR /* if the list has a color callback */ if (list->callback_get_item_color) { int color = list->callback_get_item_color(i, list->data); /* if color selected */ if (color >= 0) { style |= STYLE_COLORED|color; } } #endif /* draw the selected line */ if( #ifdef HAVE_TOUCHSCREEN /* don't draw it during scrolling */ scroll_mode == SCROLL_NONE && #endif i >= list->selected_item && i < list->selected_item + list->selected_size && list->show_selection_marker) {/* The selected item must be displayed scrolling */ if (global_settings.cursor_style == 1 #ifdef HAVE_REMOTE_LCD /* the global_settings.cursor_style check is here to make * sure if they want the cursor instead of bar it will work */ || (display->depth < 16 && global_settings.cursor_style) #endif ) { /* Display inverted-line-style */ style = STYLE_INVERT; } #ifdef HAVE_LCD_COLOR else if (global_settings.cursor_style == 2) { /* Display colour line selector */ style = STYLE_COLORBAR; } else if (global_settings.cursor_style == 3) { /* Display gradient line selector */ style = STYLE_GRADIENT; /* Make the lcd driver know how many lines the gradient should cover and current line number */ /* number of selected lines */ style |= NUMLN_PACK(list->selected_size); /* current line number, zero based */ style |= CURLN_PACK(cur_line); cur_line++; } #endif /* if the text is smaller than the viewport size */ if (item_offset> item_width - (list_text_vp->width - text_pos)) { /* don't scroll */ display->puts_style_xyoffset(0, line, entry_name, style, item_offset, draw_offset); } else { display->puts_scroll_style_xyoffset(0, line, entry_name, style, item_offset, draw_offset); } } else { if (list->scroll_all) display->puts_scroll_style_xyoffset(0, line, entry_name, style, item_offset, draw_offset); else display->puts_style_xyoffset(0, line, entry_name, style, item_offset, draw_offset); } /* do the icon */ display->set_viewport(&list_icons); if (list->callback_get_item_icon != NULL) { screen_put_icon_with_offset(display, show_cursor?1:0, (line),show_cursor?ICON_PADDING:0,draw_offset, list->callback_get_item_icon(i, list->data)); } if (show_cursor && i >= list->selected_item && i < list->selected_item + list->selected_size) { screen_put_icon_with_offset(display, 0, line, 0, draw_offset, Icon_Cursor); } } display->set_viewport(parent); display->update_viewport(); display->set_viewport(NULL); }
/* * Display a gauge, or progress meter. Starts at percent% and reads stdin. If * stdin is not XXX, then it is interpreted as a percentage, and the display is * updated accordingly. Otherwise the next line is the percentage, and * subsequent lines up to another XXX are used for the new prompt. Note that * the size of the window never changes, so the prompt can not get any larger * than the height and width specified. */ int dialog_gauge(const char *title, const char *prompt, int height, int width, int percent) { int i, x, y; char buf[MY_LEN]; char prompt_buf[MY_LEN]; WINDOW *dialog; auto_size(title, prompt, &height, &width, MIN_HIGH, MIN_WIDE); print_size(height, width); ctl_size(height, width); /* center dialog box on screen */ x = box_x_ordinate(width); y = box_y_ordinate(height); dialog = new_window(height, width, y, x); curs_set(0); do { (void) werase(dialog); draw_box(dialog, 0, 0, height, width, dialog_attr, border_attr); draw_title(dialog, title); wattrset(dialog, dialog_attr); print_autowrap(dialog, prompt, height, width - (2 * MARGIN)); draw_box(dialog, height - 4, 2 + MARGIN, 2 + MARGIN, width - 2 * (2 + MARGIN), dialog_attr, border_attr); (void) wmove(dialog, height - 3, 4); wattrset(dialog, title_attr); for (i = 0; i < (width - 2 * (3 + MARGIN)); i++) (void) waddch(dialog, ' '); wattrset(dialog, title_attr); (void) wmove(dialog, height - 3, (width / 2) - 2); (void) wprintw(dialog, "%3d%%", percent); x = (percent * (width - 2 * (3 + MARGIN))) / 100; wattrset(dialog, A_REVERSE); (void) wmove(dialog, height - 3, 4); for (i = 0; i < x; i++) (void) waddch(dialog, winch(dialog)); (void) wrefresh(dialog); if (read_data(buf, pipe_fp) == 0) break; if (isMarker(buf)) { /* * Historically, next line should be percentage, but one of the * worse-written clones of 'dialog' assumes the number is missing. * (Gresham's Law applied to software). */ if (read_data(buf, pipe_fp) == 0) break; prompt_buf[0] = '\0'; if (decode_percent(buf)) percent = atoi(buf); else strcpy(prompt_buf, buf); /* Rest is message text */ while (read_data(buf, pipe_fp) != 0 && !isMarker(buf)) { if (strlen(prompt_buf) + strlen(buf) < sizeof(prompt_buf) - 1) { strcat(prompt_buf, buf); } } prompt = prompt_buf; } else if (decode_percent(buf)) { percent = atoi(buf); } } while (1); curs_set(1); del_window(dialog); return (DLG_EXIT_OK); }
void do_menu(void){ if(show_menu){ //regular xmc mode //xmc #define pos_x 0.25 #define start_y 0.14 INIT_FRONTEND_HELPER_TEXT(); DRAW_FRONTEND_HELPER_TEXT("LEAVE", "INPUT_F_CANCEL", 0); DRAW_FRONTEND_HELPER_TEXT("CONFIRM", "INPUT_F_ACCEPT", 0); DRAW_FRONTEND_HELPER_TEXT("SCROLL", "PAD_DPAD_UPDOWN", 0); if(!xmc_compact){ HIDE_HELP_TEXT_THIS_FRAME(); pos_y = start_y; if(xmc_dim) DRAW_RECT(0.5000, 0.5000, 1.0000, 1.0000, 0, 0, 0, 110); //draw_title(0.5,0.05,0.6,0.98,s_r,s_g,s_b,255,MENU_TITLE); draw_title(0.5,0.05,0.6,0.98,s_r,s_g,s_b,255,footer); draw_title(0.5,0.109,0.4,0.50,s_r,s_g,s_b,255,MENU_AUTHOR); set_up_draw(3,0.35,0.35,255,255,255,255); //draw_text("STRING",0.05,0.975,footer); uint i = 1; for(i;i <= item_count;i++){ r = 255; g = 255; b = 255; a = 255; pos_y = pos_y + 0.0375; if(item_select == i){ r = s_r; g = s_g; b = s_b; } if(menu[i].type == 1){ if(menu[i].value){ set_up_draw(3,0.35,0.35,s_r,s_g,s_b,a); draw_text("STRING",(pos_x + 0.3),pos_y,"On"); } else{ set_up_draw(3,0.35,0.35,255,255,255,a); draw_text("STRING",(pos_x + 0.3),pos_y,"Off"); } } if(menu[i].type == 2){ set_up_draw(3,0.35,0.35,s_r,s_g,s_b,a); draw_text("STRING",(pos_x + 0.3),pos_y,"("); set_up_draw(3,0.35,0.35,255,255,255,a); draw_number("NUMBR",(pos_x + 0.305),pos_y,menu[i].value); set_up_draw(3,0.35,0.35,s_r,s_g,s_b,a); if(menu[i].value > 99) draw_text("STRING",(pos_x + 0.345),pos_y,")"); else if(menu[i].value > 9) draw_text("STRING",(pos_x + 0.33),pos_y,")"); else draw_text("STRING",(pos_x + 0.315),pos_y,")"); } if(menu[i].type == 3){ set_up_draw(3,0.35,0.35,r,g,b,a); draw_text("STRING",pos_x,pos_y,GET_STRING_FROM_TEXT_FILE(GET_DISPLAY_NAME_FROM_VEHICLE_MODEL(menu[i].value))); } if(menu[i].type == 4){ if(item_select == i){ r = s_r; g = s_g; b = s_b; } else GET_PLAYER_RGB_COLOUR(menu[i].value,&r,&g,&b); set_up_draw(3,0.35,0.35,r,g,b,a); draw_text("STRING", pos_x, pos_y, menu[i].item_name); } if(menu[i].type == 5){ if(!COMPARE_STRING(menu[i].item_name, "")){ set_up_draw(3,0.35,0.35,s_r,s_g,s_b,a); draw_text("STRING", pos_x - 0.08, pos_y, "Admin"); } if(item_select == i){ r = s_r; g = s_g; b = s_b; } else if(xmc_online_col) GET_PLAYER_RGB_COLOUR(menu[i].value,&r,&g,&b); set_up_draw(3,0.35,0.35,r,g,b,a); draw_text("STRING", pos_x, pos_y, menu[i].item_name); } else{ set_up_draw(3,0.35,0.35,r,g,b,a); draw_text("STRING",pos_x,pos_y,menu[i].item_name); } } ///Buttons if(IS_BUTTON_JUST_PRESSED(0,DPAD_UP)){ if(item_select == 1){ item_select = item_count; } else item_select--; } else if(IS_BUTTON_JUST_PRESSED(0,DPAD_DOWN)){ if(item_select == item_count){ item_select = 1; } else item_select++; } else if(IS_BUTTON_JUST_PRESSED(0,DPAD_RIGHT) && menu[item_select].type == 2){ if(menu[item_select].value == menu[item_select].maxval) menu[item_select].value = 1; else menu[item_select].value += 1; } else if(IS_BUTTON_JUST_PRESSED(0,DPAD_LEFT) && menu[item_select].type == 2){ if(menu[item_select].value == 1) menu[item_select].value = menu[item_select].maxval; else menu[item_select].value -= 1; } else if(IS_BUTTON_JUST_PRESSED(0,BUTTON_A)){ if(menu[item_select].action){ menu_functions(); } else{ uint i = 1; for(i;i <= item_count;i++){ menu[i].action = false; menu[i].type = 0; } last_selected[menu_level] = item_select; menu_level++; menu_setup(); item_select = 1; } } else if(IS_BUTTON_JUST_PRESSED(0,BUTTON_B)){ if(menu_level > 0){ uint i = 1; for(i;i <= item_count;i++){ menu[i].action = false; menu[i].type = 0; } menu_level--; item_select = last_selected[menu_level]; menu_setup(); } else menu_shutdown(); } } else{ #define pos_x 0.60 #define start_y 0.25 #define spacing 0.025 pos_y = start_y; drawWindow(); s_a = 255; set_up_draw(4,0.35,0.35,s_r,s_g,s_b,255); draw_text("STRING",pos_x,start_y-.02,footer); uint i = 1; for(i;i <= item_count;i++){ r = 255;g = 255;b = 255;a = 255; pos_y = pos_y + spacing; if(item_select == i){ r = s_r; g = s_g; b = s_b; } if(menu[i].type == 1){ if(menu[i].value){ set_up_draw(3,0.35,0.35,s_r,s_g,s_b,a); draw_text("STRING",(pos_x + 0.265),pos_y,"On"); } } if(menu[i].type == 2){ set_up_draw(3,0.35,0.35,s_r,s_g,s_b,a); draw_text("STRING",(pos_x + 0.19),pos_y,"("); set_up_draw(3,0.35,0.35,255,255,255,a); draw_number("NUMBR",(pos_x + 0.205),pos_y,menu[i].value); set_up_draw(3,0.35,0.35,s_r,s_g,s_b,a); if(menu[i].value > 99) draw_text("STRING",(pos_x + 0.245),pos_y,")"); else if(menu[i].value > 9) draw_text("STRING",(pos_x + 0.23),pos_y,")"); else draw_text("STRING",(pos_x + 0.215),pos_y,")"); } if(menu[i].type == 3){ set_up_draw(3,0.35,0.35,r,g,b,a); draw_text("STRING",pos_x,pos_y,GET_STRING_FROM_TEXT_FILE(GET_DISPLAY_NAME_FROM_VEHICLE_MODEL(menu[i].value))); } if(menu[i].type == 4){ if(item_select == i){ r = s_r; g = s_g; b = s_b; } else GET_PLAYER_RGB_COLOUR(menu[i].value,&r,&g,&b); set_up_draw(3,0.35,0.35,r,g,b,a); draw_text("STRING", pos_x, pos_y, menu[i].item_name); } else{ set_up_draw(3,0.35,0.35,r,g,b,a); draw_text("STRING",pos_x,pos_y,menu[i].item_name); } } ///Buttons if(IS_BUTTON_JUST_PRESSED(0,DPAD_UP)){ if(item_select == 1){ item_select = item_count; } else item_select--; } else if(IS_BUTTON_JUST_PRESSED(0,DPAD_DOWN)){ if(item_select == item_count){ item_select = 1; } else item_select++; } else if(IS_BUTTON_JUST_PRESSED(0,DPAD_RIGHT) && menu[item_select].type == 2){ if(menu[item_select].value == menu[item_select].maxval) menu[item_select].value = 1; else menu[item_select].value += 1; } else if(IS_BUTTON_JUST_PRESSED(0,DPAD_LEFT) && menu[item_select].type == 2){ if(menu[item_select].value == 1) menu[item_select].value = menu[item_select].maxval; else menu[item_select].value -= 1; } else if(IS_BUTTON_JUST_PRESSED(0,BUTTON_A)){ if(menu[item_select].action){ menu_functions(); } else{ uint i = 1; for(i;i <= item_count;i++){ menu[i].action = false; menu[i].type = 0; } last_selected[menu_level] = item_select; menu_level++; menu_setup(); item_select = 1; } } else if(IS_BUTTON_JUST_PRESSED(0,BUTTON_B)){ if(menu_level > 0){ uint i = 1; for(i;i <= item_count;i++){ menu[i].action = false; menu[i].type = 0; } menu_level--; item_select = last_selected[menu_level]; menu_setup(); } else menu_shutdown(); } } } else if(!xmc_switch && IS_BUTTON_PRESSED(0,BUTTON_LB) && IS_BUTTON_JUST_PRESSED(0,BUTTON_RB)) menu_startup(); else if(xmc_switch && IS_BUTTON_PRESSED(0,BUTTON_RB) && IS_BUTTON_JUST_PRESSED(0,BUTTON_LB)) menu_startup(); }
/* * Display a dialog box with a list of options that can be turned on or off * The `flag' parameter is used to select between radiolist and checklist. */ int dialog_checklist(const char *title, const char *cprompt, int height, int width, int list_height, int item_no, char **items, int flag, int separate_output) { int i, j, key2, found, x, y, cur_x, cur_y, box_x, box_y; int key = 0, fkey; int button = 0; int choice = 0; int scrollamt = 0; int max_choice, *status; int use_width, name_width, text_width; int result = DLG_EXIT_UNKNOWN; WINDOW *dialog, *list; char *prompt = strclone(cprompt); const char **buttons = dlg_ok_labels(); tab_correct_str(prompt); if (list_height == 0) { use_width = calc_listw(item_no, items, CHECKBOX_TAGS) + 10; /* calculate height without items (4) */ auto_size(title, prompt, &height, &width, 4, MAX(26, use_width)); calc_listh(&height, &list_height, item_no); } else { auto_size(title, prompt, &height, &width, 4 + list_height, 26); } print_size(height, width); ctl_size(height, width); checkflag = flag; /* Allocate space for storing item on/off status */ status = malloc(sizeof(int) * item_no); assert_ptr(status, "dialog_checklist"); /* Initializes status */ for (i = 0; i < item_no; i++) status[i] = !dlg_strcmp(ItemStatus(i), "on"); max_choice = MIN(list_height, item_no); x = box_x_ordinate(width); y = box_y_ordinate(height); dialog = new_window(height, width, y, x); mouse_setbase(x, y); draw_box(dialog, 0, 0, height, width, dialog_attr, border_attr); draw_bottom_box(dialog); draw_title(dialog, title); wattrset(dialog, dialog_attr); print_autowrap(dialog, prompt, height, width); list_width = width - 6; getyx(dialog, cur_y, cur_x); box_y = cur_y + 1; box_x = (width - list_width) / 2 - 1; /* create new window for the list */ list = sub_window(dialog, list_height, list_width, y + box_y + 1, x + box_x + 1); /* draw a box around the list items */ draw_box(dialog, box_y, box_x, list_height + 2 * MARGIN, list_width + 2 * MARGIN, menubox_border_attr, menubox_attr); text_width = 0; name_width = 0; /* Find length of longest item to center checklist */ for (i = 0; i < item_no; i++) { text_width = MAX(text_width, (int) strlen(ItemText(i))); name_width = MAX(name_width, (int) strlen(ItemName(i))); } /* If the name+text is wider than the list is allowed, then truncate * one or both of them. If the name is no wider than 1/4 of the list, * leave it intact. */ use_width = (list_width - 6); if (text_width + name_width > use_width) { int need = 0.25 * use_width; if (name_width > need) { int want = use_width * ((double) name_width) / (text_width + name_width); name_width = (want > need) ? want : need; } text_width = use_width - name_width; } check_x = (use_width - (text_width + name_width)) / 2; item_x = name_width + check_x + 6; /* Print the list */ for (i = 0; i < max_choice; i++) print_item(list, ItemData(i), status[i], i, i == choice); (void) wnoutrefresh(list); /* register the new window, along with its borders */ mouse_mkbigregion(box_y + 1, box_x, list_height, list_width + 2, KEY_MAX, 1, 1, 1 /* by lines */ ); dlg_draw_arrows(dialog, scrollamt, scrollamt + max_choice < item_no - 1, box_x + check_x + 5, box_y, box_y + list_height + 1); dlg_draw_buttons(dialog, height - 2, 0, buttons, 0, FALSE, width); wtimeout(dialog, WTIMEOUT_VAL); while (result == DLG_EXIT_UNKNOWN) { key = mouse_wgetch(dialog, &fkey); if (fkey && (key >= (M_EVENT + KEY_MAX))) { getyx(dialog, cur_y, cur_x); /* De-highlight current item */ print_item(list, ItemData(scrollamt + choice), status[scrollamt + choice], choice, FALSE); /* Highlight new item */ choice = (key - (M_EVENT + KEY_MAX)); print_item(list, ItemData(scrollamt + choice), status[scrollamt + choice], choice, TRUE); (void) wnoutrefresh(list); (void) wmove(dialog, cur_y, cur_x); key = ' '; /* force the selected item to toggle */ fkey = FALSE; } /* * A space toggles the item status. We handle either a checklist * (any number of items can be selected) or radio list (zero or one * items can be selected). */ if (key == ' ') { getyx(dialog, cur_y, cur_x); if (flag == FLAG_CHECK) { /* checklist? */ status[scrollamt + choice] = !status[scrollamt + choice]; print_item(list, ItemData(scrollamt + choice), status[scrollamt + choice], choice, TRUE); } else { /* radiolist */ if (!status[scrollamt + choice]) { for (i = 0; i < item_no; i++) status[i] = FALSE; status[scrollamt + choice] = TRUE; for (i = 0; i < max_choice; i++) print_item(list, ItemData(scrollamt + i), status[scrollamt + i], i, i == choice); } } (void) wnoutrefresh(list); (void) wmove(dialog, cur_y, cur_x); wrefresh(dialog); continue; /* wait for another key press */ } else if (key == ESC) { result = DLG_EXIT_ESC; continue; } if (!fkey) { fkey = TRUE; switch (key) { case '\n': case '\r': key = KEY_ENTER; break; case '-': key = KEY_UP; break; case '+': key = KEY_DOWN; break; case TAB: key = KEY_RIGHT; break; default: fkey = FALSE; break; } } /* * Check if key pressed matches first character of any item tag in * list. If there is more than one match, we will cycle through * each one as the same key is pressed repeatedly. */ found = FALSE; if (!fkey) { for (j = scrollamt + choice + 1; j < item_no; j++) { if (dlg_match_char(dlg_last_getc(), ItemName(j))) { found = TRUE; i = j - scrollamt; break; } } if (!found) { for (j = 0; j <= scrollamt + choice; j++) { if (dlg_match_char(dlg_last_getc(), ItemName(j))) { found = TRUE; i = j - scrollamt; break; } } } if (found) dlg_flush_getc(); } /* * A single digit (1-9) positions the selection to that line in the * current screen. */ if (!found && (key <= '9') && (key > '0') && (key - '1' < max_choice)) { found = TRUE; i = key - '1'; } if (!found) { if (fkey) { found = TRUE; switch (key) { case KEY_HOME: i = -scrollamt; break; case KEY_LL: case KEY_END: i = item_no - 1 - scrollamt; break; case M_EVENT + KEY_PPAGE: case KEY_PPAGE: if (choice) i = 0; else if (scrollamt != 0) i = -MIN(scrollamt, max_choice); else continue; break; case M_EVENT + KEY_NPAGE: case KEY_NPAGE: i = MIN(choice + max_choice, item_no - scrollamt - 1); break; case KEY_UP: i = choice - 1; if (choice == 0 && scrollamt == 0) continue; break; case KEY_DOWN: i = choice + 1; if (scrollamt + choice >= item_no - 1) continue; break; default: found = FALSE; break; } } } if (found) { if (i != choice) { getyx(dialog, cur_y, cur_x); if (i < 0 || i >= max_choice) { #if defined(NCURSES_VERSION_MAJOR) && NCURSES_VERSION_MAJOR < 5 /* * Using wscrl to assist ncurses scrolling is not needed * in version 5.x */ if (i == -1) { if (list_height > 1) { /* De-highlight current first item */ print_item(list, ItemData(scrollamt), status[scrollamt], 0, FALSE); scrollok(list, TRUE); wscrl(list, -1); scrollok(list, FALSE); } scrollamt--; print_item(list, ItemData(scrollamt), status[scrollamt], 0, TRUE); } else if (i == max_choice) { if (list_height > 1) { /* De-highlight current last item before scrolling up */ print_item(list, ItemData(scrollamt + max_choice - 1), status[scrollamt + max_choice - 1], max_choice - 1, FALSE); scrollok(list, TRUE); wscrl(list, 1); scrollok(list, FALSE); } scrollamt++; print_item(list, ItemData(scrollamt + max_choice - 1), status[scrollamt + max_choice - 1], max_choice - 1, TRUE); } else #endif { if (i < 0) { scrollamt += i; choice = 0; } else { choice = max_choice - 1; scrollamt += (i - max_choice + 1); } for (i = 0; i < max_choice; i++) { print_item(list, ItemData(scrollamt + i), status[scrollamt + i], i, i == choice); } } (void) wnoutrefresh(list); dlg_draw_arrows(dialog, scrollamt, scrollamt + choice < item_no - 1, box_x + check_x + 5, box_y, box_y + list_height + 1); } else { /* De-highlight current item */ print_item(list, ItemData(scrollamt + choice), status[scrollamt + choice], choice, FALSE); /* Highlight new item */ choice = i; print_item(list, ItemData(scrollamt + choice), status[scrollamt + choice], choice, TRUE); (void) wnoutrefresh(list); (void) wmove(dialog, cur_y, cur_x); wrefresh(dialog); } } continue; /* wait for another key press */ } if (fkey) { switch (key) { case KEY_ENTER: result = dlg_ok_buttoncode(button); break; case KEY_BTAB: case KEY_LEFT: button = dlg_prev_button(buttons, button); dlg_draw_buttons(dialog, height - 2, 0, buttons, button, FALSE, width); break; case KEY_RIGHT: button = dlg_next_button(buttons, button); dlg_draw_buttons(dialog, height - 2, 0, buttons, button, FALSE, width); break; default: if (key >= M_EVENT) { if ((key2 = dlg_ok_buttoncode(key - M_EVENT)) >= 0) { result = key2; break; } beep(); } } } else { beep(); } } del_window(dialog); switch (result) { case DLG_EXIT_OK: /* FALLTHRU */ case DLG_EXIT_EXTRA: for (i = 0; i < item_no; i++) { if (status[i]) { if (flag == FLAG_CHECK) { if (separate_output) { dlg_add_result(ItemName(i)); dlg_add_result("\n"); } else { dlg_add_result("\""); dlg_add_result(ItemName(i)); dlg_add_result("\" "); } } else { dlg_add_result(ItemName(i)); } } } break; case DLG_EXIT_HELP: dlg_add_result("HELP "); if (USE_ITEM_HELP(ItemHelp(scrollamt + choice))) { dlg_add_result(ItemHelp(scrollamt + choice)); result = DLG_EXIT_OK; /* this is inconsistent */ } else { dlg_add_result(ItemName(scrollamt + choice)); } break; } mouse_free_regions(); free(status); free(prompt); return result; }
void screen_model (ESContext *esContext) { #ifndef SDLGL ESMatrix modelview; UserData *userData = esContext->userData; #endif draw_title(esContext, "Model"); char tmp_str[100]; int n = 0; #ifndef SDLGL esMatrixLoadIdentity(&modelview); esMatrixMultiply(&userData->mvpMatrix, &modelview, &userData->perspective); esMatrixMultiply(&userData->mvpMatrix2, &modelview, &userData->perspective); #endif if (clientmode == 1) { draw_text_button(esContext, "clientmode", VIEW_MODE_MODEL, "Client-Mode / No Config", FONT_PINK, 0.0, 0.0, 0.002, 0.1, ALIGN_CENTER, ALIGN_TOP, model_null, (float)n); return; } if (select_teletype == 1) { for (n = 0; n < TELETYPE_LAST; n++) { draw_text_button(esContext, teletypes[n], VIEW_MODE_MODEL, teletypes[n], FONT_WHITE, -1.25, -0.8 + n * 0.12, 0.002, 0.06, ALIGN_LEFT, ALIGN_TOP, model_teletype_set, (float)n); } return; } draw_text_button(esContext, "Model", VIEW_MODE_MODEL, "Model", FONT_WHITE, -1.25, -0.8 + n * 0.12, 0.002, 0.06, ALIGN_LEFT, ALIGN_TOP, model_null, (float)n); draw_line_f3(esContext, -1.3, -0.8 + n * 0.12 + 0.1, 0.002, 1.25, -0.8 + n * 0.12 + 0.1, 0.002, 255, 255, 0, 128); n++; draw_text_button(esContext, "model_load", VIEW_MODE_MODEL, "[LOAD]", FONT_WHITE, 1.1, -0.8 + n * 0.12, 0.002, 0.06, ALIGN_RIGHT, ALIGN_TOP, model_load, 0); draw_text_button(esContext, "model_load2", VIEW_MODE_MODEL, "NAME:", FONT_WHITE, -1.1, -0.8 + n * 0.12, 0.002, 0.06, ALIGN_LEFT, ALIGN_TOP, model_name_edit, 0); if (ModelData[ModelActive].name[0] == 0) { strcpy(ModelData[ModelActive].name, "model1"); } sprintf(tmp_str, "%s", ModelData[ModelActive].name); draw_text_button(esContext, "model_name_edit", VIEW_MODE_MODEL, tmp_str, FONT_WHITE, -1.1 + 0.3, -0.8 + n * 0.12, 0.002, 0.06, ALIGN_LEFT, ALIGN_TOP, model_name_edit, 0); n++; draw_text_button(esContext, "model_type", VIEW_MODE_MODEL, "TYPE:", FONT_WHITE, -1.1, -0.8 + n * 0.12, 0.002, 0.06, ALIGN_LEFT, ALIGN_TOP, model_dronetype_change, 0); if (ModelData[ModelActive].dronetype > 26) { sprintf(tmp_str, "UNKNOWN: %i", ModelData[ModelActive].dronetype); draw_text_button(esContext, "dronetype_change", VIEW_MODE_MODEL, tmp_str, FONT_WHITE, -1.1 + 0.3, -0.8 + n * 0.12, 0.002, 0.06, ALIGN_LEFT, ALIGN_TOP, model_dronetype_change, 0); } else { draw_text_button(esContext, "dronetype_change", VIEW_MODE_MODEL, dronetypes[ModelData[ModelActive].dronetype], FONT_WHITE, -1.1 + 0.3, -0.8 + n * 0.12, 0.002, 0.06, ALIGN_LEFT, ALIGN_TOP, model_dronetype_change, 0); } #ifdef SDLGL // get_background_model(ModelActive, tmp_str); if (ModelData[ModelActive].dronetype > 26) { sprintf(tmp_str, "%s/obj3d/_.obj", BASE_DIR); } else { sprintf(tmp_str, "%s/obj3d/%s.obj", BASE_DIR, dronetypes[ModelData[ModelActive].dronetype]); } if (file_exists(tmp_str) != 0) { static uint8_t startup = 0; static float rotate = 0.0; rotate += 0.5; if (startup == 0 || strcmp(obj3d_dronetype.name, tmp_str) != 0) { startup = 1; if (obj3d_dronetype.faces_num != 0) { object3d_free(&obj3d_dronetype); } object3d_load(&obj3d_dronetype, tmp_str); } glPushMatrix(); glTranslatef(0.5, (-0.8 + n * 0.12 + 0.2) * -1.0, -2.0); if (ModelData[ModelActive].heartbeat == 0) { glRotatef(rotate, 0.2, 1.0, 0.3); } else { glRotatef(-90.0, 1.0, 0.0, 0.0); // glRotatef(ModelData[ModelActive].yaw, 0.0, 0.0, -1.0); glRotatef(ModelData[ModelActive].pitch, 1.0, 0.0, 0.0); glRotatef(ModelData[ModelActive].roll, 0.0, 1.0, 0.0); } glScalef(0.25, 0.25, 0.25); object3d_draw(&obj3d_dronetype, 255, 255, 255, 100); glPopMatrix(); } else { sprintf(tmp_str, "%s/textures/%s.png", BASE_DIR, dronetypes[ModelData[ModelActive].dronetype]); draw_image_f3(esContext, -1.1 + 1.0, -0.8 + n * 0.12 - 0.02, -1.1 + 1.0 + 0.1, -0.8 + n * 0.12 + 0.1 - 0.02, 0.002, tmp_str); } #else sprintf(tmp_str, "%s/textures/%s.png", BASE_DIR, dronetypes[ModelData[ModelActive].dronetype]); draw_image_f3(esContext, -1.1 + 1.0, -0.8 + n * 0.12 - 0.02, -1.1 + 1.0 + 0.1, -0.8 + n * 0.12 + 0.1 - 0.02, 0.002, tmp_str); #endif n++; draw_text_button(esContext, "model_image_change", VIEW_MODE_MODEL, "IMAGE:", FONT_WHITE, -1.1, -0.8 + n * 0.12, 0.002, 0.06, ALIGN_LEFT, ALIGN_TOP, model_image_change, 0); draw_image_f3(esContext, -1.1 + 0.3, -0.8 + n * 0.12 - 0.02, -1.2 + 0.3 + 0.4, -0.8 + n * 0.12 + 0.3 - 0.02, 0.002, ModelData[ModelActive].image); n++; n++; draw_text_button(esContext, "Telemetry", VIEW_MODE_MODEL, "Telemetry", FONT_WHITE, -1.25, -0.8 + n * 0.12, 0.002, 0.06, ALIGN_LEFT, ALIGN_TOP, model_null, (float)n); draw_line_f3(esContext, -1.3, -0.8 + n * 0.12 + 0.1, 0.002, 1.25, -0.8 + n * 0.12 + 0.1, 0.002, 255, 255, 0, 128); n++; draw_text_button(esContext, "model_load3", VIEW_MODE_MODEL, "TYPE:", FONT_WHITE, -1.1, -0.8 + n * 0.12, 0.002, 0.06, ALIGN_LEFT, ALIGN_TOP, model_teletype_change, 0); draw_text_button(esContext, "model_teletype_change", VIEW_MODE_MODEL, teletypes[ModelData[ModelActive].teletype], FONT_WHITE, -1.1 + 0.3, -0.8 + n * 0.12, 0.002, 0.06, ALIGN_LEFT, ALIGN_TOP, model_teletype_change, 0); n++; #ifdef SDLGL if (ModelData[ModelActive].pilottype == MAV_AUTOPILOT_PIXHAWK) { sprintf(tmp_str, "%s/obj3d/%s.obj", BASE_DIR, "PIXHAWK"); } else { sprintf(tmp_str, "%s/obj3d/%s.obj", BASE_DIR, teletypes[ModelData[ModelActive].teletype]); } if (file_exists(tmp_str) != 0) { static uint8_t startup = 0; static float rotate = 0.0; rotate += 0.4; if (startup == 0 || strcmp(obj3d_teletype.name, tmp_str) != 0) { startup = 1; if (obj3d_teletype.faces_num != 0) { object3d_free(&obj3d_teletype); } object3d_load(&obj3d_teletype, tmp_str); } glTranslatef(0.5, -0.15, -2.0); glRotatef(rotate, -1.0, -1.0, 0.2); glScalef(0.25, 0.25, 0.25); object3d_draw(&obj3d_teletype, 255, 255, 255, 100); glMatrixMode( GL_MODELVIEW ); glLoadIdentity(); } #endif draw_text_f3(esContext, -1.1, -0.8 + n * 0.12, 0.002, 0.06, 0.06, FONT_WHITE, "DEVICE:"); if (ModelData[ModelActive].telemetry_port[0] == 0) { // strcpy(ModelData[ModelActive].telemetry_port, "/dev/rfcomm0"); } sprintf(tmp_str, "%s [SELECT]", ModelData[ModelActive].telemetry_port); draw_text_button(esContext, "device_select", VIEW_MODE_MODEL, tmp_str, FONT_WHITE, -1.1 + 0.3, -0.8 + n * 0.12, 0.002, 0.06, ALIGN_LEFT, ALIGN_TOP, model_device_change, 0); n++; if (strcmp(ModelData[ModelActive].telemetry_port, "TCP") == 0) { draw_text_f3(esContext, -1.1, -0.8 + n * 0.12, 0.002, 0.06, 0.06, FONT_WHITE, "IP:"); sprintf(tmp_str, "%s [CHANGE]", ModelData[ModelActive].netip); draw_text_button(esContext, "model_ip_edit", VIEW_MODE_MODEL, tmp_str, FONT_WHITE, -1.1 + 0.3, -0.8 + n * 0.12, 0.002, 0.06, ALIGN_LEFT, ALIGN_TOP, model_ip_edit, n); n++; draw_text_f3(esContext, -1.1, -0.8 + n * 0.12, 0.002, 0.06, 0.06, FONT_WHITE, "PORT:"); sprintf(tmp_str, "%i [CHANGE]", ModelData[ModelActive].netport); draw_text_button(esContext, "model_port_edit", VIEW_MODE_MODEL, tmp_str, FONT_WHITE, -1.1 + 0.3, -0.8 + n * 0.12, 0.002, 0.06, ALIGN_LEFT, ALIGN_TOP, model_port_edit, n); n++; } else if (strcmp(ModelData[ModelActive].telemetry_port, "UDP") == 0) { if (ModelData[ModelActive].teletype == TELETYPE_ARDUPILOT) { draw_text_f3(esContext, -1.1, -0.8 + n * 0.12, 0.002, 0.06, 0.06, FONT_WHITE, "USEID:"); sprintf(tmp_str, "%i [CHANGE]", ModelData[ModelActive].use_deviceid); if (ModelData[ModelActive].use_deviceid == 1) { draw_text_button(esContext, "rc_useid", VIEW_MODE_MODEL, tmp_str, FONT_GREEN, -1.1 + 0.3, -0.8 + n * 0.12, 0.002, 0.06, ALIGN_LEFT, ALIGN_TOP, model_use_deviceid_change, n); n++; draw_text_f3(esContext, -1.1, -0.8 + n * 0.12, 0.002, 0.06, 0.06, FONT_WHITE, "SysID:"); sprintf(tmp_str, "%i [CHANGE]", ModelData[ModelActive].mavlink_sysid); draw_text_button(esContext, "rc_mavlink_sysid", VIEW_MODE_MODEL, tmp_str, FONT_WHITE, -1.1 + 0.3, -0.8 + n * 0.12, 0.002, 0.06, ALIGN_LEFT, ALIGN_TOP, model_mavlink_sysid_change, n); } else { draw_text_button(esContext, "rc_useid", VIEW_MODE_MODEL, tmp_str, FONT_WHITE, -1.1 + 0.3, -0.8 + n * 0.12, 0.002, 0.06, ALIGN_LEFT, ALIGN_TOP, model_use_deviceid_change, n); } } n++; } else { draw_text_f3(esContext, -1.1, -0.8 + n * 0.12, 0.002, 0.06, 0.06, FONT_WHITE, "BAUD:"); sprintf(tmp_str, "%i [CHANGE]", ModelData[ModelActive].telemetry_baud); draw_text_button(esContext, "rc_baud", VIEW_MODE_MODEL, tmp_str, FONT_WHITE, -1.1 + 0.3, -0.8 + n * 0.12, 0.002, 0.06, ALIGN_LEFT, ALIGN_TOP, model_baud_change, n); n++; draw_text_f3(esContext, -1.1, -0.8 + n * 0.12, 0.002, 0.06, 0.06, FONT_WHITE, "USEID:"); sprintf(tmp_str, "%i [CHANGE]", ModelData[ModelActive].use_deviceid); if (ModelData[ModelActive].use_deviceid == 1) { draw_text_button(esContext, "rc_useid", VIEW_MODE_MODEL, tmp_str, FONT_GREEN, -1.1 + 0.3, -0.8 + n * 0.12, 0.002, 0.06, ALIGN_LEFT, ALIGN_TOP, model_use_deviceid_change, n); n++; draw_text_f3(esContext, -1.1, -0.8 + n * 0.12, 0.002, 0.06, 0.06, FONT_WHITE, "ID:"); draw_text_button(esContext, "rc_deviceid", VIEW_MODE_MODEL, ModelData[ModelActive].deviceid, FONT_WHITE, -1.1 + 0.3, -0.8 + n * 0.12, 0.002, 0.06, ALIGN_LEFT, ALIGN_TOP, model_null, n); } else { draw_text_button(esContext, "rc_useid", VIEW_MODE_MODEL, tmp_str, FONT_WHITE, -1.1 + 0.3, -0.8 + n * 0.12, 0.002, 0.06, ALIGN_LEFT, ALIGN_TOP, model_use_deviceid_change, n); } n++; } draw_text_f3(esContext, -1.1, -0.8 + n * 0.12, 0.002, 0.06, 0.06, FONT_WHITE, "FORWARD:"); if (ModelData[ModelActive].mavlink_forward == 0) { sprintf(tmp_str, "NO [CHANGE]"); } else if (ModelData[ModelActive].mavlink_forward == 1) { sprintf(tmp_str, "READ/WRITE [CHANGE]"); } else if (ModelData[ModelActive].mavlink_forward == 2) { sprintf(tmp_str, "WRITE PROTECT [CHANGE]"); } draw_text_button(esContext, "mavlink_forward_change", VIEW_MODE_MODEL, tmp_str, FONT_WHITE, -1.1 + 0.3, -0.8 + n * 0.12, 0.002, 0.06, ALIGN_LEFT, ALIGN_TOP, model_mavlink_forward_change, n); n++; if (strstr(ModelData[ModelActive].telemetry_port, "rfcomm") > 0) { n++; draw_text_f3(esContext, -1.1 + 0.1, -0.8 + n * 0.12, 0.002, 0.06, 0.06, FONT_WHITE, "BLUETOOTH_DEVICE:"); if (ModelData[ModelActive].telebtaddr[0] == 0) { strcpy(ModelData[ModelActive].telebtaddr, "00:00:00:00:00:00"); } sprintf(tmp_str, "%s [RESCAN]", ModelData[ModelActive].telebtaddr); draw_text_button(esContext, "bt_scan", VIEW_MODE_MODEL, tmp_str, FONT_WHITE, -1.1 + 0.8, -0.8 + n * 0.12, 0.002, 0.06, ALIGN_LEFT, ALIGN_TOP, model_null, n); n++; draw_text_f3(esContext, -1.1 + 0.1, -0.8 + n * 0.12, 0.002, 0.06, 0.06, FONT_WHITE, "BLUETOOTH_PIN:"); if (ModelData[ModelActive].telebtpin[0] == 0) { strcpy(ModelData[ModelActive].telebtpin, "1234"); } sprintf(tmp_str, "%s [CHANGE]", ModelData[ModelActive].telebtpin); draw_text_button(esContext, "bt_pin", VIEW_MODE_MODEL, tmp_str, FONT_WHITE, -1.1 + 0.8, -0.8 + n * 0.12, 0.002, 0.06, ALIGN_LEFT, ALIGN_TOP, model_null, n); } else { n++; n++; } n = 13; draw_text_button(esContext, "model_reconnect", VIEW_MODE_MODEL, "[RECONNECT]", FONT_WHITE, 0.0, -0.8 + n * 0.12, 0.002, 0.06, ALIGN_CENTER, ALIGN_TOP, model_reconnect, n); n++; draw_text_button(esContext, "model_save", VIEW_MODE_MODEL, "[SAVE]", FONT_WHITE, 0.0, -0.8 + n * 0.12, 0.002, 0.06, ALIGN_CENTER, ALIGN_TOP, model_save, n); screen_keyboard(esContext); screen_filesystem(esContext); screen_device(esContext); screen_baud(esContext); }
dialog_frame::dimension_measurements dialog_frame::layout(int x, int y, int w, int h) { dim_ = dimension_measurements(); if(!title_.empty()) { dim_.title = draw_title(NULL); dim_.title.w += title_border_w; } if(buttons_ != NULL) { for(std::vector<button*>::const_iterator b = buttons_->begin(); b != buttons_->end(); ++b) { dim_.button_row.w += (**b).width() + ButtonHPadding; dim_.button_row.h = std::max<int>((**b).height() + ButtonVPadding,dim_.button_row.h); } dim_.button_row.x = -dim_.button_row.w; dim_.button_row.y = y + h; dim_.button_row.w += ButtonHPadding; } size_t buttons_width = dim_.button_row.w; if(help_button_ != NULL) { buttons_width += help_button_->width() + ButtonHPadding*2; dim_.button_row.y = y + h; } y -= dim_.title.h; w = std::max<int>(w,std::max<int>(int(dim_.title.w),int(buttons_width))); h += dim_.title.h + dim_.button_row.h; dim_.button_row.x += x + w; SDL_Rect bounds = screen_area(); if(have_border_) { bounds.x += left_->w; bounds.y += top_->h; bounds.w -= left_->w; bounds.h -= top_->h; } if(x < bounds.x) { w += x; x = bounds.x; } if(y < bounds.y) { h += y; y = bounds.y; } if(x > bounds.w) { w = 0; } else if(x + w > bounds.w) { w = bounds.w - x; } if(y > bounds.h) { h = 0; } else if(y + h > bounds.h) { h = bounds.h - y; } dim_.interior.x = x; dim_.interior.y = y; dim_.interior.w = w; dim_.interior.h = h; if(have_border_) { dim_.exterior.x = dim_.interior.x - left_->w; dim_.exterior.y = dim_.interior.y - top_->h; dim_.exterior.w = dim_.interior.w + left_->w + right_->w; dim_.exterior.h = dim_.interior.h + top_->h + bot_->h; } else { dim_.exterior = dim_.interior; } dim_.title.x = dim_.interior.x + title_border_w; dim_.title.y = dim_.interior.y + title_border_h; return dim_; }
void screen_mwi_menu (ESContext *esContext) { int16_t n = 0; int16_t n2 = 0; int16_t n3 = 0; char tmp_str[100]; char tmp_str2[100]; draw_title(esContext, "MultiWii"); if (mwi_view == 1) { for (n3 = 0; n3 < 4; n3++) { if (n3 < 4) { float val = (float)ModelData.radio[4 + n3] / 2.0 + 50.0; if (val > 100.0) { val = 100.0; } else if (val < -100.0) { val = -100.0; } draw_circleMeter_f3(esContext, -0.4 + (float)n3 * 0.16 * 3.0, -0.8, 0.001, 0.06, 20.0, 30.0, 70.0, 160.0, val, "", "", 1); } sprintf(tmp_str2, " AUX%i", n3 + 1); draw_text_button(esContext, "box", VIEW_MODE_FCMENU, tmp_str2, FONT_WHITE, -0.85 + (float)n3 * 0.16 * 3.0, -0.87, 0.002, 0.08, 0, 0, mwi_null, (float)n3); if (ModelData.radio[4 + n3] < -40) { draw_text_button(esContext, "box", VIEW_MODE_FCMENU, " L", FONT_GREEN, -0.8 + (float)n3 * 0.16 * 3.0, -0.8, 0.002, 0.08, 0, 0, mwi_null, (float)n3); draw_text_button(esContext, "box", VIEW_MODE_FCMENU, " M", FONT_WHITE, -0.8 + (float)n3 * 0.16 * 3.0 + 0.16, -0.8, 0.002, 0.08, 0, 0, mwi_null, (float)n3); draw_text_button(esContext, "box", VIEW_MODE_FCMENU, " H", FONT_WHITE, -0.8 + (float)n3 * 0.16 * 3.0 + 0.32, -0.8, 0.002, 0.08, 0, 0, mwi_null, (float)n3); } else if (ModelData.radio[4 + n3] > 40) { draw_text_button(esContext, "box", VIEW_MODE_FCMENU, " L", FONT_WHITE, -0.8 + (float)n3 * 0.16 * 3.0, -0.8, 0.002, 0.08, 0, 0, mwi_null, (float)n3); draw_text_button(esContext, "box", VIEW_MODE_FCMENU, " M", FONT_WHITE, -0.8 + (float)n3 * 0.16 * 3.0 + 0.16, -0.8, 0.002, 0.08, 0, 0, mwi_null, (float)n3); draw_text_button(esContext, "box", VIEW_MODE_FCMENU, " H", FONT_GREEN, -0.8 + (float)n3 * 0.16 * 3.0 + 0.32, -0.8, 0.002, 0.08, 0, 0, mwi_null, (float)n3); } else { draw_text_button(esContext, "box", VIEW_MODE_FCMENU, " L", FONT_WHITE, -0.8 + (float)n3 * 0.16 * 3.0, -0.8, 0.002, 0.08, 0, 0, mwi_null, (float)n3); draw_text_button(esContext, "box", VIEW_MODE_FCMENU, " M", FONT_GREEN, -0.8 + (float)n3 * 0.16 * 3.0 + 0.16, -0.8, 0.002, 0.08, 0, 0, mwi_null, (float)n3); draw_text_button(esContext, "box", VIEW_MODE_FCMENU, " H", FONT_WHITE, -0.8 + (float)n3 * 0.16 * 3.0 + 0.32, -0.8, 0.002, 0.08, 0, 0, mwi_null, (float)n3); } } for (n2 = 0; n2 < 16 && mwi_box_names[n2][0] != 0; n2++) { sprintf(tmp_str, "mwi_v%i", n); sprintf(tmp_str2, "%s", mwi_box_names[n2]); if (n2 < 3 && ! (mwi_sensors & (1<<n2))) { draw_text_button(esContext, "box", VIEW_MODE_FCMENU, tmp_str2, FONT_TRANS, -1.2, -0.7 + (float)n2 * 0.1, 0.002, 0.08, 0, 0, mwi_null, (float)n2); // } else if ((n2 == 6 || n2 == 7) && ! (mwi_sensors & (1<<3))) { // draw_text_button(esContext, "box", VIEW_MODE_FCMENU, tmp_str2, FONT_TRANS, -1.2, -0.7 + (float)n2 * 0.1, 0.002, 0.08, 0, 0, mwi_null, (float)n2); // } else if ((n2 == 9) && ! (mwi_sensors & (1<<2))) { // draw_text_button(esContext, "box", VIEW_MODE_FCMENU, tmp_str2, FONT_TRANS, -1.2, -0.7 + (float)n2 * 0.1, 0.002, 0.08, 0, 0, mwi_null, (float)n2); } else if (mwi_status & (1<<n2)) { draw_text_button(esContext, "box", VIEW_MODE_FCMENU, tmp_str2, FONT_GREEN, -1.2, -0.7 + (float)n2 * 0.1, 0.002, 0.08, 0, 0, mwi_null, (float)n2); } else { draw_text_button(esContext, "box", VIEW_MODE_FCMENU, tmp_str2, FONT_WHITE, -1.2, -0.7 + (float)n2 * 0.1, 0.002, 0.08, 0, 0, mwi_null, (float)n2); } } n = 0; for (n2 = 0; n2 < 16 && mwi_box_names[n2][0] != 0; n2++) { for (n3 = 0; n3 < 12; n3++) { sprintf(tmp_str, "mwi_v%i", n); if (mwi_set_box[n2] & (1<<n3)) { sprintf(tmp_str2, "[x]"); draw_text_button(esContext, tmp_str, VIEW_MODE_FCMENU, tmp_str2, FONT_WHITE, -0.8 + (float)n3 * 0.16, -0.7 + (float)n2 * 0.1, 0.002, 0.08, 0, 0, mwi_box_set, (float)n); } else { sprintf(tmp_str2, "[ ]"); draw_text_button(esContext, tmp_str, VIEW_MODE_FCMENU, tmp_str2, FONT_WHITE, -0.8 + (float)n3 * 0.16, -0.7 + (float)n2 * 0.1, 0.002, 0.08, 0, 0, mwi_box_set, (float)n); } n++; } } draw_text_button(esContext, "mwi_view", VIEW_MODE_FCMENU, "[BOX]", FONT_WHITE, 0.0, 0.9, 0.002, 0.07, 1, 0, mwi_view_change, 0.0); } else { draw_text_button(esContext, "pid", VIEW_MODE_FCMENU, "P", FONT_WHITE, -0.7 + 1.0 * 0.2, -0.8, 0.002, 0.08, 1, 0, mwi_pid_set, (float)0); draw_text_button(esContext, "pid", VIEW_MODE_FCMENU, "I", FONT_WHITE, 0.0 + 1.0 * 0.2, -0.8, 0.002, 0.08, 1, 0, mwi_pid_set, (float)1); draw_text_button(esContext, "pid", VIEW_MODE_FCMENU, "D", FONT_WHITE, 0.7 + 1.0 * 0.2, -0.8, 0.002, 0.08, 1, 0, mwi_pid_set, (float)2); for (n2 = 0; n2 < 16 && mwi_pid_names[n2][0]; n2++) { sprintf(tmp_str2, "%s", mwi_pid_names[n2]); draw_text_button(esContext, "pid", VIEW_MODE_FCMENU, tmp_str2, FONT_WHITE, -1.2, -0.7 + (float)n2 * 0.13, 0.002, 0.08, 0, 0, mwi_null, (float)n2); if (n2 < 3) { float val = (float)ModelData.radio[n2] / 2.0 + 50.0; if (val > 100.0) { val = 100.0; } else if (val < -100.0) { val = -100.0; } draw_circleMeter_f3(esContext, -0.85, -0.7 + (float)n2 * 0.13 + 0.07, 0.001, 0.06, 20.0, 50.0, 50.0, 160.0, val, "", "", 1); } } n = 0; for (n2 = 0; n2 < 16 && mwi_pid_names[n2][0]; n2++) { if (n2 == 114) { sprintf(tmp_str2, "%0.2f", (float)mwi_pid[n2][0] / 100.0); sprintf(tmp_str, "mwi_p-%i", n); draw_text_button(esContext, tmp_str, VIEW_MODE_FCMENU, "[-]", FONT_WHITE, -0.7 + 0.0 * 0.2, -0.7 + (float)n2 * 0.13, 0.002, 0.08, 1, 0, mwi_pid_set, (float)n); sprintf(tmp_str, "mwi_p%i", n); draw_text_button(esContext, tmp_str, VIEW_MODE_FCMENU, tmp_str2, FONT_WHITE, -0.7 + 1.0 * 0.2, -0.7 + (float)n2 * 0.13, 0.002, 0.08, 1, 0, mwi_pid_set, (float)n); sprintf(tmp_str, "mwi_p+%i", n); draw_text_button(esContext, tmp_str, VIEW_MODE_FCMENU, "[+]", FONT_WHITE, -0.7 + 2.0 * 0.2, -0.7 + (float)n2 * 0.13, 0.002, 0.08, 1, 0, mwi_pid_set, (float)n); sprintf(tmp_str2, "%0.2f", (float)mwi_pid[n2][1] / 100.0); sprintf(tmp_str, "mwi_i-%i", n); draw_text_button(esContext, tmp_str, VIEW_MODE_FCMENU, "[-]", FONT_WHITE, -0.0 + 0.0 * 0.2, -0.7 + (float)n2 * 0.13, 0.002, 0.08, 1, 0, mwi_pid_set, (float)n + 1.0); sprintf(tmp_str, "mwi_i%i", n); draw_text_button(esContext, tmp_str, VIEW_MODE_FCMENU, tmp_str2, FONT_WHITE, -0.0 + 1.0 * 0.2, -0.7 + (float)n2 * 0.13, 0.002, 0.08, 1, 0, mwi_pid_set, (float)n + 1.0); sprintf(tmp_str, "mwi_i+%i", n); draw_text_button(esContext, tmp_str, VIEW_MODE_FCMENU, "[+]", FONT_WHITE, -0.0 + 2.0 * 0.2, -0.7 + (float)n2 * 0.13, 0.002, 0.08, 1, 0, mwi_pid_set, (float)n + 1.0); } else if (n2 == 115 || n2 == 116) { sprintf(tmp_str2, "%0.2f", (float)mwi_pid[n2][0] / 10.0); sprintf(tmp_str, "mwi_p-%i", n); draw_text_button(esContext, tmp_str, VIEW_MODE_FCMENU, "[-]", FONT_WHITE, -0.7 + 0.0 * 0.2, -0.7 + (float)n2 * 0.13, 0.002, 0.08, 1, 0, mwi_pid_set, (float)n); sprintf(tmp_str, "mwi_p%i", n); draw_text_button(esContext, tmp_str, VIEW_MODE_FCMENU, tmp_str2, FONT_WHITE, -0.7 + 1.0 * 0.2, -0.7 + (float)n2 * 0.13, 0.002, 0.08, 1, 0, mwi_pid_set, (float)n); sprintf(tmp_str, "mwi_p+%i", n); draw_text_button(esContext, tmp_str, VIEW_MODE_FCMENU, "[+]", FONT_WHITE, -0.7 + 2.0 * 0.2, -0.7 + (float)n2 * 0.13, 0.002, 0.08, 1, 0, mwi_pid_set, (float)n); sprintf(tmp_str2, "%0.2f", (float)mwi_pid[n2][1] / 100.0); sprintf(tmp_str, "mwi_i-%i", n); draw_text_button(esContext, tmp_str, VIEW_MODE_FCMENU, "[-]", FONT_WHITE, -0.0 + 0.0 * 0.2, -0.7 + (float)n2 * 0.13, 0.002, 0.08, 1, 0, mwi_pid_set, (float)n + 1.0); sprintf(tmp_str, "mwi_i%i", n); draw_text_button(esContext, tmp_str, VIEW_MODE_FCMENU, tmp_str2, FONT_WHITE, -0.0 + 1.0 * 0.2, -0.7 + (float)n2 * 0.13, 0.002, 0.08, 1, 0, mwi_pid_set, (float)n + 1.0); sprintf(tmp_str, "mwi_i+%i", n); draw_text_button(esContext, tmp_str, VIEW_MODE_FCMENU, "[+]", FONT_WHITE, -0.0 + 2.0 * 0.2, -0.7 + (float)n2 * 0.13, 0.002, 0.08, 1, 0, mwi_pid_set, (float)n + 1.0); sprintf(tmp_str2, "%0.3f", (float)mwi_pid[n2][2] / 1000.0); sprintf(tmp_str, "mwi_d-%i", n); draw_text_button(esContext, tmp_str, VIEW_MODE_FCMENU, "[-]", FONT_WHITE, 0.7 + 0.0 * 0.2, -0.7 + (float)n2 * 0.13, 0.002, 0.08, 1, 0, mwi_pid_set, (float)n + 2.0); sprintf(tmp_str, "mwi_d%i", n); draw_text_button(esContext, tmp_str, VIEW_MODE_FCMENU, tmp_str2, FONT_WHITE, 0.7 + 1.0 * 0.2, -0.7 + (float)n2 * 0.13, 0.002, 0.08, 1, 0, mwi_pid_set, (float)n + 2.0); sprintf(tmp_str, "mwi_d+%i", n); draw_text_button(esContext, tmp_str, VIEW_MODE_FCMENU, "[+]", FONT_WHITE, 0.7 + 2.0 * 0.2, -0.7 + (float)n2 * 0.13, 0.002, 0.08, 1, 0, mwi_pid_set, (float)n + 2.0); } else { sprintf(tmp_str2, "%0.2f", (float)mwi_pid[n2][0] / 10.0); sprintf(tmp_str, "mwi_p-%i", n); draw_text_button(esContext, tmp_str, VIEW_MODE_FCMENU, "[-]", FONT_WHITE, -0.7 + 0.0 * 0.2, -0.7 + (float)n2 * 0.13, 0.002, 0.08, 1, 0, mwi_pid_set, (float)n); sprintf(tmp_str, "mwi_p%i", n); draw_text_button(esContext, tmp_str, VIEW_MODE_FCMENU, tmp_str2, FONT_WHITE, -0.7 + 1.0 * 0.2, -0.7 + (float)n2 * 0.13, 0.002, 0.08, 1, 0, mwi_pid_set, (float)n); sprintf(tmp_str, "mwi_p+%i", n); draw_text_button(esContext, tmp_str, VIEW_MODE_FCMENU, "[+]", FONT_WHITE, -0.7 + 2.0 * 0.2, -0.7 + (float)n2 * 0.13, 0.002, 0.08, 1, 0, mwi_pid_set, (float)n); if (n2 != 118) { sprintf(tmp_str2, "%0.3f", (float)mwi_pid[n2][1] / 1000.0); sprintf(tmp_str, "mwi_i-%i", n); draw_text_button(esContext, tmp_str, VIEW_MODE_FCMENU, "[-]", FONT_WHITE, -0.0 + 0.0 * 0.2, -0.7 + (float)n2 * 0.13, 0.002, 0.08, 1, 0, mwi_pid_set, (float)n + 1.0); sprintf(tmp_str, "mwi_i%i", n); draw_text_button(esContext, tmp_str, VIEW_MODE_FCMENU, tmp_str2, FONT_WHITE, -0.0 + 1.0 * 0.2, -0.7 + (float)n2 * 0.13, 0.002, 0.08, 1, 0, mwi_pid_set, (float)n + 1.0); sprintf(tmp_str, "mwi_i+%i", n); draw_text_button(esContext, tmp_str, VIEW_MODE_FCMENU, "[+]", FONT_WHITE, -0.0 + 2.0 * 0.2, -0.7 + (float)n2 * 0.13, 0.002, 0.08, 1, 0, mwi_pid_set, (float)n + 1.0); sprintf(tmp_str2, "%0.0f", (float)mwi_pid[n2][2] / 1.0); sprintf(tmp_str, "mwi_d-%i", n); draw_text_button(esContext, tmp_str, VIEW_MODE_FCMENU, "[-]", FONT_WHITE, 0.7 + 0.0 * 0.2, -0.7 + (float)n2 * 0.13, 0.002, 0.08, 1, 0, mwi_pid_set, (float)n + 2.0); sprintf(tmp_str, "mwi_d%i", n); draw_text_button(esContext, tmp_str, VIEW_MODE_FCMENU, tmp_str2, FONT_WHITE, 0.7 + 1.0 * 0.2, -0.7 + (float)n2 * 0.13, 0.002, 0.08, 1, 0, mwi_pid_set, (float)n + 2.0); sprintf(tmp_str, "mwi_d+%i", n); draw_text_button(esContext, tmp_str, VIEW_MODE_FCMENU, "[+]", FONT_WHITE, 0.7 + 2.0 * 0.2, -0.7 + (float)n2 * 0.13, 0.002, 0.08, 1, 0, mwi_pid_set, (float)n + 2.0); } } n += 3; } draw_text_button(esContext, "mwi_view", VIEW_MODE_FCMENU, "[PID]", FONT_WHITE, 0.0, 0.9, 0.002, 0.07, 1, 0, mwi_view_change, 0.0); } draw_text_button(esContext, "mwi_cal_acc", VIEW_MODE_FCMENU, "[CAL_ACC]", FONT_WHITE, -0.8, 0.9, 0.002, 0.07, 1, 0, mwi_cal_acc, 0.0); draw_text_button(esContext, "mwi_cal_mac", VIEW_MODE_FCMENU, "[CAL_MAG]", FONT_WHITE, -0.4, 0.9, 0.002, 0.07, 1, 0, mwi_cal_mac, 0.0); draw_text_button(esContext, "mwi_get_values", VIEW_MODE_FCMENU, "[READ]", FONT_WHITE, 0.4, 0.9, 0.002, 0.07, 1, 0, mwi_get_values, 0.0); draw_text_button(esContext, "mwi_write_rom", VIEW_MODE_FCMENU, "[WRITE_ROM]", FONT_WHITE, 0.8, 0.9, 0.002, 0.07, 1, 0, mwi_write_rom, 0.0); }
int title_screen(const char *commands[100], int *f, double noteinfo[2][1000], char output[1000]){ int xsize=1250; int ysize=1000; int xpos; int ypos; int height=400; int width=(xsize-50)/16; int i,j; char input[20]; char initial[1000]; char c; gfx_open(xsize, ysize, "Digital Piano"); quit_button(); draw_title(100); draw_name(50); draw_name2(50); draw_button(295,600,70,310); draw_button(645,600,70,310); button_label(60); button_label2(60); while (1){ c=gfx_wait(); xpos=gfx_xpos(); ypos=gfx_ypos(); //user clicks the quit button if (xpos>=1110 && xpos<=1210 && ypos>=850 && ypos<=890){ return 0; } //user clicks free play button if (xpos>=295 && xpos<=605 && ypos>=600 && ypos<=670){ gfx_clear(); piano_graphic(commands, f); } //user clicks load file button if (xpos>=645 && xpos<=955 && ypos>=600 && ypos<=670){ terminal_message(); printf("Please enter the name of the file, including the extension.\nThe file content should follow the same format as the examples in lab 8:\n"); scanf("%s", input); //scans file name into input FILE *music=fopen(input, "r"); if ((music=fopen(input, "r")) == NULL){ //returns error if file not found puts("File could not be opened"); return 0; } else{ //scans the file into output for (j=0; j<1000; j++){ fscanf(music, "%c", &output[j]); if (output[j]=='X'){ break; } } } piano2(noteinfo, output); //fork to play sound while lighting up keys if (fork()){ system("play sound.wav"); } else{ gfx_clear(); draw_piano(width, height); draw_arrow(50, f); gfx_color(255,255,255); draw_box(); octave_label(30); quit_button(); gfx_flush(); key_animation(noteinfo, f); return 0; } } } }
void screen_system(ESContext *esContext) { #ifndef SDLGL ESMatrix modelview; UserData *userData = esContext->userData; #endif #ifndef WINDOWS FILE *cmd = NULL; #endif char buffer[1025]; static char ip[30]; static char bcast[30]; static char mask[30]; static char hostname[30]; static char dnsserver[30]; static char gateway[30]; uint32_t now_time = time(0); static uint32_t last_time = 0; #ifndef SDLGL esMatrixLoadIdentity(&modelview); esMatrixMultiply(&userData->mvpMatrix, &modelview, &userData->perspective); #endif draw_title(esContext, "System"); if (last_time != now_time) { strcpy(ip, "---.---.---.---"); strcpy(bcast, "---.---.---.---"); strcpy(mask, "---.---.---.---"); strcpy(dnsserver, "---.---.---.---"); strcpy(gateway, "---.---.---.---"); #ifndef WINDOWS #ifndef ANDROID #ifdef OSX if ((cmd = popen("LANG=C ifconfig en0 | grep \"inet \" | sed \"s|[a-zA-Z:]||g\"", "r")) != NULL) { while (!feof(cmd)) { if (fgets(buffer, 1024, cmd) != NULL) { sscanf(buffer, "%s %s %s", (char *)&ip, (char *)&bcast, (char *)&mask); // SDL_Log("## %s, %s, %s ##\n", ip, bcast, mask); } } pclose(cmd); } #else if ((cmd = popen("LANG=C ifconfig eth0 | grep \"inet addr:\" | sed \"s|[a-zA-Z:]||g\"", "r")) != NULL) { while (!feof(cmd)) { if (fgets(buffer, 1024, cmd) != NULL) { sscanf(buffer, "%s %s %s", (char *)&ip, (char *)&bcast, (char *)&mask); // SDL_Log("## %s, %s, %s ##\n", ip, bcast, mask); } } pclose(cmd); } if ((cmd = popen("grep \"^nameserver \" /etc/resolv.conf | cut -d\" \" -f2", "r")) != NULL) { while (!feof(cmd)) { if (fgets(dnsserver, 1024, cmd) != NULL) { } } } pclose(cmd); if ((cmd = popen("route -n | grep \" 0.0.0.0.*255.255.255.0 \" | cut -d\" \" -f1", "r")) != NULL) { while (!feof(cmd)) { if (fgets(gateway, 1024, cmd) != NULL) { } } } pclose(cmd); #endif if ((cmd = popen("hostname", "r")) != NULL) { while (!feof(cmd)) { if (fgets(hostname, 1024, cmd) != NULL) { } } } pclose(cmd); #endif #endif last_time = now_time; } sprintf(buffer, "Name : %s", hostname); draw_text_f(esContext, -0.5, -0.8 + 1 * 0.1, 0.06, 0.06, FONT_GREEN, buffer); sprintf(buffer, "IP : %s", ip); draw_text_f(esContext, -0.5, -0.8 + 3 * 0.1, 0.06, 0.06, FONT_GREEN, buffer); sprintf(buffer, "BCAST : %s", bcast); draw_text_f(esContext, -0.5, -0.8 + 4 * 0.1, 0.06, 0.06, FONT_GREEN, buffer); sprintf(buffer, "MASK : %s", mask); draw_text_f(esContext, -0.5, -0.8 + 5 * 0.1, 0.06, 0.06, FONT_GREEN, buffer); sprintf(buffer, "DNS : %s", dnsserver); draw_text_f(esContext, -0.5, -0.8 + 6 * 0.1, 0.06, 0.06, FONT_GREEN, buffer); sprintf(buffer, "GATE : %s", gateway); draw_text_f(esContext, -0.5, -0.8 + 7 * 0.1, 0.06, 0.06, FONT_GREEN, buffer); draw_text_button(esContext, "system_dhclient", VIEW_MODE_SYSTEM, "<GET IP OVER DHCP>", FONT_GREEN, 0.0, -0.8 + 9 * 0.1, 0.002, 0.06, ALIGN_CENTER, ALIGN_TOP, system_dhclient, 0.0); // draw_text_button(esContext, "system_gcs", VIEW_MODE_SYSTEM, "<UPDATE GCS>", FONT_GREEN, 0.0, -0.8 + 10 * 0.1, 0.002, 0.06, ALIGN_CENTER, ALIGN_TOP, system_update, 0.0); // Connections-Status char tmp_str[100]; uint8_t n = 0; if (ModelData[ModelActive].teletype == TELETYPE_AUTOQUAD || ModelData[ModelActive].teletype == TELETYPE_ARDUPILOT || ModelData[ModelActive].teletype == TELETYPE_MEGAPIRATE_NG) { if (mavlink_connection_status(ModelActive) != 0) { sprintf(tmp_str, "MAVLINK %s (%i / %i)", ModelData[ModelActive].telemetry_port, ModelData[ModelActive].telemetry_baud, (uint8_t)(time(0)) - mavlink_connection_status(ModelActive)); draw_text_button(esContext, "mavlink_connection_status", VIEW_MODE_SYSTEM, tmp_str, FONT_GREEN, -1.3, 0.2 + n++ * 0.065, 0.002, 0.04, ALIGN_LEFT, ALIGN_TOP, system_null, 0.0); } else { sprintf(tmp_str, "MAVLINK %s (%i)", ModelData[ModelActive].telemetry_port, ModelData[ModelActive].telemetry_baud); draw_text_button(esContext, "mavlink_connection_status", VIEW_MODE_SYSTEM, tmp_str, FONT_WHITE, -1.3, 0.2 + n++ * 0.065, 0.002, 0.04, ALIGN_LEFT, ALIGN_TOP, system_null, 0.0); } } else { draw_text_button(esContext, "mavlink_connection_status", VIEW_MODE_SYSTEM, "MAVLINK", FONT_TRANS, -1.3, 0.2 + n++ * 0.065, 0.002, 0.04, ALIGN_LEFT, ALIGN_TOP, system_null, 0.0); } if (ModelData[ModelActive].teletype == TELETYPE_MULTIWII_21 || ModelData[ModelActive].teletype == TELETYPE_BASEFLIGHT) { if (mwi21_connection_status(ModelActive) != 0) { sprintf(tmp_str, "MULTIWII21 %s (%i / %i)", ModelData[ModelActive].telemetry_port, ModelData[ModelActive].telemetry_baud, (uint8_t)(time(0)) - mwi21_connection_status(ModelActive)); draw_text_button(esContext, "mwi21_connection_status", VIEW_MODE_SYSTEM, tmp_str, FONT_GREEN, -1.3, 0.2 + n++ * 0.065, 0.002, 0.04, ALIGN_LEFT, ALIGN_TOP, system_null, 0.0); } else { sprintf(tmp_str, "MULTIWII21 %s (%i)", ModelData[ModelActive].telemetry_port, ModelData[ModelActive].telemetry_baud); draw_text_button(esContext, "mwi21_connection_status", VIEW_MODE_SYSTEM, tmp_str, FONT_WHITE, -1.3, 0.2 + n++ * 0.065, 0.002, 0.04, ALIGN_LEFT, ALIGN_TOP, system_null, 0.0); } } else { draw_text_button(esContext, "mwi21_connection_status", VIEW_MODE_SYSTEM, "MULTIWII21", FONT_TRANS, -1.3, 0.2 + n++ * 0.065, 0.002, 0.04, ALIGN_LEFT, ALIGN_TOP, system_null, 0.0); } if (ModelData[ModelActive].teletype == TELETYPE_BASEFLIGHT) { if (mwi21_connection_status(ModelActive) != 0) { sprintf(tmp_str, "BASEFLIGHT %s (%i / %i)", ModelData[ModelActive].telemetry_port, ModelData[ModelActive].telemetry_baud, (uint8_t)(time(0)) - mwi21_connection_status(ModelActive)); draw_text_button(esContext, "mwi21_connection_status", VIEW_MODE_SYSTEM, tmp_str, FONT_GREEN, -1.3, 0.2 + n++ * 0.065, 0.002, 0.04, ALIGN_LEFT, ALIGN_TOP, system_null, 0.0); } else { sprintf(tmp_str, "BASEFLIGHT %s (%i)", ModelData[ModelActive].telemetry_port, ModelData[ModelActive].telemetry_baud); draw_text_button(esContext, "mwi21_connection_status", VIEW_MODE_SYSTEM, tmp_str, FONT_WHITE, -1.3, 0.2 + n++ * 0.065, 0.002, 0.04, ALIGN_LEFT, ALIGN_TOP, system_null, 0.0); } } else { draw_text_button(esContext, "mwi21_connection_status", VIEW_MODE_SYSTEM, "BASEFLIGHT", FONT_TRANS, -1.3, 0.2 + n++ * 0.065, 0.002, 0.04, ALIGN_LEFT, ALIGN_TOP, system_null, 0.0); } if (ModelData[ModelActive].teletype == TELETYPE_OPENPILOT) { if (openpilot_connection_status(ModelActive) != 0) { sprintf(tmp_str, "OPENPILOT %s (%i / %i)", ModelData[ModelActive].telemetry_port, ModelData[ModelActive].telemetry_baud, (uint8_t)(time(0)) - openpilot_connection_status(ModelActive)); draw_text_button(esContext, "openpilot_connection_status", VIEW_MODE_SYSTEM, tmp_str, FONT_GREEN, -1.3, 0.2 + n++ * 0.065, 0.002, 0.04, ALIGN_LEFT, ALIGN_TOP, system_null, 0.0); } else { sprintf(tmp_str, "OPENPILOT %s (%i)", ModelData[ModelActive].telemetry_port, ModelData[ModelActive].telemetry_baud); draw_text_button(esContext, "openpilot_connection_status", VIEW_MODE_SYSTEM, tmp_str, FONT_WHITE, -1.3, 0.2 + n++ * 0.065, 0.002, 0.04, ALIGN_LEFT, ALIGN_TOP, system_null, 0.0); } } else { draw_text_button(esContext, "openpilot_connection_status", VIEW_MODE_SYSTEM, "OPENPILOT", FONT_TRANS, -1.3, 0.2 + n++ * 0.065, 0.002, 0.04, ALIGN_LEFT, ALIGN_TOP, system_null, 0.0); } if (ModelData[ModelActive].teletype == TELETYPE_GPS_NMEA) { if (gps_connection_status(ModelActive) != 0) { sprintf(tmp_str, "NMEA-GPS %s (%i / %i)", ModelData[ModelActive].telemetry_port, ModelData[ModelActive].telemetry_baud, (uint8_t)(time(0)) - gps_connection_status(ModelActive)); draw_text_button(esContext, "gps_connection_status", VIEW_MODE_SYSTEM, tmp_str, FONT_GREEN, -1.3, 0.2 + n++ * 0.065, 0.002, 0.04, ALIGN_LEFT, ALIGN_TOP, system_null, 0.0); } else { sprintf(tmp_str, "NMEA-GPS %s (%i)", ModelData[ModelActive].telemetry_port, ModelData[ModelActive].telemetry_baud); draw_text_button(esContext, "gps_connection_status", VIEW_MODE_SYSTEM, tmp_str, FONT_WHITE, -1.3, 0.2 + n++ * 0.065, 0.002, 0.04, ALIGN_LEFT, ALIGN_TOP, system_null, 0.0); } } else { draw_text_button(esContext, "gps_connection_status", VIEW_MODE_SYSTEM, "NMEA-GPS", FONT_TRANS, -1.3, 0.2 + n++ * 0.065, 0.002, 0.04, ALIGN_LEFT, ALIGN_TOP, system_null, 0.0); } if (frsky_connection_status() != 0) { sprintf(tmp_str, "FRSKY %s (%i / %i)", setup.frsky_port, setup.frsky_baud, (uint8_t)(time(0)) - frsky_connection_status()); draw_text_button(esContext, "frsky", VIEW_MODE_SYSTEM, tmp_str, FONT_GREEN, -1.3, 0.2 + n++ * 0.065, 0.002, 0.04, ALIGN_LEFT, ALIGN_TOP, system_device_change, 0.0); } else { sprintf(tmp_str, "FRSKY %s (%i)", setup.frsky_port, setup.frsky_baud); draw_text_button(esContext, "frsky", VIEW_MODE_SYSTEM, tmp_str, FONT_WHITE, -1.3, 0.2 + n++ * 0.065, 0.002, 0.04, ALIGN_LEFT, ALIGN_TOP, system_device_change, 0.0); } if (jeti_connection_status() != 0) { sprintf(tmp_str, "JETI %s (%i / %i)", setup.jeti_port, setup.jeti_baud, (uint8_t)(time(0)) - jeti_connection_status()); draw_text_button(esContext, "jeti", VIEW_MODE_SYSTEM, tmp_str, FONT_GREEN, -1.3, 0.2 + n++ * 0.065, 0.002, 0.04, ALIGN_LEFT, ALIGN_TOP, system_device_change, 0.0); } else { sprintf(tmp_str, "JETI %s (%i)", setup.jeti_port, setup.jeti_baud); draw_text_button(esContext, "jeti", VIEW_MODE_SYSTEM, tmp_str, FONT_WHITE, -1.3, 0.2 + n++ * 0.065, 0.002, 0.04, ALIGN_LEFT, ALIGN_TOP, system_device_change, 0.0); } if (gcsgps_connection_status() != 0) { sprintf(tmp_str, "GCS-GPS %s (%i / %i)", setup.gcs_gps_port, setup.gcs_gps_baud, (uint8_t)(time(0)) - gcsgps_connection_status()); draw_text_button(esContext, "gcs_gps", VIEW_MODE_SYSTEM, tmp_str, FONT_GREEN, -1.3, 0.2 + n++ * 0.065, 0.002, 0.04, ALIGN_LEFT, ALIGN_TOP, system_device_change, 0.0); } else { sprintf(tmp_str, "GCS-GPS %s (%i)", setup.gcs_gps_port, setup.gcs_gps_baud); draw_text_button(esContext, "gcs_gps", VIEW_MODE_SYSTEM, tmp_str, FONT_WHITE, -1.3, 0.2 + n++ * 0.065, 0.002, 0.04, ALIGN_LEFT, ALIGN_TOP, system_device_change, 0.0); } if (rcflow_connection_status() != 0) { sprintf(tmp_str, "RCFLOW %s (%i / %i)", setup.rcflow_port, setup.rcflow_baud, (uint8_t)(time(0)) - rcflow_connection_status()); draw_text_button(esContext, "rcflow", VIEW_MODE_SYSTEM, tmp_str, FONT_GREEN, -1.3, 0.2 + n++ * 0.065, 0.002, 0.04, ALIGN_LEFT, ALIGN_TOP, system_device_change, 0.0); } else { sprintf(tmp_str, "RCFLOW %s (%i)", setup.rcflow_port, setup.rcflow_baud); draw_text_button(esContext, "rcflow", VIEW_MODE_SYSTEM, tmp_str, FONT_WHITE, -1.3, 0.2 + n++ * 0.065, 0.002, 0.04, ALIGN_LEFT, ALIGN_TOP, system_device_change, 0.0); } if (tracker_connection_status() != 0) { sprintf(tmp_str, "TRACKER %s (%i / %i)", setup.tracker_port, setup.tracker_baud, (uint8_t)(time(0)) - tracker_connection_status()); draw_text_button(esContext, "tracker", VIEW_MODE_SYSTEM, tmp_str, FONT_GREEN, -1.3, 0.2 + n++ * 0.065, 0.002, 0.04, ALIGN_LEFT, ALIGN_TOP, system_device_change, 0.0); } else { sprintf(tmp_str, "TRACKER %s (%i)", setup.tracker_port, setup.tracker_baud); draw_text_button(esContext, "tracker", VIEW_MODE_SYSTEM, tmp_str, FONT_WHITE, -1.3, 0.2 + n++ * 0.065, 0.002, 0.04, ALIGN_LEFT, ALIGN_TOP, system_device_change, 0.0); } sprintf(tmp_str, "Font: %s (%i/%i)", fontnames[(int)setup.font], setup.font + 1, FONT_MAX); draw_text_button(esContext, "_font", VIEW_MODE_SYSTEM, tmp_str, FONT_GREEN, 0.55, 0.2, 0.002, 0.05, ALIGN_LEFT, ALIGN_TOP, system_set_font, 0.0); sprintf(tmp_str, "Resolution: %ix%i", esContext->width, esContext->height); draw_text_button(esContext, "_res", VIEW_MODE_SYSTEM, tmp_str, FONT_GREEN, 0.55, 0.3, 0.002, 0.05, ALIGN_LEFT, ALIGN_TOP, system_set_fps, 0.0); draw_text_button(esContext, "_border_x", VIEW_MODE_SYSTEM, "X-Border", FONT_GREEN, 0.55, 0.4, 0.002, 0.05, ALIGN_LEFT, ALIGN_TOP, system_set_border_x, 0.0); draw_text_button(esContext, "_border_x--", VIEW_MODE_SYSTEM, "[-]", FONT_GREEN, 0.85, 0.4, 0.002, 0.05, ALIGN_LEFT, ALIGN_TOP, system_set_border_x, -2.0); draw_text_button(esContext, "_border_x++", VIEW_MODE_SYSTEM, "[+]", FONT_GREEN, 0.95, 0.4, 0.002, 0.05, ALIGN_LEFT, ALIGN_TOP, system_set_border_x, 2.0); draw_text_button(esContext, "_border_y", VIEW_MODE_SYSTEM, "Y-Border", FONT_GREEN, 0.55, 0.5, 0.002, 0.05, ALIGN_LEFT, ALIGN_TOP, system_set_border_y, 0.0); draw_text_button(esContext, "_border_y--", VIEW_MODE_SYSTEM, "[-]", FONT_GREEN, 0.85, 0.5, 0.002, 0.05, ALIGN_LEFT, ALIGN_TOP, system_set_border_y, -2.0); draw_text_button(esContext, "_border_y++", VIEW_MODE_SYSTEM, "[+]", FONT_GREEN, 0.95, 0.5, 0.002, 0.05, ALIGN_LEFT, ALIGN_TOP, system_set_border_y, 2.0); sprintf(tmp_str, "Ratio(%0.1f)", setup.keep_ratio); draw_text_button(esContext, "ratio", VIEW_MODE_SYSTEM, tmp_str, FONT_GREEN, 0.55, 0.6, 0.002, 0.05, ALIGN_LEFT, ALIGN_TOP, system_set_ratio, 0.0); draw_text_button(esContext, "ratio--", VIEW_MODE_SYSTEM, "[-]", FONT_GREEN, 0.85, 0.6, 0.002, 0.05, ALIGN_LEFT, ALIGN_TOP, system_set_ratio, -0.1); draw_text_button(esContext, "ratio++", VIEW_MODE_SYSTEM, "[+]", FONT_GREEN, 0.95, 0.6, 0.002, 0.05, ALIGN_LEFT, ALIGN_TOP, system_set_ratio, 0.1); if (setup.side_by_side == 1) { draw_text_button(esContext, "side_by_side", VIEW_MODE_SYSTEM, "SideBySide", FONT_PINK, 0.55, 0.7, 0.002, 0.05, ALIGN_LEFT, ALIGN_TOP, system_set_side_by_side, 0.1); } else { draw_text_button(esContext, "side_by_side", VIEW_MODE_SYSTEM, "SideBySide", FONT_GREEN, 0.55, 0.7, 0.002, 0.05, ALIGN_LEFT, ALIGN_TOP, system_set_side_by_side, 0.1); } #ifndef ANDROID #ifdef SDL2 if (setup.fullscreen == 0) { draw_text_button(esContext, "fullscreen", VIEW_MODE_SYSTEM, "TOGGLE FULLSCREEN", FONT_WHITE, 0.55, 0.7, 0.002, 0.05, ALIGN_LEFT, ALIGN_TOP, system_set_fullscreen, 0.0); } else { draw_text_button(esContext, "fullscreen", VIEW_MODE_SYSTEM, "TOGGLE FULLSCREEN", FONT_GREEN, 0.55, 0.7, 0.002, 0.05, ALIGN_LEFT, ALIGN_TOP, system_set_fullscreen, 0.0); } #endif #endif if (setup.weather_enable == 1) { draw_text_button(esContext, "copyright", VIEW_MODE_SYSTEM, "Weather-Data copyright by http://www.openweathermap.org", FONT_PINK, 0.0, 0.88, 0.002, 0.04, ALIGN_CENTER, ALIGN_TOP, system_null, 0.0); } draw_text_button(esContext, "copyright", VIEW_MODE_SYSTEM, "Copyright by Oliver Dippel ([email protected])", FONT_PINK, 0.0, 0.93, 0.002, 0.04, ALIGN_CENTER, ALIGN_TOP, system_null, 0.0); screen_device(esContext); screen_baud(esContext); if (resize != 0) { resize = 0; #ifdef SDL2 glResize(esContext, setup.screen_w, setup.screen_h); #endif } }