Merge pull request #3596 from mapycz/text-simple-placement-center

Text simple placement: add center 'C' placement
This commit is contained in:
Artem Pavlenko 2017-01-09 11:57:03 +01:00 committed by GitHub
commit e5a93bce52
3 changed files with 5 additions and 10 deletions

View file

@ -96,7 +96,8 @@ enum directions_e : std::uint8_t
SOUTHEAST, SOUTHEAST,
NORTHWEST, NORTHWEST,
SOUTHWEST, SOUTHWEST,
EXACT_POSITION EXACT_POSITION,
CENTER
}; };
using fontset_map = std::map<std::string, font_set>; using fontset_map = std::map<std::string, font_set>;

View file

@ -57,6 +57,7 @@ struct direction_name : x3::symbols<directions_e>
("NW", NORTHWEST) ("NW", NORTHWEST)
("SW", SOUTHWEST) ("SW", SOUTHWEST)
("X" , EXACT_POSITION) ("X" , EXACT_POSITION)
("C" , CENTER)
; ;
} }
} names; } names;

View file

@ -63,31 +63,24 @@ pixel_position evaluate_displacement(double dx, double dy, directions_e dir)
{ {
case EXACT_POSITION: case EXACT_POSITION:
return pixel_position(dx,dy); return pixel_position(dx,dy);
break;
case NORTH: case NORTH:
return pixel_position(0,-std::abs(dy)); return pixel_position(0,-std::abs(dy));
break;
case EAST: case EAST:
return pixel_position(std::abs(dx),0); return pixel_position(std::abs(dx),0);
break;
case SOUTH: case SOUTH:
return pixel_position(0,std::abs(dy)); return pixel_position(0,std::abs(dy));
break;
case WEST: case WEST:
return pixel_position(-std::abs(dx),0); return pixel_position(-std::abs(dx),0);
break;
case NORTHEAST: case NORTHEAST:
return pixel_position(std::abs(dx),-std::abs(dy)); return pixel_position(std::abs(dx),-std::abs(dy));
break;
case SOUTHEAST: case SOUTHEAST:
return pixel_position(std::abs(dx),std::abs(dy)); return pixel_position(std::abs(dx),std::abs(dy));
break;
case NORTHWEST: case NORTHWEST:
return pixel_position(-std::abs(dx),-std::abs(dy)); return pixel_position(-std::abs(dx),-std::abs(dy));
break;
case SOUTHWEST: case SOUTHWEST:
return pixel_position(-std::abs(dx),std::abs(dy)); return pixel_position(-std::abs(dx),std::abs(dy));
break; case CENTER:
return pixel_position(0, 0);
default: default:
return pixel_position(dx,dy); return pixel_position(dx,dy);
} }