New rotation system (see forum thread).

Major changes:
  - when rotating, the top left corner of the rectangle stays in place.
  - ValueViewers get a dc that is pre-rotated/translated for them, i.e. (0,0) is the top-left of the viewer (with ValueViewer::getRotation).
  - moved 'angle' from individual Styles to the Style base class.
  - any rotation angle is now possible. angle is still an int for now.

This warrants a version bump

git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@782 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
twanvl
2007-12-23 21:58:58 +00:00
parent 94e4a1ce9e
commit b79f52db84
47 changed files with 498 additions and 371 deletions
+14 -26
View File
@@ -27,21 +27,12 @@ bool ChoiceValueViewer::prepare(RotatedDC& dc) {
ImageCombine combine = style().combine;
style().loadMask(*viewer.stylesheet);
Bitmap bitmap; Image image;
img.generateCached(img_options, &style().mask, &combine, &bitmap, &image);
int w, h;
if (bitmap.Ok()) {
w = bitmap.GetWidth();
h = bitmap.GetHeight();
} else {
assert(image.Ok());
w = image.GetWidth();
h = image.GetHeight();
}
if (sideways(img_options.angle)) swap(w,h);
RealSize size;
img.generateCached(img_options, &style().mask, &combine, &bitmap, &image, &size);
// store content properties
if (style().content_width != w || style().content_height != h) {
style().content_width = w;
style().content_height = h;
if (style().content_width != size.width || style().content_height != size.height) {
style().content_width = size.width;
style().content_height = size.height;
return true;
}
}
@@ -64,21 +55,18 @@ void ChoiceValueViewer::draw(RotatedDC& dc) {
ImageCombine combine = style().combine;
style().loadMask(*viewer.stylesheet);
Bitmap bitmap; Image image;
img.generateCached(img_options, &style().mask, &combine, &bitmap, &image);
RealSize size;
img.generateCached(img_options, &style().mask, &combine, &bitmap, &image, &size);
size = dc.trInvS(size);
RealRect rect(align_in_rect(style().alignment, size, dc.getInternalRect()), size);
if (bitmap.Ok()) {
// just draw it
dc.DrawPreRotatedBitmap(bitmap,
align_in_rect(style().alignment, dc.trInvNoNeg(RealSize(bitmap)), style().getRect())
);
margin = dc.trInv(RealSize(bitmap)).width + 1;
dc.DrawPreRotatedBitmap(bitmap,rect);
} else {
// use combine mode
dc.DrawPreRotatedImage(image,
align_in_rect(style().alignment, dc.trInvNoNeg(RealSize(image)), style().getRect()),
combine
);
margin = dc.trInv(RealSize(image)).width + 1;
dc.DrawPreRotatedImage(image,rect,combine);
}
margin = size.width + 1;
} else if (nativeLook()) {
// always have the margin
margin = 17;
@@ -88,7 +76,7 @@ void ChoiceValueViewer::draw(RotatedDC& dc) {
// draw text
dc.SetFont(style().font, 1.0);
String text = tr(*viewer.stylesheet, value().value(), capitalize(value().value()));
RealPoint pos = align_in_rect(ALIGN_MIDDLE_LEFT, RealSize(0, dc.GetCharHeight()), style().getRect()) + RealSize(margin, 0);
RealPoint pos = align_in_rect(ALIGN_MIDDLE_LEFT, RealSize(0, dc.GetCharHeight()), dc.getInternalRect()) + RealSize(margin, 0);
if (style().font.hasShadow()) {
dc.SetTextForeground(style().font.shadow_color);
dc.DrawText(text, pos + style().font.shadow_displacement);
@@ -106,7 +94,7 @@ void ChoiceValueViewer::onStyleChange(int changes) {
void ChoiceValueViewer::getOptions(Rotation& rot, GeneratedImage::Options& opts) {
opts.package = viewer.stylesheet.get();
opts.local_package = &getSet();
opts.angle = rot.trAngle(style().angle);
opts.angle = rot.trAngle(0);
if (nativeLook()) {
opts.width = opts.height = 16;
opts.preserve_aspect = ASPECT_BORDER;