void CarApp::mouse_released(int x, int y) { logger->log(DEBUG, "CarApp::mouse_released", "start"); int i, top; top = MARGIN; for (i=0; i<=7; i++) { if (y > top && y < top+button_height) { if (i == MENU) set_current_selection(MENU); else if (i == UP) sound->volume_up(); else if (i == DOWN) sound->volume_down(); else if (i == MUTE) sound->toggle_mute(); else if (i == RIGHT) currentModule->action_right(); else if (i == LEFT) currentModule->action_left(); draw_buttons(-1); //draw_current_selection(); return; } top += MARGIN + button_height; } logger->log(DEBUG, "CarApp::mouse_released", "end"); }
void on_terminate_exec() { is_playing = false; is_recording = false; draw_buttons(); draw_vu(1, -1); draw_vu(1, 1); pmic->stop(); }
void draw_dialog(void) { wattrset(dialogw, GET_PAIR_FOR(stgs.colors->def)); draw_rect(dialogw, (Vector2i) { 0, 0 }, DIALOG_WINDOW_WIDTH, DIALOG_WINDOW_HEIGHT); draw_tiles(); draw_buttons(); wnoutrefresh(dialogw); }
void draw(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); //draw working window and panel with set of tools draw_grid(); draw_panel(border); glColor3f(0, 0, 0); drawBitmapText("Tools", 2, 770); draw_buttons(); }
void procbar::remove(xwindow *win) // remove from bar { WINLIST *w; int i; for(i=0; i < wlist.size() && wlist.at(i)->win != win; i++); if(i == wlist.size()) return; w = wlist.takeAt(i); delete w->button; delete w; draw_buttons(); }
CarApp::CarApp(int argc, char *argv[]) { logger = new Logger(); // must read config file before loading any module conf = new ConfigFile("/etc/carpc.conf", logger); logger->set_log_level(atoi(conf->get_value("log_level"))); logger->log(DEBUG, "CarApp::CarApp", "start"); fb = new FrameBuffer(logger); button_height = fb->height / 6; button_width = button_height; // buttons are square // set the client area where various modules will be drawn client_offset_x = button_width; client_offset_y = 0; client_width = fb->width - client_offset_x; client_height = fb->height - client_offset_y; // construct all modules. sound = new VolumeControl(logger); carMenu = new CarMenu(this, logger); carRadio = new CarRadio(this, logger); carMp3 = new CarMP3(this, logger); carGps = new CarGPS(this, logger); carObdii = new CarOBDII(this, logger); touchScreen = new TouchScreen(logger); quit = FALSE; carDefault = new CarModule(this, logger); currentModule = carMenu; draw_buttons(-1); set_current_selection(MENU); draw_current_selection(); // disable console blanking char ioctlarg[2]; ioctlarg[0] = 10; // powersave ioctlarg[1] = 0; // disable console balnking if (ioctl(0,TIOCLINUX,ioctlarg)) logger->log(ERROR, "CarApp::CarApp", "Cannot disable console blanking"); logger->log(DEBUG, "CarApp::CarApp", "end"); }
void CarApp::mouse_pressed(int x, int y) { logger->log(DEBUG, "CarApp::mouse_pressed", "start"); int i, top; top = MARGIN; for (i=0; i<=7; i++) { if (y > top && y < top+button_height) { draw_buttons(i); //draw_current_selection(); return; } top += MARGIN + button_height; } logger->log(DEBUG, "CarApp::mouse_pressed", "end"); }
void procbar::add(xwindow *win) { WINLIST *w; int i; if(win == NULL) return; foreach(w, wlist) { if(w->win == win) // window already on bar { w->button->setChecked(FALSE); return; } } i = wlist.size(); while(i--*max_bwidth > width() && remove_fg()); w = new WINLIST; Q_CHECK_PTR(w); w->button = new QPushButton(this); Q_CHECK_PTR(w->button); w->button->lower(); if(win->icon() != NULL) w->button->setIcon(QIcon(*win->icon())); w->button->setText(win->icaption()); w->win = win; w->button->setCheckable(TRUE); connect(w->button, SIGNAL(toggled(bool)), win, SLOT(state(bool))); wlist.append(w); draw_buttons(); }
void showRenderBuffer() { int i; EGLContext eglContext; EGLDisplay eglDisplay; EGLSurface eglSurface; grs_font *font; JNIEnv *env; jclass clazz; jmethodID method; if (Want_pause) { // Save this in case we need to destroy it later eglContext = eglGetCurrentContext(); eglDisplay = eglGetCurrentDisplay(); eglSurface = eglGetCurrentSurface(EGL_DRAW); // Close digi so another application can use the OpenSL ES objects digi_close_digi(); (*jvm)->GetEnv(jvm, (void **) &env, JNI_VERSION_1_6); clazz = (*env)->FindClass(env, "tuchsen/descent/DescentView"); // Pause this thread method = (*env)->GetMethodID(env, clazz, "pauseRenderThread", "()V"); (*env)->CallVoidMethod(env, Descent_view, method); digi_init_digi(); if (Surface_was_destroyed) { // Purge all texture assets, since the EGL context will be blown away for (i = 0; i < MAX_FONTS; ++i) { font = Gamefonts[i]; glDeleteTextures(font->ft_maxchar - font->ft_minchar, font->ft_ogles_texes); memset(font->ft_ogles_texes, 0, (font->ft_maxchar - font->ft_minchar) * sizeof(GLuint)); } for (i = 0; i < MAX_BITMAP_FILES; ++i) { glDeleteTextures(1, &GameBitmaps[i].bm_ogles_tex_id); GameBitmaps[i].bm_ogles_tex_id = 0; } texmerge_close(); texmerge_init(50); glDeleteTextures(1, &nm_background.bm_ogles_tex_id); nm_background.bm_ogles_tex_id = 0; // Blow away EGL surface and context eglMakeCurrent(eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); eglDestroySurface(eglDisplay, eglSurface); eglDestroyContext(eglDisplay, eglContext); eglTerminate(eglDisplay); // Reset EGL context method = (*env)->GetMethodID(env, clazz, "initEgl", "()V"); (*env)->CallVoidMethod(env, Descent_view, method); (*env)->DeleteLocalRef(env, clazz); eglSurfaceAttrib(eglGetCurrentDisplay(), eglGetCurrentSurface(EGL_DRAW), EGL_SWAP_BEHAVIOR, EGL_BUFFER_PRESERVED); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Hack to show stuff like menus if (Game_mode != GM_NORMAL || In_screen) { mouse_handler(-1, -1, true); mouse_handler(-1, -1, false); } Surface_was_destroyed = false; } Want_pause = false; } else { draw_buttons(); eglSwapBuffers(eglGetCurrentDisplay(), eglGetCurrentSurface(EGL_READ)); can_save_screen = !can_save_screen; } }
void procbar::resizeEvent(QResizeEvent *) { draw_buttons(); }
int main() { #ifdef __MIPSEL__ create_app_dir(BASE_PATH); #endif if (SDL_Init(SDL_INIT_VIDEO) < 0) { log(FATAL, "Cannot init SDL."); } if (!(screen = SDL_SetVideoMode(WIDTH, HEIGHT, DEPTH, SDL_HWSURFACE | SDL_DOUBLEBUF))) { SDL_Quit(); log(FATAL, "Cannot SetVideoMode."); } SDL_ShowCursor(SDL_DISABLE); if (TTF_Init() < 0) { SDL_Quit(); log(FATAL, "Unable to start the TTF."); } int img_flags = IMG_INIT_PNG; if(!(IMG_Init(img_flags) & img_flags)) { TTF_Quit(); SDL_Quit(); log(FATAL, "SDL_image could not initialize. %s.", IMG_GetError()); } pconfig = new Config(); pconfig->load(); pmixer = new Mixer(); current_volume = pmixer->get_speaker_volume(); pmixer->set_speaker_volume(current_volume); load_resources(); draw_buttons(); draw_timer(0, 0, 0); draw_volume(); draw_vu(1, -1); draw_vu(1, 1); pmic = new Mic(); pmic->set_on_terminate_event(on_terminate_exec); pmic->set_on_vu_change_event(on_vu_changed); main_loop(); delete pmic; delete pmixer; delete pconfig; TTF_CloseFont(font_10); TTF_CloseFont(font_28); IMG_Quit(); TTF_Quit(); SDL_Quit(); return 0; }
void main_loop() { SDL_Event event; bool quit = false; SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL); while(!quit && SDL_WaitEvent(&event)) { switch(event.type) { case SDL_KEYDOWN: //case SDL_KEYUP: { SDLKey key = event.key.keysym.sym; switch (key) { case SELECT_BUTTON: quit = true; break; case A_BUTTON: if (is_playing) continue; if (is_recording) { pmic->stop(); } else { current_file = pconfig->get_new_file_name(); pmixer->set_direction(CAPTURE); pmic->capture(current_file, pconfig->get_file_type(), pconfig->get_file_format(), pconfig->get_channel(), pconfig->get_rate(), 0); } is_recording = !is_recording; draw_buttons(); break; case B_BUTTON: if (is_recording || current_file.empty()) continue; if (is_playing) { pmic->stop(); } else { pmixer->set_direction(PLAYBACK); pmic->play(current_file); } is_playing = !is_playing; draw_buttons(); break; case UP_BUTTON: if (current_volume < 100) { current_volume++; draw_volume(); pmixer->set_speaker_volume(current_volume); log(INFO, "Volume changed to %ld.", current_volume); } break; case DOWN_BUTTON: if (current_volume > 0) { current_volume--; draw_volume(); pmixer->set_speaker_volume(current_volume); log(INFO, "Volume changed to %ld.", current_volume); } break; default: log(INFO, "Invalid key."); break; } } break; case SDL_QUIT: /* window close */ quit = true; break; default: //log(INFO, "Invalid key."); break; } } }