src/proto2/Dimension.hh
branchno-netsession
changeset 35 e21cfda0edde
parent 34 1ea6554d703e
child 36 785d220fc6b7
equal deleted inserted replaced
34:1ea6554d703e 35:e21cfda0edde
     1 #ifndef DIMENSION_HH
       
     2 #define DIMENSION_HH
       
     3 
       
     4 #include <iostream>
       
     5 
       
     6 class Dimension {
       
     7     public:
       
     8         uint32_t w;
       
     9         uint32_t h;
       
    10 
       
    11         Dimension (uint32_t w, uint32_t h) : w(w), h(h) { }
       
    12 };
       
    13 
       
    14 class PositionDelta {
       
    15     public:
       
    16         int32_t dx;
       
    17         int32_t dy;
       
    18 
       
    19         PositionDelta (int32_t dx, int32_t dy) : dx(dx), dy(dy) { }
       
    20 };
       
    21 
       
    22 class Coordinate {
       
    23     public:
       
    24         uint32_t x;
       
    25         uint32_t y;
       
    26 
       
    27         Coordinate (uint32_t x, uint32_t y) : x(x), y(y) { }
       
    28 
       
    29         Coordinate &operator+= (const PositionDelta &d) {
       
    30             this->x += d.dx;
       
    31             this->y += d.dy;
       
    32 
       
    33             return *this;
       
    34         }
       
    35 
       
    36         Coordinate operator+ (const PositionDelta &d) {
       
    37             return Coordinate(x + d.dx, y + d.dy);
       
    38         }
       
    39 
       
    40         // Scale the coordinate so that it matches the pixel resolution
       
    41         uint32_t scaledX() { return x; }
       
    42 
       
    43         uint32_t scaledY() { return y; }
       
    44 };
       
    45 
       
    46 std::ostream& operator<< (std::ostream &s, const Coordinate &c);
       
    47 std::ostream& operator<< (std::ostream &s, const PositionDelta &c);
       
    48 
       
    49 #endif