void controller_base::play_slice(bool is_delay_enabled) { display& gui = get_display(); CKey key; events::pump(); events::raise_process_event(); events::raise_draw_event(); slice_before_scroll(); int mousex, mousey; Uint8 mouse_flags = SDL_GetMouseState(&mousex, &mousey); bool was_scrolling = scrolling_; scrolling_ = handle_scroll(key, mousex, mousey, mouse_flags); get_display().draw(); // be nice when window is not visible // NOTE should be handled by display instead, to only disable drawing if (is_delay_enabled && (SDL_GetAppState(gui.video().getWindow()) & SDL_APPACTIVE) == 0) { get_display().delay(200); } if (!scrolling_ && was_scrolling) { #if (defined(__APPLE__) && TARGET_OS_IPHONE) || defined(ANDROID) #else // scrolling ended, update the cursor and the brightened hex get_mouse_handler_base().mouse_update(browse_); #endif } slice_end(); }
bool litehtml::element::is_point_inside( int x, int y ) { if(get_display() != display_inline && get_display() != display_table_row) { position pos = m_pos; pos += m_padding; pos += m_borders; if(pos.is_point_inside(x, y)) { return true; } else { return false; } } else { position::vector boxes; get_inline_boxes(boxes); for(position::vector::iterator box = boxes.begin(); box != boxes.end(); box++) { if(box->is_point_inside(x, y)) { return true; } } } return false; }
bool controller_base::handle_scroll(CKey& key, int mousex, int mousey, int mouse_flags, double x_axis, double y_axis) { bool mouse_in_window = (SDL_GetAppState() & SDL_APPMOUSEFOCUS) != 0 || preferences::get("scroll_when_mouse_outside", true); bool keyboard_focus = have_keyboard_focus(); int scroll_speed = preferences::scroll_speed(); int dx = 0, dy = 0; int scroll_threshold = (preferences::mouse_scroll_enabled()) ? preferences::mouse_scroll_threshold() : 0; BOOST_FOREACH(const theme::menu& m, get_display().get_theme().menus()) { if (point_in_rect(mousex, mousey, m.get_location())) { scroll_threshold = 0; } } if ((key[SDLK_UP] && keyboard_focus) || (mousey < scroll_threshold && mouse_in_window)) { dy -= scroll_speed; } if ((key[SDLK_DOWN] && keyboard_focus) || (mousey > get_display().h() - scroll_threshold && mouse_in_window)) { dy += scroll_speed; } if ((key[SDLK_LEFT] && keyboard_focus) || (mousex < scroll_threshold && mouse_in_window)) { dx -= scroll_speed; } if ((key[SDLK_RIGHT] && keyboard_focus) || (mousex > get_display().w() - scroll_threshold && mouse_in_window)) { dx += scroll_speed; } if ((mouse_flags & SDL_BUTTON_MMASK) != 0 && preferences::middle_click_scrolls()) { const SDL_Rect& rect = get_display().map_outside_area(); if (point_in_rect(mousex, mousey,rect)) { // relative distance from the center to the border // NOTE: the view is a rectangle, so can be more sensible in one direction // but seems intuitive to use and it's useful since you must // more often scroll in the direction where the view is shorter const double xdisp = ((1.0*mousex / rect.w) - 0.5); const double ydisp = ((1.0*mousey / rect.h) - 0.5); // 4.0 give twice the normal speed when mouse is at border (xdisp=0.5) int speed = 4 * scroll_speed; dx += round_double(xdisp * speed); dy += round_double(ydisp * speed); } } dx += round_double( x_axis * scroll_speed); dy += round_double( y_axis * scroll_speed); return get_display().scroll(dx, dy); }
void controller_base::handle_mouse_up(const SDL_MouseButtonEvent& button) { display& disp = get_display(); // user maybe want to click at mini-map. so allow click out of main-map. get_mouse_handler_base().mouse_press(button, multi_gestures() || mouse_motions_, browse_); post_mouse_press(button); if (get_mouse_handler_base().get_show_menu()){ get_display().goto_main_context_menu(); } }
int main(int argc, char *argv[]) { TEST_START(); display = get_display(); /* get an appropriate EGL frame buffer configuration */ ECHK(eglChooseConfig(display, config_attribute_list, &config, 1, &num_config)); DEBUG_MSG("num_config: %d", num_config); /* create an EGL rendering context */ ECHK(context = eglCreateContext(display, config, EGL_NO_CONTEXT, context_attribute_list)); TEST(test_tex(0, 0, 0)); TEST(test_tex(0, 1, 0)); TEST(test_tex(1, 0, 0)); TEST(test_tex(1, 1, 0)); TEST(test_tex(1, 2, 0)); TEST(test_tex(2, 1, 0)); TEST(test_tex(2, 2, 0)); TEST(test_tex(0, 3, 0)); TEST(test_tex(3, 2, 0)); TEST(test_tex(3, 0, 1)); TEST(test_tex(0, 3, 1)); TEST(test_tex(3, 3, 1)); TEST(test_tex(1, 2, 1)); TEST(test_tex(2, 1, 1)); ECHK(eglTerminate(display)); TEST_END(); return 0; }
int litehtml::element::get_inline_shift_right() { int ret = 0; if(m_parent->get_display() == display_inline) { style_display disp = get_display(); if(disp == display_inline_text || disp == display_inline_block) { element* parent = m_parent; element* el = this; while(parent && parent->get_display() == display_inline) { if( parent->is_last_child_inline(el) ) { ret += parent->padding_right() + parent->border_right() + parent->margin_right(); } el = parent; parent = parent->m_parent; } } } return ret; }
void DisplayMessageQueue_X11::process_message() { std::shared_ptr<ThreadData> data = get_thread_data(); ::Display *display = get_display(); XEvent event; while (XPending(display) > 0) { XNextEvent(display, &event); for (auto & elem : data->windows) { X11Window *window = elem; if (window->get_window() == event.xany.window) { X11Window *mouse_capture_window = current_mouse_capture_window; if (mouse_capture_window == nullptr) mouse_capture_window = window; window->process_message(event, mouse_capture_window); } } } for (auto & elem : data->windows) { elem->process_message_complete(); } // Process all input context messages (done seperately, because of the mouse_capture hack) for (auto & elem : data->windows) { InputContext context = elem->get_ic(); context.process_messages(); } }
ScreenArea::ScreenArea(int _iWidth, int _iHeight, int _iScale) : m_iFilterScale(1) , m_vFilter2x(NULL) , m_vFilterIB(NULL) , m_puiPixels(NULL) , m_puiDelta(NULL) , m_iScaledWidth(_iWidth) , m_iScaledHeight(_iHeight) , m_bEnableRender(true) , m_bShowCursor(true) { g_assert(_iWidth >= 1 && _iHeight >= 1 && _iScale >= 1); m_iWidth = _iWidth; m_iHeight = _iHeight; m_iScale = _iScale; set_events(Gdk::EXPOSURE_MASK | Gdk::POINTER_MOTION_MASK | Gdk::ENTER_NOTIFY_MASK | Gdk::LEAVE_NOTIFY_MASK); Glib::RefPtr<Gdk::Pixbuf> pixbuf = Gdk::Pixbuf::create(Gdk::COLORSPACE_RGB, true, 8, 8, 8); pixbuf->fill(0); #if !GTK_CHECK_VERSION(3, 0, 0) m_poEmptyCursor = new Gdk::Cursor(get_display, pixbuf, 0, 0); #else m_poEmptyCursor = Gdk::Cursor::create(get_display(), pixbuf, 0, 0); #endif }
int main(){ printf("Lcd driver and lib demo\n"); display = get_display(); if (display == NULL) { printf("Failed to get display\n"); return -1; } disable_waiting_for_enter(); build_vars(); intro_animation(); char key = 0; int position = 0; while(running){ position = menu_selection(position); } clear_screen(); restore_terminal_settings(); release_display(display); }
void telnet_input_cb(evutil_socket_t sock, short ev, void *arg) { int id = * ((int*) arg); printf("input id %d\n", id); char buff[1]; static char s[100 + 30*DEFAULT_LENGTH]; int rcv; rcv = read(sock, buff, 1); if(rcv > 0) { if(buff[0] == 'a' || buff[0] == 'A') _r_id[id]++; if(buff[0] == 'q' || buff[0] == 'Q') _r_id[id]--; int size = get_display(s, rows, r_size, &(_r_id[id]), ROWS_NR); int t = write(sock, s, size); } else { _r_id[id] = 0; close(sock); event_del(telnet_descs[id].e); event_free(telnet_descs[id].e); telnet_descs[id].e = NULL; telnet_descs[id].sock = 0; } }
void AppWindow::on_button_previous(void) { #ifdef DEBUG std::cout << "ON_BUTTON_PREVIOUS: Previous file \n"; #endif busy(true); ImageBox.LoadImage( ImageManager.get_previous_file(), &scalefactor, (int)h_scroller->get_page_size(), (int)v_scroller->get_page_size()); set_title( "gimmage: " + ImageManager.get_current_file() ); set_buttons_active( ImageBox.is_loaded() ); set_filechooser_dir(); // flush the queue so that the image is displayed // even if the user presses and holds the backspace key get_display()->flush(); // since we now have a new image, let's make sure the save button is off! Button_Save.set_sensitive( false ); busy(false); }
void telnet_cb(evutil_socket_t sock, short ev, void *arg) { static char s[100 + 30*DEFAULT_LENGTH]; fflush(stdout); int i; int msgsock = accept(sock, (struct sockaddr*)0, (socklen_t*)0); delay_t *delays; int d_size; for(i = 0; i < MAX_TELNET; ++i) { if(telnet_descs[i].e == NULL) break; } _r_id[i] = 0; telnet_descs[i].id = i; telnet_descs[i].sock = msgsock; get_delays(&delays, &d_size); prepare_rows(&rows, &r_size, &r_max, delays, d_size, 0, DEFAULT_LENGTH); int size = get_display(s, rows, r_size, &(_r_id[i]), ROWS_NR); write(telnet_descs[i].sock, s, size); telnet_descs[i].e = event_new(main_loop, msgsock, EV_READ|EV_PERSIST, telnet_input_cb, (void *) &(telnet_descs[i].id)); event_add(telnet_descs[i].e, NULL); }
void command_executor_default::map_screenshot() { make_screenshot(_("Map-Screenshot"), get_video(), [this](const std::string& filename, const CVideo&) { return get_display().screenshot(filename, true); }); }
platform_display_type insert<display_number_t>(display_t& display, platform_display_type& parent, display_number_t& element) { HWND parent_hwnd(parent); element.initialize(parent_hwnd); return display.insert(parent, get_display(element)); }
int main(int argc, char *argv[]) { GLint width, height; EGLint pbuffer_attribute_list[] = { EGL_WIDTH, 256, EGL_HEIGHT, 256, EGL_LARGEST_PBUFFER, EGL_TRUE, EGL_NONE }; const EGLint config_attribute_list[] = { EGL_RED_SIZE, 8, EGL_GREEN_SIZE, 8, EGL_BLUE_SIZE, 8, EGL_SURFACE_TYPE, EGL_PBUFFER_BIT, EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, EGL_DEPTH_SIZE, 8, EGL_NONE }; const EGLint context_attribute_list[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE }; EGLDisplay display; EGLConfig config; EGLint num_config; EGLContext context; EGLSurface surface; int i; display = get_display(); /* get an appropriate EGL frame buffer configuration */ ECHK(eglChooseConfig(display, config_attribute_list, &config, 1, &num_config)); DEBUG_MSG("num_config: %d", num_config); /* create an EGL rendering context */ ECHK(context = eglCreateContext(display, config, EGL_NO_CONTEXT, context_attribute_list)); ECHK(surface = eglCreatePbufferSurface(display, config, pbuffer_attribute_list)); ECHK(eglQuerySurface(display, surface, EGL_WIDTH, &width)); ECHK(eglQuerySurface(display, surface, EGL_HEIGHT, &height)); DEBUG_MSG("PBuffer: %dx%d", width, height); /* connect the context to the surface */ ECHK(eglMakeCurrent(display, surface, surface, context)); GCHK(glFlush()); for (i = 0; ; i++) { if (test_compiler(i)) { break; } } ECHK(eglDestroySurface(display, surface)); ECHK(eglTerminate(display)); }
egl_display_t* validate_display(EGLDisplay dpy) { egl_display_t * const dp = get_display(dpy); if (!dp) return setError(EGL_BAD_DISPLAY, (egl_display_t*)NULL); if (!dp->isReady()) return setError(EGL_NOT_INITIALIZED, (egl_display_t*)NULL); return dp; }
static void test_mipmap(int maxlevels, int w, int h, unsigned filt) { RD_START("mipmap", "maxlevels=%d, texsize=%dx%d", maxlevels, w, h); display = get_display(); /* get an appropriate EGL frame buffer configuration */ ECHK(eglChooseConfig(display, config_attribute_list, &config, 1, &num_config)); DEBUG_MSG("num_config: %d", num_config); /* create an EGL rendering context */ ECHK(context = eglCreateContext(display, config, EGL_NO_CONTEXT, context_attribute_list)); surface = make_window(display, config, 400, 240); ECHK(eglQuerySurface(display, surface, EGL_WIDTH, &width)); ECHK(eglQuerySurface(display, surface, EGL_HEIGHT, &height)); DEBUG_MSG("Buffer: %dx%d", width, height); /* connect the context to the surface */ ECHK(eglMakeCurrent(display, surface, surface, context)); programObject = get_program(vShaderStr, fShaderStr); link_program(programObject); // Get the attribute locations GCHK(positionLoc = glGetAttribLocation(programObject, "a_position")); GCHK(texCoordLoc = glGetAttribLocation(programObject, "a_texCoord")); // Get the sampler location GCHK(samplerLoc = glGetUniformLocation(programObject, "s_texture")); // Get the offset location GCHK(offsetLoc = glGetUniformLocation(programObject, "u_offset")); // Load the texture GCHK(textureId = CreateMipMappedTexture2D(maxlevels, w, h, filt)); GCHK(glClearColor(0.0f, 0.0f, 0.0f, 0.0f)); GCHK(Draw()); ECHK(eglSwapBuffers(display, surface)); GCHK(glFlush()); #ifndef BIONIC sleep(5); #endif ECHK(eglDestroySurface(display, surface)); #ifdef BIONIC ECHK(eglTerminate(display)); #endif RD_END(); }
egl_display_ptr validate_display(EGLDisplay dpy) { egl_display_ptr dp = get_display(dpy); if (!dp) return setError(EGL_BAD_DISPLAY, egl_display_ptr(NULL)); if (!dp->isReady()) return setError(EGL_NOT_INITIALIZED, egl_display_ptr(NULL)); return dp; }
int main(){ printf("Get display\n"); display = get_display(); if (display == NULL) { printf("Failed to get display\n"); return -1; } //lcd_load_bmp("blani.bmp", display); lcd_load_bmp("blani.bmp", display); getc(stdin); lcd_set_bmp(0,0,display); getc(stdin); lcd_backlight(LCD_OFF, display); getc(stdin); lcd_backlight(LCD_ON, display); getc(stdin); lcd_sleep(LCD_ON, display); getc(stdin); lcd_sleep(LCD_OFF, display); getc(stdin); lcd_onoff(LCD_OFF, display); getc(stdin); lcd_onoff(LCD_ON, display); getc(stdin); printf("Lcd rect\n"); lcd_set_rect(20, 20, 50, 50, NOFILL, WHITE, display); getc(stdin); lcd_set_rect(20, 60, 50, 90, NOFILL, RED, display); getc(stdin); lcd_set_rect(60, 20, 90, 50, NOFILL, BLUE, display); getc(stdin); lcd_set_rect(60, 60, 90, 90, NOFILL, ORANGE, display); getc(stdin); // printf("Lcd pixel\n"); // lcd_set_pixel(100, 100, WHITE, display); lcd_set_line(2,0, 20, 78, RED, display); getc(stdin); lcd_set_line(30,19, 98, 34, BLUE, display); getc(stdin); lcd_set_line(129,129, 20, 60, GREEN, display); getc(stdin); lcd_put_str("Test str 1\n", 10, 10, SMALL, YELLOW, display); getc(stdin); lcd_put_str("Test str 2\n", 30, 10, MEDIUM, GREEN, display); getc(stdin); lcd_put_str("Test str 3\n", 50, 10, LARGE, ORANGE, display); getc(stdin); printf("Release display\n"); release_display(display); }
void command_executor_default::lua_console() { if (get_display().in_game()) { gui2::tlua_interpreter::display(get_video(), gui2::tlua_interpreter::GAME); } else { command_executor::lua_console(); } }
void test_piglit(void) { RD_START("piglit-good", ""); display = get_display(); /* get an appropriate EGL frame buffer configuration */ ECHK(eglChooseConfig(display, config_attribute_list, &config, 1, &num_config)); DEBUG_MSG("num_config: %d", num_config); /* create an EGL rendering context */ ECHK(context = eglCreateContext(display, config, EGL_NO_CONTEXT, context_attribute_list)); surface = make_window(display, config, 250, 250); ECHK(eglQuerySurface(display, surface, EGL_WIDTH, &width)); ECHK(eglQuerySurface(display, surface, EGL_HEIGHT, &height)); DEBUG_MSG("Buffer: %dx%d", width, height); /* connect the context to the surface */ ECHK(eglMakeCurrent(display, surface, surface, context)); program = get_program(vertex_shader_source, fragment_shader_source); GCHK(glBindAttribLocation(program, 0, "vertex")); link_program(program); GCHK(glViewport(0, 0, width, height)); /* clear the color buffer */ GCHK(glClearColor(0.5, 0.5, 0.5, 0.5)); GCHK(glClear(GL_COLOR_BUFFER_BIT)); GCHK(glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 0, (GLfloat[]){ 20.0, 5.0, 0.0, 1.0, 30.0, 5.0, 0.0, 1.0, 20.0, 15.0, 0.0, 1.0, 30.0, 15.0, 0.0, 1.0 })); GCHK(glEnableVertexAttribArray(0)); /* now set up our uniforms. */ GCHK(uniform_location = glGetUniformLocation(program, "row")); GCHK(glUniform1i(uniform_location, 1)); GCHK(uniform_location = glGetUniformLocation(program, "expect")); GCHK(glUniform1fv(uniform_location, 1, (GLfloat[]){ 4 })); GCHK(glDrawArrays(GL_TRIANGLE_STRIP, 0, 4)); ECHK(eglSwapBuffers(display, surface)); GCHK(glFlush()); usleep(1000000); eglTerminate(display); RD_END(); }
bool litehtml::element::is_inline_box() const { style_display d = get_display(); if( d == display_inline || d == display_inline_block || d == display_inline_text) { return true; } return false; }
bool controller_base::finger_coordinate_valid(int x, int y) const { const display& disp = get_display(); if (!point_in_rect(x, y, disp.map_outside_area())) { return false; } if (disp.point_in_volatiles(x, y)) { return false; } return true; }
void Background::_update_uniforms() { Display *display = get_display(); // setup the modelview and projection matrices if (display != nullptr) { display->update_programmable_projection(_shader_program); display->update_programmable_viewport(_shader_program); } glUniformMatrix4fv(_modelview_uniform, 1, GL_FALSE, Util::identity_matrix().data()); glUniform4fv(_begin_color_uniform, 1, _begin_color.data()); glUniform4fv(_end_color_uniform, 1, _end_color.data()); }
void AppWindow::busy(bool showwatch) { if( showwatch ) { get_window()->set_cursor(Watch); // indicate that we're working ImageBox.get_window()->set_cursor(Watch); get_display()->flush(); } else { get_window()->set_cursor(); ImageBox.get_window()->set_cursor(); } }
menuItem* yesNoItem::do_action() { display *lcd; uint8_t value; uint8_t button; lcd = get_display(); value = *_variable; do { lcd->clear(); get_question(buffer); lcd->print(buffer); if(value) { strcpy_P(buffer, yes_sel); } else { strcpy_P(buffer, yes_unsel); } lcd->setCursor(0, 2); lcd->print(buffer); if(value) { strcpy_P(buffer, no_unsel); } else { strcpy_P(buffer, no_sel); } lcd->setCursor(0, 3); lcd->print(buffer); // wait for some useful key do{ button = buttons_reader.read(); } while(button == IDLE); if(button == UP) { value = 1; } else if(button == DOWN) { value = 0; } } while(button == UP || button == DOWN); // if not "cancel", save value if(button != LEFT) { *_variable = value; } return 0; }
void statistics_dialog::action(gui::dialog_process_info &dp_info) { int sel = get_menu().selection(); bool has_details = sel < 5 && sel >= 0 && unit_count_[sel] > 0; detail_btn_->enable(has_details); if(dp_info.double_clicked && has_details) { set_result(sel); } else if(dp_info.new_key_down && !dp_info.key_down) { set_result(gui::CLOSE_DIALOG); } // Prepare the sub-dialog for Statistic Details std::string title; std::vector<std::string> items_sub; switch(result()) { case gui::CLOSE_DIALOG: break; case 0: items_sub = create_unit_table(stats_.recruits, team_num_); title = _("Recruits"); break; case 1: items_sub = create_unit_table(stats_.recalls, team_num_); title = _("Recalls"); break; case 2: items_sub = create_unit_table(stats_.advanced_to, team_num_); title = _("Advancements"); break; case 3: items_sub = create_unit_table(stats_.deaths, team_num_); title = _("Losses"); break; case 4: items_sub = create_unit_table(stats_.killed, team_num_); /** @todo FIXME? Perhaps killed units shouldn't have the same team-color as your own. */ title = _("Kills"); break; default: break; } if (items_sub.empty() == false) { gui::dialog d(get_display(), title + " (" + player_name_ + ")", "", gui::CLOSE_ONLY); d.set_menu(items_sub); d.show(); dp_info.clear_buttons(); set_result(gui::CONTINUE_DIALOG); } }
void Nodelist::activate_open_rtmon() { char node_name[80]; int sts; char display[80]; sts = nodelistnav->get_selected_node( node_name); if ( EVEN(sts)) { nodelistnav->wow->DisplayError( "Open Xtt", "Select a node"); return; } get_display( display); statussrv_RtMonStart( node_name, "", display, remote_gui); }
int main(int argc, char *argv[]) { display = get_display(); /* get an appropriate EGL frame buffer configuration */ ECHK(eglChooseConfig(display, config_attribute_list, &config, 1, &num_config)); DEBUG_MSG("num_config: %d", num_config); /* create an EGL rendering context */ ECHK(context = eglCreateContext(display, config, EGL_NO_CONTEXT, context_attribute_list)); test_stencil(); ECHK(eglTerminate(display)); }
void controller_base::execute_action(const std::vector<std::string>& items_arg, int xloc, int yloc, bool context_menu) { std::vector<std::string> items; BOOST_FOREACH(const std::string& item, items_arg) { const hotkey::hotkey_command& command = hotkey::get_hotkey_command(item); if(can_execute_command(command)) items.push_back(item); } if(items.empty()) return; command_executor::execute_action(items, xloc, yloc, context_menu, get_display()); }