// ------------------------------------------------------------------------ // window to display an adventure map // ------------------------------------------------------------------------ void t_adventure_map_window::on_size_change( t_screen_rect const& rect ) { bool size_changed = (m_back_buffer == 0); if (get_screen_rect().height() != rect.height() || get_screen_rect().width() != rect.width()) size_changed = true; if (size_changed) { t_screen_point view_pos = get_view_pos(); t_map_renderer::move_view( view_pos, t_screen_point( rect.width(), rect.height() ) ); get_frame()->resize_view(rect); } }
QWindowSystemInterface::TouchPoint& tuio_impl::fill_qws_touch_point(const tuio::touch_point& tuio_tp, QWindowSystemInterface::TouchPoint& qws_tp) { qws_tp.id = tuio_tp.session_id; /// The TUIO touch point arrives in normalized hardware coordinates const QRectF screenRect = get_screen_rect(); //const QRectF winRect = get_window_rect(); // Generate a screen position that is always within the active window // const qreal // xScaleFactor = screenRect.width() / winRect.width(), // yScaleFactor = screenRect.height() / winRect.height(); const QPointF screenPos(tuio_tp.position.x * screenRect.width(), tuio_tp.position.y * screenRect.height()); // QWindowSystemInterface::TouchPoint wants the normalPosition in normalized touch device coordinates (same as TUIO) qws_tp.normalPosition = QPointF(tuio_tp.position.x, tuio_tp.position.y); // QWindowSystemInterface::TouchPoint wants the area in screen coordinates qws_tp.area = QRectF(0, 0, tuio_tp.dims.width * screenRect.width(), tuio_tp.dims.height * screenRect.height()); qws_tp.area.moveCenter(screenPos); qws_tp.pressure = tuio_tp.area; // again, the velocity is reported in the screen coordinate system (pixels per second) qws_tp.velocity = QVector2D(tuio_tp.velocity.X * screenRect.width(), tuio_tp.velocity.Y * screenRect.height()); if (tuio_tp.type == tuio::token_touch) { qws_tp.flags = QTouchEvent::TouchPoint::Pen; } QVector<QPointF> myRawPositions = qws_tp.rawPositions; myRawPositions << screenPos; qws_tp.rawPositions = myRawPositions; return qws_tp; }
// ---------------------------------------------------------------------- // window which displays a bitmap buffer // ---------------------------------------------------------------------- void t_buffer_window::set_bitmap( t_image_buffer const& bitmap ) { if (bitmap.get_bitmap() == m_bitmap.get_bitmap()) return; m_bitmap = bitmap; move_screen_rect( get_screen_rect().top_left() + bitmap.get_bitmap()->get_rect() ); invalidate(); }
void SpriteNode::mark(SceneGraph* graph) { if (has_changed_) { graph->mark_screen_region(this, get_old_screen_rect()); graph->mark_screen_region(this, get_screen_rect()); } }
QRectF tuio_impl::get_window_rect() { #if 0 // qevdevtouch has this "m_forceToActiveWindow" member; not sure why... if (m_forceToActiveWindow) { if (QWindow *win = QGuiApplication::focusWindow()) { return win->geometry(); } } #endif return get_screen_rect(); }
void init( float normsize, bool fullscreen ) { static struct on { on() { glfwInit(); } ~on() { glfwTerminate(); } } _; auto rect = get_screen_rect(); screen_w = rect.first; screen_h = rect.second; { // reinit :P normsize = ( normsize <= 0 ? 1 : normsize ); w = screen_w * normsize; h = screen_h * normsize; } #if 0 //wglSwapIntervalEXT(1); glfwOpenWindowHint( GLFW_ACCUM_RED_BITS, 16 ); glfwOpenWindowHint( GLFW_ACCUM_GREEN_BITS, 16 ); glfwOpenWindowHint( GLFW_ACCUM_BLUE_BITS, 16 ); glfwOpenWindowHint( GLFW_ACCUM_ALPHA_BITS, 16 ); if( glfwOpenWindow( w, h, 0,0,0,0,0,0, fullscreen ? GLFW_FULLSCREEN : GLFW_WINDOW ) != GL_TRUE ) { std::cerr << "<gate/gate.hpp> says: Cant create " << w << 'x' << h << " window!" << std::endl; exit(1); } #endif window = glfwCreateWindow(w, h, title.c_str(), NULL, NULL); if (!window) { glfwTerminate(); std::cerr << "<gate/gate.hpp> says: Cant create " << w << 'x' << h << " window!" << std::endl; exit(1); } glfwMakeContextCurrent(window); glfwSetWindowTitle( window, title.c_str() ); resize( w, h ); init_glew(); glInit(); }
// ------------------------------------------------------------------ // window for a bitmap-based mouse // on adding child, expand to include child's extents. // ------------------------------------------------------------------ void t_mouse_window::add_child( t_window* window ) { t_window::add_child( window ); t_screen_rect rect = get_screen_rect(); if (rect.height() == 0) rect = window->get_screen_rect(); else rect = get_extent( rect, window->get_screen_rect() ); // change window's size. move_screen_rect( rect, false ); }
// -------------------------------------------------------- // change the bitmap // -------------------------------------------------------- void t_bitmap_layer_window::set_bitmap( t_bitmap_layer const* bitmap, bool use_offset ) { t_screen_point point = get_parent()->to_client( get_screen_rect().top_left() ); if (use_offset) { if (m_bitmap != 0) point -= m_bitmap->get_rect().top_left(); } else { if (bitmap != 0) point -= bitmap->get_rect().top_left(); } set_bitmap( bitmap, point ); }
BoxCutterWindow(HINSTANCE hinst, const char *title, const char* filename) : m_active(true), m_drag(false), m_draw(false), m_filename(filename), m_have_coords(false) { // fill wndclass structure WNDCLASS wc; strcpy(m_class_name, g_class_name); wc.hInstance = hinst; wc.lpszClassName = m_class_name; wc.lpszMenuName = ""; wc.lpfnWndProc = WindowProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.style = CS_HREDRAW | CS_VREDRAW; wc.hbrBackground = 0; //(HBRUSH) GetStockObject(WHITE_BRUSH); wc.hCursor = LoadCursor(0, IDC_CROSS); wc.hIcon = LoadIcon(0, IDI_APPLICATION); // register class ATOM class_atom = RegisterClass(&wc); // determine screen dimensions RECT rect; get_screen_rect(&rect); // create window DWORD exstyle = WS_EX_TRANSPARENT; DWORD style = WS_POPUP; // set this window as the receiver of messages g_win = this; m_handle = CreateWindowEx(exstyle, m_class_name, title, style, // dimensions 0, 0, rect.right, rect.bottom, 0, // no parent 0, // no menu hinst, //module_instance, NULL); }
int main(int argc, char **argv) { HINSTANCE hInstance = (HINSTANCE)GetModuleHandle(NULL); InitCommonControls(); setup_console(); // default screenshot filename char *filename = NULL; // coordinates bool use_coords = false; int x1, y1, x2, y2; // parse command line int i; // parse options for (i=1; i<argc; i++) { if (argv[i][0] != '-') // argument is not an option break; else if (strcmp(argv[i], "-f") == 0 || strcmp(argv[i], "--fullscreen") == 0) { RECT rect; get_screen_rect(&rect); x1 = rect.left; y1 = rect.top; x2 = rect.right; y2 = rect.bottom; use_coords = true; } else if (strcmp(argv[i], "-c") == 0 || strcmp(argv[i], "--coords") == 0) { if (i+1 >= argc) { printf("error: expected argument for -c,--coord\n"); usage(); return 1; } if (sscanf(argv[++i], "%d,%d,%d,%d", &x1, &y1, &x2, &y2) != 4) { printf("error: expected 4 comma separated integers\n"); usage(); return 1; } use_coords = true; } else if (strcmp(argv[i], "-v") == 0 || strcmp(argv[i], "--version") == 0) { // display version information version(); return 1; } else if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0) { // display help info usage(); return 1; } else { printf("error: unknown option '%s'\n", argv[i]); usage(); return 1; } } // argument after options is a filename if (i < argc) filename = argv[i]; // create screenshot window BoxCutterWindow win(hInstance, "BoxCutter", filename); if (use_coords) { win.show(); } else { // manually acquire coordinates win.show(); win.maximize(); win.activate(); main_loop(&win); if (win.have_coords()) { win.get_coords(&x1, &y1, &x2, &y2); } else { printf("error: cannot retrieve screenshot coordinates\n"); return 1; } } // display screenshot coords printf("screenshot coords: (%d,%d)-(%d,%d)\n", x1, y1, x2, y2); // save bitmap if (filename) { // save to file if (!capture_screen(filename, x1, y1, x2, y2)) { MessageBox(win.get_handle(), "Cannot save screenshot", "Error", MB_OK); return 1; } printf("screenshot saved to file: %s\n", filename); } else { // save to clipboard if (!capture_screen_clipboard(win.get_handle(), x1, y1, x2, y2)) { MessageBox(win.get_handle(), "Cannot save screenshot to clipboard", "Error", MB_OK); return 1; } printf("screenshot saved to clipboard.\n"); } win.close(); return 0; }
// ------------------------------------------------------------------ // window for a bitmap-based mouse // open for display // ------------------------------------------------------------------ void t_mouse_window::open() { t_window::open( get_screen_rect(), get_main_window() ); }