Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
shotwell
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
99
Issues
99
List
Boards
Labels
Milestones
Merge Requests
3
Merge Requests
3
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
GNOME
shotwell
Commits
145ddbb8
Commit
145ddbb8
authored
May 08, 2009
by
Jim Nelson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Crop now following photo orientation.
parent
8a41e42b
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
100 additions
and
11 deletions
+100
-11
Box.vala
Box.vala
+67
-0
CollectionPage.vala
CollectionPage.vala
+12
-3
Photo.vala
Photo.vala
+12
-5
PhotoPage.vala
PhotoPage.vala
+9
-3
No files found.
Box.vala
View file @
145ddbb8
...
...
@@ -80,6 +80,73 @@ public struct Box {
return
rect
;
}
public
Box
rotate
(
Exif
.
Orientation
orientation
,
Dimensions
space
)
{
int
l
=
left
;
int
t
=
top
;
int
r
=
right
;
int
b
=
bottom
;
switch
(
orientation
)
{
case
Exif
.
Orientation
.
TOP_LEFT
:
// fine as is
break
;
case
Exif
.
Orientation
.
TOP_RIGHT
:
l
=
space
.
width
-
right
;
r
=
space
.
width
-
left
;
break
;
case
Exif
.
Orientation
.
BOTTOM_RIGHT
:
l
=
space
.
width
-
right
;
t
=
space
.
height
-
bottom
;
r
=
space
.
width
-
left
;
b
=
space
.
height
-
top
;
break
;
case
Exif
.
Orientation
.
BOTTOM_LEFT
:
t
=
space
.
height
-
bottom
;
b
=
space
.
height
-
top
;
break
;
case
Exif
.
Orientation
.
LEFT_TOP
:
l
=
top
;
t
=
left
;
r
=
bottom
;
b
=
right
;
break
;
case
Exif
.
Orientation
.
RIGHT_TOP
:
l
=
space
.
width
-
bottom
;
t
=
left
;
r
=
space
.
width
-
top
;
b
=
right
;
break
;
case
Exif
.
Orientation
.
RIGHT_BOTTOM
:
l
=
space
.
width
-
bottom
;
t
=
space
.
height
-
right
;
r
=
space
.
width
-
top
;
b
=
space
.
height
-
left
;
break
;
case
Exif
.
Orientation
.
LEFT_BOTTOM
:
l
=
top
;
t
=
space
.
height
-
right
;
r
=
bottom
;
b
=
space
.
height
-
left
;
break
;
default
:
error
(
"Unknown orientation: %d"
,
orientation
);
break
;
}
Box
rotated
=
Box
(
l
,
t
,
r
,
b
);
assert
(
rotated
.
is_valid
());
return
rotated
;
}
public
string
to_string
()
{
return
"%d,%d %d,%d"
.
printf
(
left
,
top
,
right
,
bottom
);
}
...
...
CollectionPage.vala
View file @
145ddbb8
...
...
@@ -338,9 +338,18 @@ public class CollectionPage : CheckerboardPage {
private
void
on_remove
()
{
// iterate over selected photos and remove them from entire system .. this will result
// in them being removed from this view in on_photo_removed
foreach
(
LayoutItem
item
in
get_selected
())
((
Thumbnail
)
item
).
get_photo
().
remove
();
// in on_photo_removed being called, which we don't want in this case is because it will
// remove from the list while iterating, so disconnect the signals and do the work here
foreach
(
LayoutItem
item
in
get_selected
())
{
Photo
photo
=
((
Thumbnail
)
item
).
get_photo
();
photo
.
removed
-=
on_photo_removed
;
photo
.
altered
-=
on_photo_altered
;
photo
.
remove
();
}
// now remove from page, outside of iterator
remove_selected
();
refresh
();
}
...
...
Photo.vala
View file @
145ddbb8
...
...
@@ -71,7 +71,8 @@ public class Photo : Object {
ThumbnailCache
.
import
(
photo_id
,
pixbuf
);
// sanity ... this would be very bad
assert
(!
photo_map
.
contains
(
photo_id
.
id
));
if
(
photo_map
!=
null
)
assert
(!
photo_map
.
contains
(
photo_id
.
id
));
return
fetch
(
photo_id
);
}
...
...
@@ -202,15 +203,21 @@ public class Photo : Object {
crop
=
Box
(
left
,
top
,
right
,
bottom
);
// crop follows rotation
crop
=
crop
.
rotate
(
photo_table
.
get_orientation
(
photo_id
),
get_uncropped_dimensions
());
return
true
;
}
public
bool
set_crop
(
Box
crop
)
{
// de-rotate crop
Box
derotated
=
crop
.
rotate
(
photo_table
.
get_orientation
(
photo_id
),
get_uncropped_dimensions
());
KeyValueMap
map
=
new
KeyValueMap
(
"crop"
);
map
.
set_int
(
"left"
,
crop
.
left
);
map
.
set_int
(
"top"
,
crop
.
top
);
map
.
set_int
(
"right"
,
crop
.
right
);
map
.
set_int
(
"bottom"
,
crop
.
bottom
);
map
.
set_int
(
"left"
,
derotated
.
left
);
map
.
set_int
(
"top"
,
derotated
.
top
);
map
.
set_int
(
"right"
,
derotated
.
right
);
map
.
set_int
(
"bottom"
,
derotated
.
bottom
);
bool
res
=
photo_table
.
set_transformation
(
photo_id
,
map
);
if
(
res
)
...
...
PhotoPage.vala
View file @
145ddbb8
...
...
@@ -674,10 +674,16 @@ public class PhotoPage : Page {
}
private
void
on_crop_toggled
()
{
if
(
crop_button
.
active
)
if
(
crop_button
.
active
)
{
activate_crop
();
else
}
else
{
// return to original view ... do this before deactivating crop, so its repaint takes
// effect
original
=
photo
.
get_pixbuf
();
pixmap
=
null
;
deactivate_crop
();
}
}
private
void
activate_crop
()
{
...
...
@@ -746,7 +752,7 @@ public class PhotoPage : Page {
crop_button
.
set_active
(
false
);
show_crop
=
false
;
repaint
();
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment