1 // Aseprite Document Library 2 // Copyright (c) 2001-2015 David Capello 3 // 4 // This file is released under the terms of the MIT license. 5 // Read LICENSE.txt for more information. 6 7 #ifndef DOC_MASK_BOUNDARIES_H_INCLUDED 8 #define DOC_MASK_BOUNDARIES_H_INCLUDED 9 #pragma once 10 11 #include "gfx/rect.h" 12 13 #include <vector> 14 15 namespace doc { 16 class Image; 17 18 class MaskBoundaries { 19 public: 20 class Segment { 21 public: Segment(bool open,const gfx::Rect & bounds)22 Segment(bool open, const gfx::Rect& bounds) 23 : m_open(open), m_bounds(bounds) { } 24 25 // Returns true if this segment enters into the boundaries. open()26 bool open() const { return m_open; } 27 bounds()28 const gfx::Rect& bounds() const { return m_bounds; } offset(int x,int y)29 void offset(int x, int y) { m_bounds.offset(x, y); } vertical()30 bool vertical() const { return m_bounds.w == 0; } horizontal()31 bool horizontal() const { return m_bounds.h == 0; } 32 33 private: 34 bool m_open; 35 gfx::Rect m_bounds; 36 37 friend class MaskBoundaries; 38 }; 39 40 typedef std::vector<Segment> list_type; 41 typedef list_type::iterator iterator; 42 typedef list_type::const_iterator const_iterator; 43 44 MaskBoundaries(const Image* bitmap); 45 begin()46 const_iterator begin() const { return m_segs.begin(); } end()47 const_iterator end() const { return m_segs.end(); } begin()48 iterator begin() { return m_segs.begin(); } end()49 iterator end() { return m_segs.end(); } 50 51 void offset(int x, int y); 52 53 private: 54 list_type m_segs; 55 }; 56 57 } // namespace doc 58 59 #endif 60