~bfiller/gallery-app/gallery-app-46-new

« back to all changes in this revision

Viewing changes to src/photoeditor/orientation.h

mergeĀ lp:~artmello/gallery-app/gallery-app-remove_local_photoeditor

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright (C) 2011 Canonical Ltd
3
 
 *
4
 
 * This program is free software: you can redistribute it and/or modify
5
 
 * it under the terms of the GNU General Public License version 3 as
6
 
 * published by the Free Software Foundation.
7
 
 *
8
 
 * This program is distributed in the hope that it will be useful,
9
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
 
 * GNU General Public License for more details.
12
 
 *
13
 
 * You should have received a copy of the GNU General Public License
14
 
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
15
 
 *
16
 
 * Authors:
17
 
 * Lucas Beeler <lucas@yorba.org>
18
 
 */
19
 
 
20
 
#ifndef GALLERY_ORIENTATION_H_
21
 
#define GALLERY_ORIENTATION_H_
22
 
 
23
 
#include <QTransform>
24
 
 
25
 
enum Orientation {
26
 
    ORIGINAL_ORIENTATION = 0,
27
 
    MIN_ORIENTATION = 1,
28
 
    TOP_LEFT_ORIGIN = 1,
29
 
    TOP_RIGHT_ORIGIN = 2,
30
 
    BOTTOM_RIGHT_ORIGIN = 3,
31
 
    BOTTOM_LEFT_ORIGIN = 4,
32
 
    LEFT_TOP_ORIGIN = 5,
33
 
    RIGHT_TOP_ORIGIN = 6,
34
 
    RIGHT_BOTTOM_ORIGIN = 7,
35
 
    LEFT_BOTTOM_ORIGIN = 8,
36
 
    MAX_ORIENTATION = 8
37
 
};
38
 
 
39
 
/*!
40
 
 * \brief The OrientationCorrection struct
41
 
 */
42
 
class OrientationCorrection
43
 
{
44
 
public:
45
 
    static OrientationCorrection fromOrientation(Orientation o);
46
 
    static OrientationCorrection identity();
47
 
    static Orientation rotateOrientation(Orientation orientation, bool left);
48
 
 
49
 
    QTransform toTransform() const;
50
 
 
51
 
    bool isFlippedFrom(const OrientationCorrection& other) const;
52
 
    int getNormalizedRotationDifference(const OrientationCorrection& other) const;
53
 
 
54
 
private:
55
 
    OrientationCorrection(double rotation_angle, double horizontal_scale_factor)
56
 
        : m_rotationAngle(rotation_angle),
57
 
          m_horizontalScaleFactor(horizontal_scale_factor) { }
58
 
 
59
 
    const double m_rotationAngle;
60
 
    const double m_horizontalScaleFactor;
61
 
};
62
 
 
63
 
 
64
 
#endif // GALLERY_ORIENTATION_H_