void Abstract::doGuardFinalize() { if (pArea && pArea->background == gfx->glfond) pArea->background = 0; doFinalize(); reset_keyboard(); clear_keybuf(); reset_mouse(); }
bool Abstract::doGuardInitialize() { pMouseX = -1; pMouseY = -1; pMouseZ = -1; pMouseB = -1; cursor_type = CURSOR_DEFAULT; reset_keyboard(); reset_mouse(); clear_keybuf(); bool r = doInitialize(); return r; }
void start_freehand_drawing(void) { FreehandGeometry geometry; int oldmouse_x, oldmouse_y; int offsetx = cxoff + canvas->get_absxpos(); int offsety = cyoff + canvas->get_absypos(); //SDL_Surface *sur = canvas->get_image(canvas->get_active_image_n()); SDL_Surface *behind = SDLGui::createSurface(screen->w, screen->h); blit(screen, behind, 0, 0, 0, 0, screen->w, screen->h); SDL_Event event; oldmouse_x = mouse.x; oldmouse_y = mouse.y; unsigned processed = 0; StlStroke& stroke = *(geometry.currStroke); while(mouse.b == SDL_BUTTON_LEFT) { // Update the screen with the last round of geometry read from the // event queue. SDL_PumpEvents(); for (unsigned i = processed; i < stroke.size(); i++) { if (i == 0) { //putpixel(screen, stroke[i].x + offsetx, // stroke[i].y + offsety, BLACK); continue; } aalineRGBA(screen, (int) stroke[i - 1].x + offsetx, (int) stroke[i - 1].y + offsety, (int) stroke[i].x + offsetx, (int) stroke[i].y + offsety, 0, 0, 0, 128); processed++; } SDL_PumpEvents(); SDL_Flip(screen); // Wait for a new event. SDL_WaitEvent(&event); // Process all events in the queue. do { switch (event.type) { case SDL_MOUSEMOTION: mouse.x = event.motion.x; mouse.y = event.motion.y; if ((oldmouse_x != mouse.x) || (oldmouse_y != mouse.y)) { geometry.addPoint(mouse.x - offsetx, mouse.y - offsety); oldmouse_x = mouse.x; oldmouse_y = mouse.y; } break; case SDL_MOUSEBUTTONUP: mouse.b = 0; break; case SDL_QUIT: mouse.kill_sig = 1; break; default: break; } } while ((mouse.b != 0) && SDL_PollEvent(&event)); } //qDebug("Points: %d", (int) points.size()); SDL_FastBlit(behind, screen, 0, 0, 0, 0, screen->w, screen->h); SDL_FreeSurface(behind); if (lastFreehand == NULL) { strokeTimerID = SDL_AddTimer(strokeTimeout, freehand_timer_callback, NULL); lastFreehand = new Freehand(geometry); // Visibility graph stuff: visalgo->obj_add(lastFreehand); //QT canvas_deselect_shapes(); } else { SDL_RemoveTimer(strokeTimerID); strokeTimerID = SDL_AddTimer(strokeTimeout, freehand_timer_callback, NULL); lastFreehand->addStroke(geometry); visalgo->obj_resize(lastFreehand); } #if defined(__APPLE__) // After using carbon for mouse input, we need to resync the sdl mouse. GUI_DummyMouseEvent(); while(SDL_PollEvent(&event)); // noop; reset_mouse(); mouse.bstate = mouse.b = 0; #endif repaint_canvas(); }