Rename image_shape.vertical_mirror_ to mirror_.

It is in fact (and always was) mirroring horizontally.
This commit is contained in:
Tommy 2022-05-31 01:17:04 +12:00
parent 25a908f9ac
commit 638c02b59e
4 changed files with 17 additions and 10 deletions

View file

@ -154,7 +154,7 @@ where calculated_width = {__GUI_IMAGE_WIDTH}
w = "{__GUI_IMAGE_DISPLAYED_WIDTH}"
h = "{__GUI_IMAGE_DISPLAYED_HEIGHT}"
name = "(portrait_image)"
vertical_mirror = "(portrait_mirror)"
mirror = "(portrait_mirror)"
[/image]
[/draw]
@ -189,7 +189,7 @@ where calculated_width = {__GUI_IMAGE_WIDTH}
w = "{__GUI_IMAGE_DISPLAYED_WIDTH}"
h = "{__GUI_IMAGE_DISPLAYED_HEIGHT}"
name = "(portrait_image)"
vertical_mirror = "(portrait_mirror)"
mirror = "(portrait_mirror)"
[/image]
[/draw]
@ -224,7 +224,7 @@ where calculated_width = {__GUI_IMAGE_WIDTH}
w = "{__GUI_IMAGE_DISPLAYED_WIDTH}"
h = "{__GUI_IMAGE_DISPLAYED_HEIGHT}"
name = "(portrait_image)"
vertical_mirror = "(portrait_mirror)"
mirror = "(portrait_mirror)"
[/image]
[image]
@ -233,7 +233,7 @@ where calculated_width = {__GUI_IMAGE_WIDTH}
w = "{__GUI_IMAGE_DISPLAYED_WIDTH}"
h = "{__GUI_IMAGE_DISPLAYED_HEIGHT}"
name = "(second_portrait_image)"
vertical_mirror = "(second_portrait_mirror)"
mirror = "(second_portrait_mirror)"
[/image]
[/draw]

View file

@ -124,7 +124,7 @@
{DEFAULT_KEY "h" f_unsigned 0}
{DEFAULT_KEY "name" f_string ""}
{DEFAULT_KEY "resize_mode" resize_mode scale}
{DEFAULT_KEY "vertical_mirror" f_bool false}
{DEFAULT_KEY "mirror" f_bool false}
{DEFAULT_KEY "w" f_unsigned 0}
{DEFAULT_KEY "x" f_unsigned 0}
{DEFAULT_KEY "y" f_unsigned 0}

View file

@ -322,8 +322,7 @@ image_shape::image_shape(const config& cfg, wfl::action_function_symbol_table& f
, image_()
, image_name_(cfg["name"])
, resize_mode_(get_resize_mode(cfg["resize_mode"]))
// TODO: highdpi - this is NOT vertical mirroring, but horizontal. rename.
, vertical_mirror_(cfg["vertical_mirror"])
, mirror_(cfg.get_old_attribute("mirror", "vertical_mirror", "image"))
, actions_formula_(cfg["actions"], &functions)
{
const std::string& debug = (cfg["debug"]);
@ -414,7 +413,11 @@ void image_shape::draw(
// TODO: highdpi - clipping?
// TODO: highdpi - vertical_mirror_ - just needs a RenderCopyEx wrapper in CVideo. Also note that it is NOT for vertical mirroring, but horizontal.
if (mirror_(variables) && (resize_mode_ == resize_mode::tile
|| resize_mode_ == resize_mode::tile_center)) {
// Not difficult to implement, but will anyone ever use it?
WRN_GUI_D << "mirrored tiling images unimplemented" << std::endl;
}
// What to do with the image depends on whether we need to tile it or not.
switch (resize_mode_) {
@ -431,7 +434,11 @@ void image_shape::draw(
// TODO: highdpi - texture API to set filtering mode, if actually needed
// TODO: highdpi - set texture filtering here, if this is desirable
// TODO: highdpi - is there any real difference between scale and stretch?
draw::blit(tex, adjusted_draw_loc);
if (mirror_(variables)) {
draw::flipped(tex, adjusted_draw_loc);
} else {
draw::blit(tex, adjusted_draw_loc);
}
break;
default:
ERR_GUI_D << "Image: unrecognized resize mode." << std::endl;

View file

@ -395,7 +395,7 @@ private:
resize_mode resize_mode_;
/** Mirror the image over the vertical axis. */
typed_formula<bool> vertical_mirror_;
typed_formula<bool> mirror_;
// TODO: use a typed_formula?
wfl::formula actions_formula_;