displayLayout and Rendering TUI library | 
          
| git clone git://git.dimitrijedobrota.com/display.git | 
| Log | Files | Refs | README | LICENSE | HACKING | CONTRIBUTING | CODE_OF_CONDUCT | BUILDING | 
window_pivot.cpp (1109B)
    0 #include "display/window_pivot.hpp"
          
              2 #include "display/utility.hpp"
          
              4 namespace display
              5 {
          
              7 plc_t WindowPivot::place(plc_t aplc, piv_t piv, dim_t dim)
              8 {
              9   const auto [awth, ahth] = aplc.dim;
             10   const auto [wth, hgt] = dim;
          
             12   dim_t start(0, 0);
             13   dim_t end(0, 0);
          
             15   using display::add_lim, display::sub_lim;
          
             17   switch (piv.x) {
             18     case PvtX::Left:
             19       start.width = wth_t(0);
             20       end.width = add_lim(start.width, wth, awth);
             21       break;
             22     case PvtX::Center:
             23       start.width = awth / 2 - wth / 2;
             24       end.width = add_lim(start.width, wth, awth);
             25       break;
             26     case PvtX::Right:
             27       end.width = awth;
             28       start.width = end.width - wth;
             29       break;
             30   }
          
             32   switch (piv.y) {
             33     case PvtY::Top:
             34       start.height = hgt_t(0);
             35       end.height = add_lim(start.height, hgt, ahth);
             36       break;
             37     case PvtY::Center:
             38       start.height = ahth / 2 - hgt / 2;
             39       end.height = add_lim(start.height, hgt, ahth);
             40       break;
             41     case PvtY::Bottom:
             42       end.height = ahth;
             43       start.height = end.height - hgt;
             44       break;
             45   }
          
             47   return {aplc.pos + start, end - start};
             48 }
          
             50 }  // namespace display