Merge pull request #3596 from mapycz/text-simple-placement-center
Text simple placement: add center 'C' placement
This commit is contained in:
commit
e5a93bce52
3 changed files with 5 additions and 10 deletions
|
@ -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>;
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue