comparison src/pixbuf-renderer.c @ 27:9c24765c2d3a

Sat Apr 2 17:28:16 2005 John Ellis <johne@verizon.net> * image.c (image_options_set): Update PixbufRenderer parent window so that changing 'fit window to image' option works. * pan-view.c (pan_window_image_zoom_cb): Use same zoom text display as for main windows. * pixbuf-renderer.c: Fix (re-implement) check for maximized window state. Fix pr_source_tile_visible() calculation which was using the x axis where it should be y. Add redrawn return value to pr_zoom_clamp() and use that value in pr_zoom_sync() to pass pr_redraw correct args. ##### Note: GQview CVS on sourceforge is not always up to date, please use ##### ##### an offical release when making enhancements and translation updates. #####
author gqview
date Sat, 02 Apr 2005 22:44:34 +0000
parents acd9885ebd78
children 8a8ec4b3e769
comparison
equal deleted inserted replaced
26:acd9885ebd78 27:9c24765c2d3a
674 return TRUE; 674 return TRUE;
675 } 675 }
676 676
677 static gint pr_parent_window_sizable(PixbufRenderer *pr) 677 static gint pr_parent_window_sizable(PixbufRenderer *pr)
678 { 678 {
679 GdkWindowState state;
680
679 if (!pr->parent_window) return FALSE; 681 if (!pr->parent_window) return FALSE;
680 if (!pr->window_fit) return FALSE; 682 if (!pr->window_fit) return FALSE;
681 if (!GTK_WIDGET(pr)->window) return FALSE; 683 if (!GTK_WIDGET(pr)->window) return FALSE;
682 #if 0 684
683 if (window_maximized(pr->top_window)) return FALSE; 685 if (!pr->parent_window->window) return FALSE;
684 #endif 686 state = gdk_window_get_state(pr->parent_window->window);
687 if (state & GDK_WINDOW_STATE_MAXIMIZED) return FALSE;
685 688
686 return TRUE; 689 return TRUE;
687 } 690 }
688 691
689 static gint pr_parent_window_resize(PixbufRenderer *pr, gint w, gint h) 692 static gint pr_parent_window_resize(PixbufRenderer *pr, gint w, gint h)
1247 x2 = ((pr->x_scroll + pr->vis_width) / PR_TILE_SIZE) * PR_TILE_SIZE + PR_TILE_SIZE; 1250 x2 = ((pr->x_scroll + pr->vis_width) / PR_TILE_SIZE) * PR_TILE_SIZE + PR_TILE_SIZE;
1248 y2 = ((pr->y_scroll + pr->vis_height) / PR_TILE_SIZE) * PR_TILE_SIZE + PR_TILE_SIZE; 1251 y2 = ((pr->y_scroll + pr->vis_height) / PR_TILE_SIZE) * PR_TILE_SIZE + PR_TILE_SIZE;
1249 1252
1250 return !((double)st->x * pr->scale > (double)x2 || 1253 return !((double)st->x * pr->scale > (double)x2 ||
1251 (double)(st->x + pr->source_tile_width) * pr->scale < (double)x1 || 1254 (double)(st->x + pr->source_tile_width) * pr->scale < (double)x1 ||
1252 (double)st->y * pr->scale > (double)x2 || 1255 (double)st->y * pr->scale > (double)y2 ||
1253 (double)(st->y + pr->source_tile_height) * pr->scale < (double)y1); 1256 (double)(st->y + pr->source_tile_height) * pr->scale < (double)y1);
1254 } 1257 }
1255 1258
1256 static SourceTile *pr_source_tile_new(PixbufRenderer *pr, gint x, gint y) 1259 static SourceTile *pr_source_tile_new(PixbufRenderer *pr, gint x, gint y)
1257 { 1260 {
2428 } 2431 }
2429 2432
2430 return (old_vw != pr->vis_width || old_vh != pr->vis_height); 2433 return (old_vw != pr->vis_width || old_vh != pr->vis_height);
2431 } 2434 }
2432 2435
2433 static gint pr_zoom_clamp(PixbufRenderer *pr, gdouble zoom, gint force, gint new, gint invalidate) 2436 static gint pr_zoom_clamp(PixbufRenderer *pr, gdouble zoom,
2437 gint force, gint new, gint invalidate,
2438 gint *redrawn)
2434 { 2439 {
2435 gint w, h; 2440 gint w, h;
2436 gdouble scale; 2441 gdouble scale;
2437 gint invalid; 2442 gint invalid;
2438 2443
2519 if (invalidate || invalid) 2524 if (invalidate || invalid)
2520 { 2525 {
2521 pr_tile_invalidate_all(pr); 2526 pr_tile_invalidate_all(pr);
2522 pr_redraw(pr, TRUE); 2527 pr_redraw(pr, TRUE);
2523 } 2528 }
2529 if (redrawn) *redrawn = (invalidate || invalid);
2524 2530
2525 return TRUE; 2531 return TRUE;
2526 } 2532 }
2527 2533
2528 static void pr_zoom_sync(PixbufRenderer *pr, gdouble zoom, 2534 static void pr_zoom_sync(PixbufRenderer *pr, gdouble zoom,
2531 { 2537 {
2532 gdouble old_scale; 2538 gdouble old_scale;
2533 gint old_cx, old_cy; 2539 gint old_cx, old_cy;
2534 gint clamped; 2540 gint clamped;
2535 gint sized; 2541 gint sized;
2542 gint redrawn = FALSE;
2536 2543
2537 old_scale = pr->scale; 2544 old_scale = pr->scale;
2538 if (center_point) 2545 if (center_point)
2539 { 2546 {
2540 px = CLAMP(px, 0, pr->width); 2547 px = CLAMP(px, 0, pr->width);
2547 px = py = 0; 2554 px = py = 0;
2548 old_cx = pr->x_scroll + pr->vis_width / 2; 2555 old_cx = pr->x_scroll + pr->vis_width / 2;
2549 old_cy = pr->y_scroll + pr->vis_height / 2; 2556 old_cy = pr->y_scroll + pr->vis_height / 2;
2550 } 2557 }
2551 2558
2552 if (!pr_zoom_clamp(pr, zoom, force, new, force)) return; 2559 if (!pr_zoom_clamp(pr, zoom, force, new, force, &redrawn)) return;
2553 2560
2554 clamped = pr_size_clamp(pr); 2561 clamped = pr_size_clamp(pr);
2555 sized = pr_parent_window_resize(pr, pr->width, pr->height); 2562 sized = pr_parent_window_resize(pr, pr->width, pr->height);
2556 2563
2557 if (force) 2564 if (force)
2598 /* If the window was not sized, redraw the image - we know there will be no size/expose signal. 2605 /* If the window was not sized, redraw the image - we know there will be no size/expose signal.
2599 * But even if a size is claimed, there is no guarantee that the window manager will allow it, 2606 * But even if a size is claimed, there is no guarantee that the window manager will allow it,
2600 * so redraw the window anyway :/ 2607 * so redraw the window anyway :/
2601 */ 2608 */
2602 if (sized || clamped) pr_border_clear(pr); 2609 if (sized || clamped) pr_border_clear(pr);
2603 pr_redraw(pr, FALSE); 2610 pr_redraw(pr, redrawn);
2604 2611
2605 pr_zoom_signal(pr); 2612 pr_zoom_signal(pr);
2606 pr_update_signal(pr); 2613 pr_update_signal(pr);
2607 } 2614 }
2608 2615
2611 if (pr->window_width == new_width && pr->window_height == new_height) return; 2618 if (pr->window_width == new_width && pr->window_height == new_height) return;
2612 2619
2613 pr->window_width = new_width; 2620 pr->window_width = new_width;
2614 pr->window_height = new_height; 2621 pr->window_height = new_height;
2615 2622
2616 if (pr->zoom == 0.0) pr_zoom_clamp(pr, 0.0, TRUE, FALSE, FALSE); 2623 if (pr->zoom == 0.0) pr_zoom_clamp(pr, 0.0, TRUE, FALSE, FALSE, NULL);
2617 2624
2618 pr_size_clamp(pr); 2625 pr_size_clamp(pr);
2619 pr_scroll_clamp(pr); 2626 pr_scroll_clamp(pr);
2620 2627
2621 /* ensure scroller remains visible */ 2628 /* ensure scroller remains visible */