/** @brief Main in-game rendering routine. * * @param b Board configuration to render. */ void draw_scene(board_t *b, GLuint fb, int reflections) { char temp[80]; int clock_seconds = 0; int clock_minutes = 0; glBindFramebuffer(GL_FRAMEBUFFER, fb); transition_update(); gg_dialog_cleanup(); glDisable(GL_BLEND); glDepthFunc(GL_ALWAYS); draw_backdrop(); glEnable(GL_BLEND); glDepthFunc(GL_LEQUAL); go_3d(get_screen_width(), get_screen_height()); render_scene_3d(b, fb, reflections); mouse_square = find_square(get_true_mouse_x(), get_true_mouse_y()); glBindFramebuffer(GL_FRAMEBUFFER, fb); resize_window(get_screen_width(), get_screen_height()); glPushMatrix(); draw_ui_elements(); // draw_move_list(get_col(COL_WHITE), get_col(COL_YELLOW)); // draw_capture_list(get_col(COL_WHITE)); clock_minutes = (((SDL_GetTicks() - get_turn_counter()) / 1000) / 60); clock_seconds = ((SDL_GetTicks() - get_turn_counter()) / 1000) - (clock_minutes * 60); snprintf(temp, sizeof(temp), "%i:%02i", clock_minutes, clock_seconds); /*text_draw_string( 303, 440, temp, 1, &col_black);*/ glPopMatrix(); /*if ( get_white_in_check() == TRUE ) text_draw_string_bouncy( 180, 420, "White is in check!", 1, get_col(COL_WHITE)); else if ( get_black_in_check() == TRUE ) text_draw_string_bouncy( 180, 420, "Black is in check!", 1, get_col(COL_WHITE));*/ gg_dialog_render_all(); if (get_fading_out()) { if (!draw_fade(FADE_OUT)) set_switch_to_menu(TRUE); } else { if (get_show_egg()) draw_sonic_fade(FADE_IN); else draw_fade(FADE_IN); } /* Draw mouse cursor.. */ draw_texture(get_mouse_cursor(), get_mouse_x(), (479 - get_mouse_y() - 32), 32, 32, 1.0f, get_col(COL_WHITE)); }
int main(int argc, char* argv[]) { create_image_world(); int image = create_image(100, 100); for(int x = 0; x < 100; x++) { for(int y = 0; y < 100; y++) { if (x == y) { set_pixel(image, x, y, 255, 0, 0, 255); } else if (x+y == 100) { set_pixel(image, x, y, 255, 255, 0, 0); } else { set_pixel(image, x, y, 255, 0, 255, 0); } } } put_image(image, get_screen_width()/2-get_image_width(image)/2, get_screen_height()/2-get_image_height(image)/2); return p1world_shutdown(); }
void mouse_input(int button, int state, int x, int y) { unsigned char pixelrgb[4]; unsigned int distance; //printf("mouse button: %i state: %i position (%i,%i)\n", button, state, x, y); last_position.button = button; last_position.state = state; last_position.x = x; last_position.y = y; if (button == LEFT_MOUSE && state == MOUSE_DOWN) ray_test(glm::vec2(x,y), glm::vec2(get_screen_width(), get_screen_height())); else if( button == MIDDLE_MOUSE && state == MOUSE_DOWN) { glReadPixels(x, get_screen_height() - y - 1, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, (unsigned char *)pixelrgb); glReadPixels( x, get_screen_height() - y - 1, 1, 1, GL_DEPTH_COMPONENT, GL_INT, &distance ); printf("(%u, %u, %u, %u) Distance: %i\n", pixelrgb[0], pixelrgb[1], pixelrgb[2], pixelrgb[3], distance); } }
static float get_area_ui_object_virtual_y (ui_object *obj) { area_ui_object *area; float py = 0; ui_object *parent; if (get_ui_object_virtual_coords (obj)) { // is this right ? check parent = get_ui_object_parent (obj); if (parent) { //py = get_ui_object_virtual_y (parent); } area = (area_ui_object *) obj->data; return area->y_start + py; } else { float y; ui_object *parent; parent = get_ui_object_parent (obj); if (parent) { y = (get_ui_object_y (obj) - get_ui_object_y (parent)) / get_ui_object_y_size (parent); } else { y = get_ui_object_y (obj) / get_screen_height (video_screen); } return y; } }
int main(int argc, char* argv) { turn_on_debug_output(); create_image_world(); // Write your code here int v = load_bmp("plane.bmp"); put_image(v, (get_screen_width() / 2) - (get_image_width(v) / 2), (get_screen_height() / 2) - (get_image_height(v) / 2)); return p1world_shutdown(); }
void Video_GL::render_all() { assert(!m_render_target); #ifdef _WINDOWS glFlush(); #else glFinish(); #endif get_Textures().unlose_resources(); get_Fonts().unlose_resources(); get_Game().prerender(); glViewport(0, 0, get_screen_width(), get_screen_height()); if(!is_zwrite_enabled()) glDepthMask(GL_TRUE); set_clear_color_impl(get_clear_color()); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); if(!is_zwrite_enabled()) glDepthMask(GL_FALSE); get_Game().render(); /*** Begin CPU saver ***/ #ifdef MANUAL_GL_VSYNC_DELAY Timer &tr = get_Timer(); if(get_vertical_sync()) { Time buffer_swap_start_time = tr.get_time(); const unsigned int time_allowed = 1000u/60u - 2u; const unsigned int new_time_taken = buffer_swap_start_time.get_ticks_since(m_buffer_swap_end_time); m_time_taken = (1.0f - m_weight_new) * m_time_taken + m_weight_new * new_time_taken; if(m_time_taken < time_allowed) SDL_Delay(static_cast<unsigned int>(time_allowed - m_time_taken)); } #endif /// Swap the buffers <-- NOT part of the CPU saver, but the reason it is "needed" #if SDL_VERSION_ATLEAST(1,3,0) SDL_GL_SwapWindow(get_window()); #else SDL_GL_SwapBuffers(); #endif #ifdef MANUAL_GL_VSYNC_DELAY m_buffer_swap_end_time = tr.get_time(); #endif }
/* How many groups *could* fit on the screen? */ unsigned int groups_possible(void) { unsigned int num_columns, column_height, num_rows; const struct electorate *voter_electorate; voter_electorate = get_voter_electorate(); num_columns = get_groups_across(voter_electorate); column_height = get_group_height(voter_electorate); /* We want to round UP, not down */ num_rows = (get_screen_height() - get_ballot_h_height(voter_electorate) + column_height-1) / column_height; return num_rows * num_columns; }
void asgtk_image_view_screen_aspect_toggle (GtkWidget * checkbutton, gpointer data) { ASGtkImageView *iv = ASGTK_IMAGE_VIEW (data); if (GTK_TOGGLE_BUTTON (checkbutton)->active) { asgtk_image_view_set_aspect (iv, get_screen_width (NULL), get_screen_height (NULL)); asgtk_image_view_set_resize (iv, ASGTK_IMAGE_VIEW_TILE_TO_ASPECT, ASGTK_IMAGE_VIEW_TILE_TO_ASPECT); } else { asgtk_image_view_set_aspect (iv, -1, -1); asgtk_image_view_set_resize (iv, 0, ASGTK_IMAGE_VIEW_TILE_TO_ASPECT); } }
void Video_DX9::render_all() { assert(!m_render_target); static bool reset = false; if(reset) { const HRESULT result = m_d3d_device->TestCooperativeLevel(); if(result == D3DERR_DEVICELOST) return; else if(result == D3DERR_DRIVERINTERNALERROR) throw Video_Device_Failure(); if(result == D3DERR_DEVICENOTRESET) { if(FAILED(m_d3d_device->Reset(&m_d3d_parameters))) throw Video_Device_Failure(); reset = false; init_context(); } } get_Textures().unlose_resources(); get_Fonts().unlose_resources(); HRESULT result = m_d3d_device->Present(0, 0, 0, 0); if(result == S_OK) { D3DVIEWPORT9 vp = {0, 0, DWORD(get_screen_width()), DWORD(get_screen_height()), 0, 1}; m_d3d_device->SetViewport(&vp); m_d3d_device->Clear(0, 0, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(get_clear_color().r_ub(), get_clear_color().g_ub(), get_clear_color().b_ub()), 1.0f, 0); m_d3d_device->BeginScene(); get_Game().render(); m_d3d_device->EndScene(); } else if(result == D3DERR_DEVICELOST) { reset = true; return; } else if(result == D3DERR_DEVICEREMOVED) { throw Video_Device_Failure(); } }
TS_DefaultOnStartSelecting(TS* ts) { HWND hwnd = HWND_FROM_TS(ts); HDC hdc; RECT rect; int max_width; int max_height; int screen_width; int screen_height; int i; hdc = GetDC(hwnd); if (hdc == NULL) { FAILURE(T("TS_DefaultOnStartSelecting/GetDC")); return !0; } ZeroMemory(&rect, sizeof(rect)); max_height = 2; max_width = 2; for (i = 0; i < g_TaskList->count; i++) { DrawText( hdc, g_TaskList->list[i]->title, -1, &rect, DT_CALCRECT | DT_NOPREFIX | DT_SINGLELINE ); if (max_height < rect.bottom) max_height = rect.bottom; if (max_width < rect.right) max_width = rect.right; } resize( hwnd, 2 + max_width + 2, 2 + ((1+max_height+1) * g_TaskList->count) + 2 ); screen_width = get_screen_width(); screen_height = get_screen_height(); GetClientRect(hwnd, &rect); move( hwnd, screen_width / 2 - rect.right / 2, screen_height / 2 - rect.bottom / 2 ); ReleaseDC(hwnd, hdc); return 0; }
static float get_area_ui_object_y (ui_object *obj) { area_ui_object *area; float y, py = 0; ui_object *parent; parent = get_ui_object_parent (obj); if (parent) { py = get_ui_object_y (parent); } area = (area_ui_object *) obj->data; y = area->y_start + (get_ui_object_bounded_t_value (obj) * (area->y_end - area->y_start)); if (area->virtual_coords) { if (parent) { y *= get_ui_object_y_size (parent); } else { y *= get_screen_height (video_screen); } } return y + py; }
void myback_parse (char *tline, FILE * fd, char **myname, int *mylook) { FilePtrAndData fpd; ConfigDef *ConfigReader; MyBackgroundConfig *back_config = NULL; FreeStorageElem *Storage = NULL, *more_stuff = NULL; MyLook *look = (MyLook *) mylook; MyBackground *myback = NULL; ConfigData cd; if (look == NULL) look = get_screen_look (NULL); fpd.fp = fd; fpd.data = safemalloc (12 + 1 + strlen (tline) + 1 + 1); sprintf (fpd.data, "MyBackground %s\n", tline); LOCAL_DEBUG_OUT ("fd(%p)->tline(\"%s\")->fpd.data(\"%s\")", fd, tline, fpd.data); cd.fileptranddata = &fpd; ConfigReader = InitConfigReader ((char *)myname, &MyBackgroundSyntax, CDT_FilePtrAndData, cd, NULL); free (fpd.data); if (!ConfigReader) return; PrintConfigReader (ConfigReader); ParseConfig (ConfigReader, &Storage); /* getting rid of all the crap first */ StorageCleanUp (&Storage, &more_stuff, CF_DISABLED_OPTION); DestroyFreeStorage (&more_stuff); back_config = ParseMyBackgroundOptions (Storage, (char *)myname); DestroyConfig (ConfigReader); DestroyFreeStorage (&Storage); if (back_config == NULL) return; /* now we have to turn MyBackgroundConfig into MyBackground structure : */ myback = create_myback (back_config->name); if (get_flags (back_config->flags, BGFLAG_FILE)) myback->type = MB_BackImage; else if (get_flags (back_config->flags, BGFLAG_MYSTYLE)) myback->type = MB_BackMyStyle; else myback->type = MB_BackCmd; myback->data = back_config->data; back_config->data = NULL; if (get_flags (back_config->flags, BGFLAG_CUT)) myback->cut = back_config->cut; if (get_flags (back_config->flags, BGFLAG_SCALE)) { myback->scale = back_config->scale; if (!get_flags (back_config->scale.flags, WidthValue)) myback->scale.width = get_screen_width (NULL); if (!get_flags (back_config->scale.flags, HeightValue)) myback->scale.height = get_screen_height (NULL); set_flags (myback->scale.flags, WidthValue | HeightValue); } myback->tint = TINT_LEAVE_SAME; if (get_flags (back_config->flags, BGFLAG_TINT) && back_config->tint) parse_argb_color (back_config->tint, &(myback->tint)); myback->pad_color = ARGB32_Black; if (get_flags (back_config->flags, BGFLAG_PAD) && back_config->pad) parse_argb_color (back_config->pad, &(myback->pad_color)); myback->align_flags = NO_ALIGN; if (get_flags (back_config->flags, BGFLAG_PAD_HOR)) { if (get_flags (back_config->flags, BGFLAG_ALIGN_RIGHT)) myback->align_flags = ALIGN_RIGHT; else if (get_flags (back_config->flags, BGFLAG_ALIGN_CENTER)) myback->align_flags = ALIGN_HCENTER; else myback->align_flags = ALIGN_LEFT; } if (get_flags (back_config->flags, BGFLAG_PAD_VERT)) { if (get_flags (back_config->flags, BGFLAG_ALIGN_BOTTOM)) myback->align_flags |= ALIGN_BOTTOM; else if (get_flags (back_config->flags, BGFLAG_ALIGN_CENTER)) myback->align_flags |= ALIGN_VCENTER; else myback->align_flags = ALIGN_TOP; } LOCAL_DEBUG_OUT ("myback added: name(\"%s\")->type(%d)->data(\"%s\")", myback->name, myback->type, myback->data); add_myback (look, myback); /* final cleanup : */ DestroyMyBackgroundConfig (&back_config); }
void Video_DX9::init() { set_opengl_flag(false); Video::init(); SDL_SysWMinfo wmInfo; SDL_VERSION(&wmInfo.version); SDL_GetWMInfo(&wmInfo); cout << "Initializing DirectX 9" << endl; m_d3d->GetDeviceCaps(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, &m_d3d_capabilities); m_dpi = GetDeviceCaps(GetDC(wmInfo.window), LOGPIXELSY); ZeroMemory(&m_d3d_parameters, sizeof(m_d3d_parameters)); m_d3d_parameters.hDeviceWindow = wmInfo.window; m_d3d_parameters.Windowed = true; m_d3d_parameters.FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT; m_d3d_parameters.BackBufferCount = 1; m_d3d_parameters.BackBufferWidth = UINT(get_screen_width()); m_d3d_parameters.BackBufferHeight = UINT(get_screen_height()); m_d3d_parameters.BackBufferFormat = D3DFMT_A8R8G8B8; m_d3d_parameters.SwapEffect = D3DSWAPEFFECT_DISCARD; m_d3d_parameters.PresentationInterval = get_vertical_sync() ? D3DPRESENT_INTERVAL_ONE : D3DPRESENT_INTERVAL_IMMEDIATE; m_d3d_parameters.Flags = 0; //D3DPRESENTFLAG_LOCKABLE_BACKBUFFER; m_d3d_parameters.EnableAutoDepthStencil = true; m_d3d_parameters.AutoDepthStencilFormat = D3DFMT_D16; if(get_multisampling() > 1) switch(get_multisampling()) { case 2: m_d3d_parameters.MultiSampleType = D3DMULTISAMPLE_2_SAMPLES; break; case 3: m_d3d_parameters.MultiSampleType = D3DMULTISAMPLE_3_SAMPLES; break; case 4: m_d3d_parameters.MultiSampleType = D3DMULTISAMPLE_4_SAMPLES; break; case 5: m_d3d_parameters.MultiSampleType = D3DMULTISAMPLE_5_SAMPLES; break; case 6: m_d3d_parameters.MultiSampleType = D3DMULTISAMPLE_6_SAMPLES; break; case 7: m_d3d_parameters.MultiSampleType = D3DMULTISAMPLE_7_SAMPLES; break; case 8: m_d3d_parameters.MultiSampleType = D3DMULTISAMPLE_8_SAMPLES; break; case 9: m_d3d_parameters.MultiSampleType = D3DMULTISAMPLE_9_SAMPLES; break; case 10: m_d3d_parameters.MultiSampleType = D3DMULTISAMPLE_10_SAMPLES; break; case 11: m_d3d_parameters.MultiSampleType = D3DMULTISAMPLE_11_SAMPLES; break; case 12: m_d3d_parameters.MultiSampleType = D3DMULTISAMPLE_12_SAMPLES; break; case 13: m_d3d_parameters.MultiSampleType = D3DMULTISAMPLE_13_SAMPLES; break; case 14: m_d3d_parameters.MultiSampleType = D3DMULTISAMPLE_14_SAMPLES; break; case 15: m_d3d_parameters.MultiSampleType = D3DMULTISAMPLE_15_SAMPLES; break; case 16: default: m_d3d_parameters.MultiSampleType = D3DMULTISAMPLE_16_SAMPLES; break; } else if(get_multisampling() < 0) m_d3d_parameters.MultiSampleType = D3DMULTISAMPLE_16_SAMPLES; else m_d3d_parameters.MultiSampleType = D3DMULTISAMPLE_NONE; m_d3d_parameters.MultiSampleQuality = 0; // Initialize the D3D device if(!init_device()) throw Video_Init_Failure(); // Initialize the rendering context init_context(); }
static void draw_area_ui_object (ui_object *obj) { float x, y, x1, y1, x2, y2; int redraw_flag = FALSE, masked, width, height, pitch; font_types font_id; area_ui_object *area; struct SCREEN *old_active_screen, *memory_graphic; unsigned short int *graphic; struct ZOOMABLE_GRAPHIC *zoomable_graphic; unsigned char *data; ui_object *parent; if (get_ui_object_redraw (obj)) { area = (area_ui_object *) obj->data; //debug_log ("AR_DRAW: drawing area %f, %f %f, %f", area->x, area->y, area->x_size, area->y_size); x1 = area->x; y1 = area->y; x2 = x1 + area->x_size; y2 = y1 + area->y_size; old_active_screen = get_active_screen (); if (get_ui_object_active_screen (obj)) { set_active_screen (get_ui_object_active_screen (obj)); } else { set_active_screen (video_screen); } if (lock_screen (active_screen)) { switch (get_ui_object_graphic_type (obj)) { case UI_OBJECT_GRAPHIC: { if (!get_ui_object_clear (obj)) { graphic = get_ui_object_graphic (obj); ui_draw_graphic (x1, y1, x2, y2, graphic); redraw_flag = TRUE; } else { parent = get_ui_object_parent (obj); if (parent) { graphic = get_ui_object_graphic (parent); ui_draw_part_graphic (x1, y1, x2, y2, x1, y1, graphic); redraw_flag = TRUE; } } break; } case UI_OBJECT_MEMORY_GRAPHIC: { memory_graphic = get_ui_object_memory_graphic (obj); if (lock_screen (memory_graphic)) { width = get_screen_width (memory_graphic); height = get_screen_height (memory_graphic); data = get_screen_data (memory_graphic); pitch = get_screen_pitch (memory_graphic); masked = get_ui_object_clear (obj); ui_draw_memory_graphic (obj, x1, y1, x2, y2, width, height, pitch, masked); unlock_screen (memory_graphic); } redraw_flag = TRUE; break; } case UI_OBJECT_ALPHA_GRAPHIC: { if (!get_ui_object_clear (obj)) { graphic = get_ui_object_graphic (obj); ui_draw_alpha_graphic (x1, y1, x2, y2, graphic); redraw_flag = TRUE; } else { parent = get_ui_object_parent (obj); if (parent) { graphic = get_ui_object_graphic (parent); ui_draw_part_alpha_graphic (x1, y1, x2, y2, x1, y1, graphic); redraw_flag = TRUE; } } break; } case UI_OBJECT_ZOOMABLE_PALETTE_GRAPHIC: { if (!get_ui_object_clear (obj)) { zoomable_graphic = get_ui_object_zoomable_palette_graphic (obj); draw_zoomable_graphic (zoomable_graphic, area->cx, area->cy, x1, y1, x2, y2, area->zoom); redraw_flag = TRUE; } break; } case UI_OBJECT_NO_GRAPHIC: default: { if (!get_ui_object_clear (obj)) { ui_draw_area (x1, y1, x2, y2); redraw_flag = TRUE; } } } // text position if (get_ui_object_text (obj)) { font_id = get_ui_font (); set_ui_font (get_ui_object_font (obj)); get_text_position (&x, &y, x1, y1, x2, y2, obj); ui_display_text (get_ui_object_text (obj), x, y); set_ui_font (font_id); redraw_flag = TRUE; } if (redraw_flag) { set_ui_repaint_area (x1 + ui_x_origin, y1 + ui_y_origin, x2 + ui_x_origin + 1, y2 + ui_y_origin + 1); } unlock_screen (active_screen); } set_active_screen (old_active_screen); area->redraw --; call_ui_object_draw_function (obj, NULL); } }
int get_mouse_y(void) { return ((float)mouse_pos.y / (float)get_screen_height()) * 480; }
int main() { struct egui_uds client_uds = {0}; si_t s_width = 0, s_height = 0, gd = 0; const char test_str[] = "hello, egui!"; struct rectangle area = {0}; /** * 初始化客户端通信句柄 **/ if(0 != uds_init(&client_uds, SOCK_STREAM, SERVER_PATH, PEER_ROLE_CLIENT)) { EGUI_PRINT_ERROR("Failed to init server uds"); return -1; } /** * 初始化客户端 **/ client_lib_init(&client_uds, NULL); EGUI_PRINT_INFO("client init sucessfully!"); /** * 获取屏幕的高和宽,输出 **/ s_width = get_screen_width(); s_height = get_screen_height(); if(s_width < 0 || s_height < 0) { EGUI_PRINT_ERROR("failed to get screen width or height"); return -1; } EGUI_PRINT_INFO("screen width = %d, height = %d", (int)s_width, (int)s_height); /** * 初始化图形设备 **/ gd = graphics_device_init(300, 300, 1000, 600, 255, 0, 0, 0, FONT_MATRIX_12); if(gd < 0) { EGUI_PRINT_ERROR("failed to init gd"); return -1; } /** * 显示字符串:hello egui **/ if(0 != show_text(gd, 300, 300, test_str, strlen(test_str)) || 0 != update(gd)) { EGUI_PRINT_ERROR("failed to show test \"%s\"", test_str); return -1; } /** * 图形设备退出 **/ if(0 != graphics_device_exit(gd)) { EGUI_PRINT_ERROR("failed to exit graph device"); return -1; } /** * 最大化窗口,输出返回的窗口大小 **/ if(0 != maximize_window(10, &area)) { EGUI_PRINT_ERROR("failed to max window"); return -1; } EGUI_PRINT_INFO("maximize window area = (%d, %d), %d, %d", (int)area.x, (int)area.y, (int)area.width, (int)area.height); if(0 != window_manager_quit()) { EGUI_PRINT_ERROR("failed to let window manager quit"); return -1; } /** * 清理通信句柄 **/ if(0 != uds_exit(&client_uds)) { EGUI_PRINT_ERROR("failed to clean uds"); return -1; } return 0; }
/* public functions */ GtkWidget * asgtk_gradient_new () { ASGtkGradient *ge; GtkWidget *main_vbox, *main_hbox; GtkWidget *scrolled_window ; GtkWidget *list_vbox ; GtkWidget *frame, *hbox, *vbox, *btn, *table; GtkWidget *label ; ge = g_object_new (ASGTK_TYPE_GRADIENT, NULL); colorize_gtk_window( GTK_WIDGET(ge) ); gtk_container_set_border_width( GTK_CONTAINER (ge), 5 ); main_vbox = GTK_DIALOG(ge)->vbox ; main_hbox = gtk_hbox_new (FALSE, 5); gtk_widget_show (main_hbox); gtk_box_pack_start (GTK_BOX (main_vbox), main_hbox, TRUE, TRUE, 0); list_vbox = gtk_vbox_new (FALSE, 0); gtk_box_pack_start (GTK_BOX (main_hbox), list_vbox, FALSE, FALSE, 0); frame = gtk_frame_new("Gradient direction : "); gtk_box_pack_start (GTK_BOX (list_vbox), frame, FALSE, FALSE, 5); table = gtk_table_new( 2, 2, FALSE ); gtk_container_add (GTK_CONTAINER (frame), table); gtk_container_set_border_width (GTK_CONTAINER (table), 3); ge->l2r_radio = gtk_radio_button_new_with_label( NULL, "Left to Right" ); gtk_table_attach_defaults (GTK_TABLE (table), ge->l2r_radio, 0, 1, 0, 1); ge->t2b_radio = gtk_radio_button_new_with_label_from_widget( GTK_RADIO_BUTTON(ge->l2r_radio), "Top to Bottom" ); gtk_table_attach_defaults (GTK_TABLE (table), ge->t2b_radio, 0, 1, 1, 2); ge->tl2br_radio = gtk_radio_button_new_with_label_from_widget( GTK_RADIO_BUTTON(ge->t2b_radio), "Top-Left to Bottom-Right" ); gtk_table_attach_defaults (GTK_TABLE (table), ge->tl2br_radio, 1, 2, 0, 1); ge->bl2tr_radio = gtk_radio_button_new_with_label_from_widget( GTK_RADIO_BUTTON(ge->tl2br_radio), "Bottom-Left to Top-Right" ); gtk_table_attach_defaults (GTK_TABLE (table), ge->bl2tr_radio, 1, 2, 1, 2); gtk_widget_show_all (table); gtk_widget_show (table); colorize_gtk_widget( frame, get_colorschemed_style_normal() ); g_signal_connect ((gpointer) ge->l2r_radio, "clicked", G_CALLBACK (on_direction_clicked), ge); g_signal_connect ((gpointer) ge->tl2br_radio, "clicked", G_CALLBACK (on_direction_clicked), ge); g_signal_connect ((gpointer) ge->t2b_radio, "clicked", G_CALLBACK (on_direction_clicked), ge); g_signal_connect ((gpointer) ge->bl2tr_radio, "clicked", G_CALLBACK (on_direction_clicked), ge); ge->screen_width_check = gtk_check_button_new_with_label("Use screen width"); gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(ge->screen_width_check), TRUE ); ge->width_entry = gtk_spin_button_new_with_range( 1, 10000, 1 ); gtk_widget_set_sensitive( ge->width_entry, FALSE ); ge->screen_height_check = gtk_check_button_new_with_label("Use screen height"); gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(ge->screen_height_check), TRUE ); ge->height_entry = gtk_spin_button_new_with_range( 1, 10000, 1 ); gtk_widget_set_sensitive( ge->height_entry, FALSE ); g_signal_connect ((gpointer) ge->screen_width_check, "clicked", G_CALLBACK (on_size_clicked), ge); g_signal_connect ((gpointer) ge->screen_height_check, "clicked", G_CALLBACK (on_size_clicked), ge); ge->size_frame = gtk_frame_new("Rendered gradient size : "); gtk_box_pack_start (GTK_BOX (list_vbox), ge->size_frame, FALSE, FALSE, 5); colorize_gtk_tree_view_window( GTK_WIDGET(ge->size_frame) ); table = gtk_table_new( 2, 4, FALSE ); gtk_container_set_border_width( GTK_CONTAINER (table), 3 ); gtk_container_add( GTK_CONTAINER(ge->size_frame), table ); gtk_table_attach_defaults (GTK_TABLE (table), gtk_label_new("Width : "), 0, 1, 0, 1); gtk_table_attach_defaults (GTK_TABLE (table), ge->width_entry, 1, 2, 0, 1); gtk_table_attach_defaults (GTK_TABLE (table), gtk_label_new("Height : "), 2, 3, 0, 1); gtk_table_attach_defaults (GTK_TABLE (table), ge->height_entry, 3, 4, 0, 1); gtk_table_attach (GTK_TABLE (table), ge->screen_width_check, 0, 2, 1, 2, GTK_FILL, GTK_FILL, 10, 0); gtk_table_attach (GTK_TABLE (table), ge->screen_height_check, 2, 4, 1, 2, GTK_FILL, GTK_FILL, 10, 0); gtk_widget_show_all (table); gtk_widget_show (table); colorize_gtk_widget( ge->size_frame, get_colorschemed_style_normal() ); scrolled_window = asgtk_gradient_create_color_list( ge ); gtk_box_pack_start (GTK_BOX (list_vbox), scrolled_window, FALSE, FALSE, 0); ge->color_entry = gtk_entry_new_with_max_length(24); gtk_entry_set_width_chars( GTK_ENTRY(ge->color_entry), 16 ); #if 0 ge->color_preview = gtk_color_button_new(); g_signal_connect ((gpointer) ge->color_preview, "clicked", G_CALLBACK (on_color_preview_clicked), ge); #else ge->color_preview = gtk_image_new(); update_color_preview( ge, DEFAULT_COLOR_STR ); #endif ge->offset_entry = gtk_spin_button_new_with_range( 0., 1., 0.05 ); frame = gtk_frame_new("Change point attributes : "); gtk_box_pack_end (GTK_BOX (list_vbox), frame, FALSE, FALSE, 5); colorize_gtk_tree_view_window( GTK_WIDGET(frame) ); vbox = gtk_vbox_new( FALSE, 5 ); gtk_container_add( GTK_CONTAINER(frame), vbox ); table = gtk_table_new( 4, 2, FALSE ); gtk_container_set_border_width( GTK_CONTAINER (table), 3 ); // hbox = gtk_hbox_new( FALSE, 5 ); // gtk_container_set_border_width( GTK_CONTAINER (hbox), 3 ); gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0); label = gtk_label_new("Color : "); gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT); gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, 0, 1); label = gtk_label_new("Offset : "); gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT); gtk_table_attach_defaults (GTK_TABLE (table), label, 2, 3, 0, 1); gtk_table_attach (GTK_TABLE (table), ge->color_entry, 1, 2, 0, 1, GTK_SHRINK, GTK_SHRINK, 2, 2); gtk_table_attach (GTK_TABLE (table), ge->offset_entry, 3, 4, 0, 1, GTK_SHRINK, GTK_SHRINK, 2, 2); frame = gtk_frame_new(NULL); colorize_gtk_tree_view_window( GTK_WIDGET(frame) ); gtk_widget_set_size_request( frame, COLOR_PREVIEW_WIDTH, COLOR_PREVIEW_HEIGHT ); gtk_container_set_border_width( GTK_CONTAINER (table), 0 ); gtk_container_add( GTK_CONTAINER(frame), ge->color_preview ); gtk_widget_show( ge->color_preview ); btn = gtk_button_new(); gtk_container_set_border_width( GTK_CONTAINER (btn), 0 ); //btn = gtk_button_new_with_label(" Color selector "); colorize_gtk_widget( GTK_WIDGET(btn), get_colorschemed_style_button()); gtk_container_add (GTK_CONTAINER (btn), frame); gtk_widget_show (frame); g_signal_connect ((gpointer) frame, "size-allocate", G_CALLBACK (color_preview_size_alloc), ge); gtk_table_attach (GTK_TABLE (table), btn, 0, 2, 1, 2, GTK_FILL, GTK_SHRINK, 2, 2); g_signal_connect ((gpointer) btn, "clicked", G_CALLBACK (on_color_clicked), ge); gtk_widget_show_all (table); gtk_widget_show (table); hbox = gtk_hbox_new( FALSE, 5 ); gtk_container_set_border_width( GTK_CONTAINER (hbox), 3 ); gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); ge->delete_btn = btn = gtk_button_new_from_stock(GTK_STOCK_DELETE); gtk_widget_set_sensitive( ge->delete_btn, FALSE ); colorize_gtk_widget( GTK_WIDGET(btn), get_colorschemed_style_button()); gtk_box_pack_end (GTK_BOX (hbox), btn, FALSE, FALSE, 0); g_signal_connect ((gpointer) btn, "clicked", G_CALLBACK (on_delete_point_clicked), ge); btn = gtk_button_new_from_stock(GTK_STOCK_ADD); colorize_gtk_widget( GTK_WIDGET(btn), get_colorschemed_style_button()); gtk_box_pack_end (GTK_BOX (hbox), btn, FALSE, FALSE, 0); g_signal_connect ((gpointer) btn, "clicked", G_CALLBACK (on_add_point_clicked), ge); ge->apply_btn = btn = gtk_button_new_from_stock(GTK_STOCK_APPLY); gtk_widget_set_sensitive( ge->apply_btn, FALSE ); colorize_gtk_widget( GTK_WIDGET(btn), get_colorschemed_style_button()); gtk_box_pack_end (GTK_BOX (hbox), btn, FALSE, FALSE, 0); g_signal_connect ((gpointer) btn, "clicked", G_CALLBACK (on_apply_point_clicked), ge); gtk_widget_show_all (hbox); gtk_widget_show (hbox); /* The preview : */ ge->image_view = ASGTK_IMAGE_VIEW(asgtk_image_view_new()); gtk_widget_set_size_request (GTK_WIDGET(ge->image_view), PREVIEW_WIDTH, PREVIEW_HEIGHT); gtk_box_pack_end (GTK_BOX (main_hbox), GTK_WIDGET(ge->image_view), TRUE, TRUE, 0); asgtk_image_view_set_aspect ( ge->image_view, get_screen_width(NULL), get_screen_height(NULL) ); asgtk_image_view_set_resize ( ge->image_view, ASGTK_IMAGE_VIEW_SCALE_TO_VIEW| ASGTK_IMAGE_VIEW_TILE_TO_ASPECT, ASGTK_IMAGE_VIEW_RESIZE_ALL ); gtk_widget_show_all (list_vbox); gtk_widget_show_all (main_hbox); gtk_widget_hide(ge->image_view->details_label); btn = gtk_check_button_new_with_label( "Use screen aspect ratio" ); gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(btn), TRUE ); gtk_widget_show (btn); colorize_gtk_widget( btn, get_colorschemed_style_normal() ); g_signal_connect (G_OBJECT (btn), "toggled", G_CALLBACK (asgtk_image_view_screen_aspect_toggle), (gpointer) ge->image_view); gtk_button_set_alignment( GTK_BUTTON(btn), 1.0, 0.5); asgtk_image_view_add_detail( ge->image_view, btn, 0 ); btn = gtk_check_button_new_with_label( "Scale to fit this view" ); gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(btn), TRUE ); gtk_widget_show (btn); colorize_gtk_widget( btn, get_colorschemed_style_normal() ); g_signal_connect (G_OBJECT (btn), "toggled", G_CALLBACK (asgtk_image_view_scale_to_view_toggle), (gpointer) ge->image_view); gtk_button_set_alignment( GTK_BUTTON(btn), 1.0, 0.5); asgtk_image_view_add_detail( ge->image_view, btn, 0 ); btn = asgtk_add_button_to_box( NULL, GTK_STOCK_REFRESH, NULL, G_CALLBACK(on_refresh_clicked), ge ); asgtk_image_view_add_tool( ge->image_view, btn, 3 ); LOCAL_DEBUG_OUT( "created image ASGtkGradient object %p", ge ); return GTK_WIDGET (ge); }
static void refresh_gradient_preview(ASGtkGradient *ge) { int width = get_screen_width(NULL); int height = get_screen_height(NULL); struct ASGradient gradient ; struct ASImageListEntry *entry; ARGB32 *color ; double *offset ; if( ge->points->count <= 0 ) return ; if( GTK_WIDGET_STATE( ge->width_entry) != GTK_STATE_INSENSITIVE ) if( (width = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(ge->width_entry))) == 0 ) width = get_screen_width(NULL) ; if( GTK_WIDGET_STATE( ge->height_entry) != GTK_STATE_INSENSITIVE ) if( (height = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(ge->height_entry))) == 0 ) height = get_screen_height(NULL) ; entry = create_asimage_list_entry(); /* rendering gradient preview : */ gradient.npoints = 0 ; gradient.type = ge->type ; gradient.offset = offset = safemalloc((ge->points->count+2) * sizeof(double) ); gradient.color = color = safemalloc((ge->points->count+2) * sizeof(ARGB32) ); ++gradient.offset ; ++gradient.color ; iterate_asbidirlist( ge->points, add_point_to_gradient, &gradient, NULL, False ); if( gradient.offset[0] > 0. ) { --gradient.offset ; --gradient.color ; gradient.offset[0] = 0. ; gradient.color[0] = DEFAULT_COLOR ; /* black */ ++gradient.npoints; } if( gradient.offset[gradient.npoints-1] < 1. ) { gradient.offset[gradient.npoints] = 1. ; gradient.color[gradient.npoints] = DEFAULT_COLOR ; /* black */ ++gradient.npoints; } entry->preview = make_gradient(get_screen_visual(NULL), &gradient, width, height, SCL_DO_ALL, ASA_ASImage, 0, ASIMAGE_QUALITY_DEFAULT); free( offset ); free( color ); /* applying gradient preview : */ if( entry->preview ) asgtk_image_view_set_entry ( ge->image_view, entry); else asgtk_image_view_set_entry ( ge->image_view, NULL); unref_asimage_list_entry( entry ); }
/** * Return screen height */ int lfjport_get_screen_height() { get_screen_height(); }
/** * Invert screen rotation flag */ jboolean winceapp_reverse_orientation() { reverse_orientation = !reverse_orientation; gxj_system_screen_buffer.width = get_screen_width(); gxj_system_screen_buffer.height = get_screen_height(); return reverse_orientation; }
void widget_move(int16 x, int16 y) { ui.screen.newmousepos.x = x; ui.screen.newmousepos.y = y; if(ui.moving){ int windowx, windowy; glfwGetWindowPos(get_the_window(),&windowx, &windowy); glfwSetWindowPos(get_the_window(),x + windowx - ui.screen.mouseclick.x, y + windowy - ui.screen.mouseclick.y); } else{ if(focused){ if(focused->action & WIDGET_MOVING){ int16 tempx = x - ui.screen.mousepos.x ; int16 tempy = y - ui.screen.mousepos.y ; if(focused->pos.x + tempx <= 0 || focused->pos.y + tempy <= 0) return; if(focused->pos.x + focused->width + tempx>= get_screen_width() +400|| focused->pos.y + focused->height + tempy >= get_screen_height() + 400) return; focused->pos.x = focused->pos.x + tempx ; focused->pos.y = focused->pos.y + tempy ; widget_position_update(focused); } if(widget_rect_contains(focused)) widget_mouse_over(focused); } else{ if(ui.root) widget_mouse_over(ui.root); } } }
int ui_clip_area (float *x_min, float *y_min, float *x_max, float *y_max) { int clipped_flag = FALSE; float screen_min_x, screen_min_y, screen_max_x, screen_max_y; screen_min_x = 0 - ui_x_origin; screen_min_y = 0 - ui_y_origin; screen_max_x = get_screen_width (active_screen) - ui_x_origin; screen_max_y = get_screen_height (active_screen) - ui_y_origin; // // clip to left extent // if (*x_min < active_viewport.x_min - ui_x_origin) { *x_min = active_viewport.x_min - ui_x_origin; clipped_flag = TRUE; } // clip to screen if (*x_min < screen_min_x) { *x_min = screen_min_x; clipped_flag = TRUE; } // guarentee valid area if (*x_max < *x_min) { *x_max = *x_min; clipped_flag = TRUE; } // // clip right // if (*x_max > active_viewport.x_max - ui_x_origin) { *x_max = active_viewport.x_max - ui_x_origin; clipped_flag = TRUE; } // clip to screen if (*x_max > screen_max_x) { *x_max = screen_max_x; clipped_flag = TRUE; } // guarentee valid area if (*x_min > *x_max) { *x_min = *x_max; clipped_flag = TRUE; } // // clip top // if (*y_min < active_viewport.y_min - ui_y_origin) { *y_min = active_viewport.y_min - ui_y_origin; clipped_flag = TRUE; } // clip to screen if (*y_min < screen_min_y) { *y_min = screen_min_y; clipped_flag = TRUE; } // guarentee valid area if (*y_max < *y_min) { *y_max = *y_min; clipped_flag = TRUE; } // // clip bottom // if (*y_max > active_viewport.y_max - ui_y_origin) { *y_max = active_viewport.y_max - ui_y_origin; clipped_flag = TRUE; } // clip to screen if (*y_max > screen_max_y) { *y_max = screen_max_y; clipped_flag = TRUE; } // guarentee valid area if (*y_min > *y_max) { *y_min = *y_max; clipped_flag = TRUE; } return clipped_flag; }
void save_high_res_screen_image ( void ) { char filename[100], image_filename[100]; int x, y, x_repeat, y_repeat, screen_width, screen_height, screen_pitch; unsigned short int *huge_screen_shot_memory; unsigned char *screen_data; x_repeat = 8; y_repeat = 8; screen_width = get_screen_width ( video_screen ); screen_height = get_screen_height ( video_screen ); huge_screen_shot_memory = ( unsigned short int * ) safe_malloc ( sizeof ( unsigned short int ) * screen_width * screen_height * x_repeat * y_repeat ); for ( y = 0; y < y_repeat; y++ ) { for ( x = 0; x < x_repeat; x++ ) { unsigned short int *destination_ptr, *screen_line; int screen_y; // // Render the big views // draw_application_highres_screen ( x, y, x_repeat, y_repeat ); if ( lock_screen ( video_screen ) ) { screen_data = get_screen_data ( video_screen ); screen_pitch = get_screen_pitch ( video_screen ); destination_ptr = huge_screen_shot_memory + ( y * x_repeat * screen_width * screen_height ) + ( x * screen_width ); for ( screen_y = 0; screen_y < screen_height; screen_y++ ) { screen_line = ( unsigned short int * ) ( screen_data + ( screen_y * screen_pitch ) ); memcpy ( destination_ptr, screen_line, screen_width * sizeof ( unsigned short int ) ); destination_ptr += x_repeat * screen_width; } unlock_screen ( video_screen ); } } } // // find first screen shot index // if (!found_first_screen_shot_index) { while (TRUE) { sprintf (image_filename, "%sIMAGE%03d.PSD", LARGE_IMAGE_PATH, screen_shot_index); if (file_exist (image_filename)) { screen_shot_index++; if (screen_shot_index == 1000) { break; } } else { found_first_screen_shot_index = TRUE; break; } } } // // write screen files and viewpoint data file // if (screen_shot_index <= MAX_SCREEN_SHOT_INDEX) { sprintf (filename, "IMAGE%03d", screen_shot_index); debug_log ("Saving screen image (%s)", filename); sprintf (image_filename, "%s%s.PSD", LARGE_IMAGE_PATH, filename); write_psd_screen_file ( image_filename, screen_width * x_repeat, screen_height * y_repeat, screen_width * x_repeat * sizeof ( unsigned short int ), ( unsigned char * ) huge_screen_shot_memory ); screen_shot_index++; } else { debug_colour_log (DEBUG_COLOUR_RED, "Exceeded screen image limit"); } safe_free ( huge_screen_shot_memory ); }
/** * Bridge function to return screen height */ int lfjport_get_screen_height() { return get_screen_height(); }