From 5c910e3059755261b910eefd9da46b68114be4fa Mon Sep 17 00:00:00 2001 From: twanvl Date: Mon, 30 Apr 2007 23:16:38 +0000 Subject: [PATCH] Added 'angle' property for choice fields git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@315 0fc631ac-6414-0410-93d0-97cfa31319b6 --- src/data/field/choice.cpp | 2 ++ src/data/field/choice.hpp | 1 + src/gfx/rotate_image.cpp | 13 +++++-------- src/render/value/choice.cpp | 3 ++- src/util/rotation.cpp | 4 ++-- src/util/rotation.hpp | 2 +- 6 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/data/field/choice.cpp b/src/data/field/choice.cpp index b72dd5a8..bee2258f 100644 --- a/src/data/field/choice.cpp +++ b/src/data/field/choice.cpp @@ -165,6 +165,7 @@ ChoiceStyle::ChoiceStyle(const ChoiceFieldP& field) , colors_card_list(false) , combine(COMBINE_NORMAL) , alignment(ALIGN_STRETCH) + , angle(0) , thumbnails(nullptr) , thumbnail_age(1) // thumbnails were made before the beginning of time , invalidated_images(false) @@ -231,6 +232,7 @@ IMPLEMENT_REFLECTION(ChoiceStyle) { REFLECT_N("mask",mask_filename); REFLECT(combine); REFLECT(alignment); + REFLECT(angle); REFLECT(colors_card_list); REFLECT(font); REFLECT(choice_images); diff --git a/src/data/field/choice.hpp b/src/data/field/choice.hpp index a8743e5c..55f1ee8c 100644 --- a/src/data/field/choice.hpp +++ b/src/data/field/choice.hpp @@ -131,6 +131,7 @@ class ChoiceStyle : public Style { ImageCombine combine; ///< Combining mode for drawing the images Alignment alignment; ///< Alignment of images Image mask; ///< The actual mask image + int angle; ///< Angle by which the images are rotated wxImageList* thumbnails; ///< Thumbnails for the choices Age thumbnail_age; ///< Age the thumbnails were generated bool invalidated_images; ///< Have the images been invalidated? diff --git a/src/gfx/rotate_image.cpp b/src/gfx/rotate_image.cpp index 9d5cbad9..fa8f37e2 100644 --- a/src/gfx/rotate_image.cpp +++ b/src/gfx/rotate_image.cpp @@ -83,13 +83,10 @@ struct Rotate270 { // ----------------------------------------------------------------------------- : Interface Image rotate_image(const Image& image, int angle) { - if (angle == 90) { - return rotate_image_impl(image); - } else if (angle == 180){ - return rotate_image_impl(image); - } else if (angle == 270){ - return rotate_image_impl(image); - } else{ - return image; + switch (angle % 360) { + case 90: return rotate_image_impl (image); + case 180: return rotate_image_impl(image); + case 270: return rotate_image_impl(image); + default: return image; } } diff --git a/src/render/value/choice.cpp b/src/render/value/choice.cpp index 9dc78a4a..28f884b7 100644 --- a/src/render/value/choice.cpp +++ b/src/render/value/choice.cpp @@ -43,7 +43,8 @@ void ChoiceValueViewer::draw(RotatedDC& dc) { // draw dc.DrawImage(i->image, align_in_rect(style().alignment, RealSize(i->image.GetWidth(), i->image.GetHeight()), style().getRect()), - i->combine == COMBINE_NORMAL ? style().combine : i->combine + i->combine == COMBINE_NORMAL ? style().combine : i->combine, + style().angle ); margin = dc.trInvS(i->image.GetWidth()) + 1; } diff --git a/src/util/rotation.cpp b/src/util/rotation.cpp index 78adc6d7..af877cc0 100644 --- a/src/util/rotation.cpp +++ b/src/util/rotation.cpp @@ -151,8 +151,8 @@ void RotatedDC::DrawBitmap(const Bitmap& bitmap, const RealPoint& pos) { DrawImage(bitmap.ConvertToImage(), pos); } } -void RotatedDC::DrawImage (const Image& image, const RealPoint& pos, ImageCombine combine) { - Image rotated = rotate_image(image, angle); +void RotatedDC::DrawImage (const Image& image, const RealPoint& pos, ImageCombine combine, int angle) { + Image rotated = rotate_image(image, angle + this->angle); wxRect r = trNoNegNoZoom(RealRect(pos, RealSize(image.GetWidth(), image.GetHeight()))); draw_combine_image(dc, r.x, r.y, rotated, combine); } diff --git a/src/util/rotation.hpp b/src/util/rotation.hpp index 583c001c..16f8c1b1 100644 --- a/src/util/rotation.hpp +++ b/src/util/rotation.hpp @@ -142,7 +142,7 @@ class RotatedDC : public Rotation { /// Draw abitmap, it must already be zoomed! void DrawBitmap(const Bitmap& bitmap, const RealPoint& pos); /// Draw an image using the given combining mode, the image must already be zoomed! - void DrawImage (const Image& image, const RealPoint& pos, ImageCombine combine = COMBINE_NORMAL); + void DrawImage (const Image& image, const RealPoint& pos, ImageCombine combine = COMBINE_NORMAL, int angle = 0); void DrawLine (const RealPoint& p1, const RealPoint& p2); void DrawRectangle(const RealRect& r); void DrawRoundedRectangle(const RealRect& r, double radius);