19
19
ProgressType load_async = ProgressType.Full;
20
20
bool progressive_display;
21
21
public GdkGlx.Context Glx;
22
private Editor editor;
22
private OldEditor editor;
24
24
public PhotoImageView (IBrowsableCollection query) : this (new BrowsablePointer (query, -1))
26
FSpot.ColorManagement.PhotoImageView = this;
28
29
public PhotoImageView (BrowsablePointer item)
31
32
loader.AreaUpdated += HandlePixbufAreaUpdated;
32
33
loader.AreaPrepared += HandlePixbufPrepared;
33
34
loader.Done += HandleDone;
36
FSpot.ColorManagement.PhotoImageView = this;
37
this.Transform = FSpot.ColorManagement.StandartTransform (); //for preview windows
35
39
Accelerometer.OrientationChanged += HandleOrientationChanged;
92
96
private void HandleEditorDone (object sender, EventArgs args)
94
Editor old = sender as Editor;
98
OldEditor old = sender as OldEditor;
96
100
old.Done -= HandleEditorDone;
307
310
private void PhotoItemChanged (BrowsablePointer item, BrowsablePointerChangedArgs args)
309
Log.Debug ("PhotoImageView::item changed");
310
312
// If it is just the position that changed fall out
311
313
if (args != null &&
312
314
args.PreviousItem != null &&
315
317
(this.Item.Current.DefaultVersionUri == args.PreviousItem.DefaultVersionUri))
320
// Don't reload if the image didn't change at all.
321
if (args != null && args.Changes != null &&
322
!args.Changes.DataChanged &&
323
args.PreviousItem != null &&
325
this.Item.Current.DefaultVersionUri == args.PreviousItem.DefaultVersionUri)
318
328
if (args != null &&
319
329
args.PreviousItem != null &&
379
389
if (pixbuf == null)
382
int available_width = this.Allocation.Width;
383
int available_height = this.Allocation.Height;
392
if (scrolled != null)
393
scrolled.SetPolicy (Gtk.PolicyType.Never, Gtk.PolicyType.Never);
395
int available_width = (scrolled != null) ? scrolled.Allocation.Width : this.Allocation.Width;
396
int available_height = (scrolled != null) ? scrolled.Allocation.Height : this.Allocation.Height;
385
398
double zoom_to_fit = ZoomUtils.FitToScale ((uint) available_width,
386
399
(uint) available_height,
387
400
(uint) pixbuf.Width,
388
401
(uint) pixbuf.Height,
391
404
double image_zoom = zoom_to_fit;
393
System.Console.WriteLine ("Zoom = {0}, {1}, {2}", image_zoom,
398
if (scrolled != null)
399
scrolled.SetPolicy (Gtk.PolicyType.Never, Gtk.PolicyType.Never);
401
406
this.SetZoom (image_zoom, image_zoom);
423
428
// for any of the default handlers.
424
429
args.RetVal = true;
426
// Check for KeyPad arrow keys, which scroll the window when zoomed in
427
// but should go to the next/previous photo when not zoomed (no scrollbars)
429
switch (args.Event.Key) {
431
// Scroll if image is zoomed in (scrollbars are visible)
432
Gtk.ScrolledWindow scrolled = this.Parent as Gtk.ScrolledWindow;
433
if (scrolled != null && !this.Fit) {
434
Gtk.Adjustment vadj = scrolled.Vadjustment;
435
Gtk.Adjustment hadj = scrolled.Hadjustment;
436
switch (args.Event.Key) {
441
vadj.Value -= vadj.StepIncrement;
442
if (vadj.Value < vadj.Lower)
443
vadj.Value = vadj.Lower;
431
445
case Gdk.Key.Left:
433
446
case Gdk.Key.KP_Left:
434
this.Item.MovePrevious ();
448
hadj.Value -= hadj.StepIncrement;
449
if (hadj.Value < hadj.Lower)
450
hadj.Value = hadj.Lower;
436
452
case Gdk.Key.Down:
453
case Gdk.Key.KP_Down:
456
vadj.Value += vadj.StepIncrement;
457
if (vadj.Value > vadj.Upper - vadj.PageSize)
458
vadj.Value = vadj.Upper - vadj.PageSize;
437
460
case Gdk.Key.Right:
438
case Gdk.Key.KP_Down:
439
461
case Gdk.Key.KP_Right:
440
this.Item.MoveNext ();
463
hadj.Value += hadj.StepIncrement;
464
if (hadj.Value > hadj.Upper - hadj.PageSize)
465
hadj.Value = hadj.Upper - hadj.PageSize;
470
// Go to the next/previous photo when not zoomed (no scrollbars)
445
471
switch (args.Event.Key) {
447
474
case Gdk.Key.Left:
475
case Gdk.Key.KP_Left:
448
476
case Gdk.Key.Page_Up:
449
477
case Gdk.Key.KP_Page_Up:
478
case Gdk.Key.BackSpace:
450
485
this.Item.MovePrevious ();
453
case Gdk.Key.KP_Home:
458
this.Item.Index = this.Query.Count - 1;
460
487
case Gdk.Key.Down:
488
case Gdk.Key.KP_Down:
461
489
case Gdk.Key.Right:
490
case Gdk.Key.KP_Right:
462
491
case Gdk.Key.Page_Down:
463
492
case Gdk.Key.KP_Page_Down:
464
493
case Gdk.Key.space:
465
494
case Gdk.Key.KP_Space:
466
501
this.Item.MoveNext ();
504
case Gdk.Key.KP_Home:
509
this.Item.Index = this.Query.Count - 1;
468
511
case Gdk.Key.Key_0:
469
512
case Gdk.Key.KP_0: