display

Layout and Rendering TUI library
git clone git://git.dimitrijedobrota.com/display.git
Log | Files | Refs | README | HACKING | CONTRIBUTING | CODE_OF_CONDUCT | BUILDING |

layout_pivot.cpp (1241B)


1 #include "display/layout_pivot.hpp" 2 3 #include "display/window_pivot.hpp" 4 5 namespace display 6 { 7 8 void LayoutPivot::resize(aplace_t aplc) 9 { 10 Layout::resize(aplc); 11 12 if (has_child()) { 13 get_child().set_pos(get_pos()); 14 get_child().resize(aplc); 15 } 16 } 17 18 pos_t LayoutPivot::get_pos() const 19 { 20 const auto [width, height] = adim(); 21 const display::sz_t midw = width / 2; 22 const display::sz_t midh = height / 2; 23 24 if (m_piv.x == PvtX::Left && m_piv.y == PvtY::Top) { 25 return {0, 0}; 26 } 27 28 if (m_piv.x == PvtX::Center && m_piv.y == PvtY::Top) { 29 return {midw, 0}; 30 } 31 32 if (m_piv.x == PvtX::Right && m_piv.y == PvtY::Top) { 33 return {width, 0}; 34 } 35 36 if (m_piv.x == PvtX::Right && m_piv.y == PvtY::Center) { 37 return {width, midh}; 38 } 39 40 if (m_piv.x == PvtX::Right && m_piv.y == PvtY::Bottom) { 41 return {width, height}; 42 } 43 44 if (m_piv.x == PvtX::Center && m_piv.y == PvtY::Bottom) { 45 return {midw, height}; 46 } 47 48 if (m_piv.x == PvtX::Left && m_piv.y == PvtY::Bottom) { 49 return {0, height}; 50 } 51 52 if (m_piv.x == PvtX::Left && m_piv.y == PvtY::Center) { 53 return {0, midh}; 54 } 55 56 if (m_piv.x == PvtX::Center && m_piv.y == PvtY::Center) { 57 return {midw, midh}; 58 } 59 60 return {0, 0}; 61 } 62 63 } // namespace display