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