Commit 68d34a0d authored by twanvl's avatar twanvl

Fixed: rotation adjust code was overwriting scripts;

Fixed: positioning of stretched + rotated text
parent f13720c6
......@@ -127,6 +127,13 @@ template <> StyleP read_new<Style>(Reader&) {
throw InternalError(_("IndexMap contains nullptr StyleP the application should have crashed already"));
}
inline bool is_set(const Scriptable<double>& x) {
return x.isScripted() || x < 100000;
}
inline bool is_setw(const Scriptable<double>& x) {
return x.isScripted() || abs(x) > 0.001;
}
int Style::update(Context& ctx) {
bool changed =
left .update(ctx)
......@@ -139,13 +146,13 @@ int Style::update(Context& ctx) {
| visible.update(ctx);
// determine automatic_side and attachment of rotation point
if (automatic_side == AUTO_UNKNOWN) {
if (right == 1000000) automatic_side = (AutomaticSide)(automatic_side | AUTO_RIGHT);
else if (width == 0) automatic_side = (AutomaticSide)(automatic_side | AUTO_WIDTH);
else if (left == 1000000) automatic_side = (AutomaticSide)(automatic_side | AUTO_LEFT);
if (!is_set (right)) automatic_side = (AutomaticSide)(automatic_side | AUTO_RIGHT);
else if (!is_setw(width)) automatic_side = (AutomaticSide)(automatic_side | AUTO_WIDTH);
else if (!is_set (left)) automatic_side = (AutomaticSide)(automatic_side | AUTO_LEFT);
else automatic_side = (AutomaticSide)(automatic_side | AUTO_LR);
if (bottom == 1000000) automatic_side = (AutomaticSide)(automatic_side | AUTO_BOTTOM);
else if (height == 0) automatic_side = (AutomaticSide)(automatic_side | AUTO_HEIGHT);
else if (top == 1000000) automatic_side = (AutomaticSide)(automatic_side | AUTO_TOP);
if (!is_set (bottom)) automatic_side = (AutomaticSide)(automatic_side | AUTO_BOTTOM);
else if (!is_setw(height)) automatic_side = (AutomaticSide)(automatic_side | AUTO_HEIGHT);
else if (!is_set (top)) automatic_side = (AutomaticSide)(automatic_side | AUTO_TOP);
else automatic_side = (AutomaticSide)(automatic_side | AUTO_TB);
changed = true;
}
......@@ -187,12 +194,8 @@ bool Style::isVisible() const {
&& abs(bottom) < 100000;
}
bool Style::hasSize() const {
int h = (abs(width) > 0 || width .isScripted())
+ (abs(left) < 100000 || left .isScripted())
+ (abs(right) < 100000 || right .isScripted());
int v = (abs(height) > 0 || height.isScripted())
+ (abs(top) < 100000 || top .isScripted())
+ (abs(bottom) < 100000 || bottom.isScripted());
int h = is_setw(width) + is_set(left) + is_set(right);
int v = is_setw(height) + is_set(top) + is_set(bottom);
return h >= 2 && v >= 2;
}
......
......@@ -53,6 +53,7 @@ TextStyle::TextStyle(const TextFieldP& field)
, line_height_line_max(0.0)
, paragraph_height(-1)
, direction(LEFT_TO_RIGHT)
, content_width(0), content_height(0), content_lines(0)
{}
double TextStyle::getStretch() const {
......
......@@ -86,7 +86,8 @@ void TextCtrl::onChangeSet() {
field->multi_line = multi_line;
style->width = 100;
style->height = 20;
style->left = style->top = 1;
style->left = 1;
style->top = 1;
style->font.color = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);
// assign to this control
IndexMap<FieldP,StyleP> styles; styles.add(field, style);
......
......@@ -120,6 +120,10 @@ class Scriptable {
inline operator const T& () const { return value; }
inline const T& operator ()() const { return value; }
inline T& mutate () { return value; }
inline void operator = (const T& value) {
this->value = value;
}
inline bool isScripted() const { return script; }
/// Has this value been read from a Reader?
inline bool hasBeenRead() const { return !script.unparsed.empty(); }
......
......@@ -203,7 +203,16 @@ void RotatedDC::DrawText (const String& text, const RealPoint& pos, int blur_ra
if (quality >= QUALITY_AA) {
RealRect r(pos, GetTextExtent(text));
RealRect r_ext = trRectToBB(r);
draw_resampled_text(dc, tr(pos), r_ext, stretch_ * getStretch(), angle, text, blur_radius, boldness);
RealPoint pos2 = tr(pos);
if (zoomX != zoomY) {
r.width *= zoomX / zoomY;
RealRect r_ext2 = trRectToBB(r);
pos2.x += r_ext2.x - r_ext.x;
pos2.y += r_ext2.y - r_ext.y;
r_ext.x = r_ext2.x;
r_ext.y = r_ext2.y;
}
draw_resampled_text(dc, pos2, r_ext, stretch_ * getStretch(), angle, text, blur_radius, boldness);
} else if (quality >= QUALITY_SUB_PIXEL) {
RealPoint p_ext = tr(pos)*text_scaling;
double usx,usy;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment