~ubuntu-branches/ubuntu/quantal/shotwell/quantal

« back to all changes in this revision

Viewing changes to src/Box.vala

  • Committer: Package Import Robot
  • Author(s): Robert Ancell
  • Date: 2012-02-21 13:52:58 UTC
  • mto: This revision was merged to the branch mainline in revision 47.
  • Revision ID: package-import@ubuntu.com-20120221135258-ao9jiib5qicomq7q
Tags: upstream-0.11.92
ImportĀ upstreamĀ versionĀ 0.11.92

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright 2009-2011 Yorba Foundation
 
1
/* Copyright 2009-2012 Yorba Foundation
2
2
 *
3
3
 * This software is licensed under the GNU LGPL (version 2.1 or later).
4
4
 * See the COPYING file in this distribution. 
77
77
            int.max(corner1.x, corner2.x), int.max(corner1.y, corner2.y));
78
78
    }
79
79
    
 
80
    public static Box from_center(Gdk.Point center, int width, int height) {
 
81
        return Box(center.x - (width / 2), center.y - (height / 2),
 
82
                   center.x + (width / 2), center.y + (height / 2));
 
83
    }
 
84
    
80
85
    public int get_width() {
81
86
        assert(right >= left);
82
87
        
97
102
        return (left == box.left && top == box.top && right == box.right && bottom == box.bottom);
98
103
    }
99
104
    
 
105
    // Adjust width, preserving the box's center.
 
106
    public void adjust_width(int width) {
 
107
        int center_x = (left + right) / 2;
 
108
        left = center_x - (width / 2);
 
109
        right = center_x + (width / 2);
 
110
    }
 
111
 
 
112
    // Adjust height, preserving the box's center.
 
113
    public void adjust_height(int height) {
 
114
        int center_y = (top + bottom) / 2;
 
115
        top = center_y - (height / 2);
 
116
        bottom = center_y + (height / 2);
 
117
    }
 
118
    
100
119
    public Box get_scaled(Dimensions scaled) {
101
120
        double x_scale, y_scale;
102
121
        get_dimensions().get_scale_ratios(scaled, out x_scale, out y_scale);
156
175
        return rect;
157
176
    }
158
177
    
 
178
    public Gdk.Point get_center() {
 
179
        return { (left + right) / 2, (top + bottom) / 2 };
 
180
    }
 
181
    
159
182
    public Box rotate_clockwise(Dimensions space) {
160
183
        int l = space.width - bottom - 1;
161
184
        int t = left;