mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-12 13:37:00 -04:00
Fixed TextCtrl to work for keyword properties;
Added wrapping of <> around parameters to TextElement; Added colors for keyword parameters; Added menu & toolbar for keyword panel; Fixed bug in package, save/save-as was the wrong way around; Added third quality setting to RotatedDC: using SetUserScale, this gets you more precise positioning. git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@250 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
@@ -79,3 +79,24 @@ template <> void Writer::handle(const Alignment& align) {
|
||||
template <> void GetDefaultMember::handle(const Alignment& align) {
|
||||
handle(to_string(align));
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : Direction
|
||||
|
||||
IMPLEMENT_REFLECTION_ENUM(Direction) {
|
||||
VALUE_N("left to right", LEFT_TO_RIGHT);
|
||||
VALUE_N("right to left", RIGHT_TO_LEFT);
|
||||
VALUE_N("top to bottom", TOP_TO_BOTTOM);
|
||||
VALUE_N("bottom to top", BOTTOM_TO_TOP);
|
||||
VALUE_N("horizontal", LEFT_TO_RIGHT);
|
||||
VALUE_N("vertical", TOP_TO_BOTTOM);
|
||||
}
|
||||
|
||||
RealPoint move_in_direction(Direction dir, const RealPoint& point, const RealSize to_move, double spacing) {
|
||||
switch (dir) {
|
||||
case LEFT_TO_RIGHT: return RealPoint(point.x + to_move.width + spacing, point.y);
|
||||
case RIGHT_TO_LEFT: return RealPoint(point.x - to_move.width - spacing, point.y);
|
||||
case TOP_TO_BOTTOM: return RealPoint(point.x, point.y + to_move.height + spacing);
|
||||
case BOTTOM_TO_TOP: return RealPoint(point.x, point.y - to_move.height - spacing);
|
||||
default: return point; // should not happen
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,5 +52,17 @@ double align_delta_y(Alignment align, double box_height, double obj_height);
|
||||
*/
|
||||
RealPoint align_in_rect(Alignment align, const RealSize& to_align, const RealRect& outer);
|
||||
|
||||
// ----------------------------------------------------------------------------- : Direction
|
||||
|
||||
/// Direction to place something in
|
||||
enum Direction {
|
||||
LEFT_TO_RIGHT, RIGHT_TO_LEFT,
|
||||
TOP_TO_BOTTOM, BOTTOM_TO_TOP
|
||||
};
|
||||
|
||||
/// Move a point in a direction
|
||||
/** If the direction is horizontal the to_move.width is used, otherwise to_move.height */
|
||||
RealPoint move_in_direction(Direction dir, const RealPoint& point, const RealSize to_move, double spacing = 0);
|
||||
|
||||
// ----------------------------------------------------------------------------- : EOF
|
||||
#endif
|
||||
|
||||
@@ -41,7 +41,7 @@ bool Package::isOpened() const {
|
||||
return !filename.empty();
|
||||
}
|
||||
bool Package::needSaveAs() const {
|
||||
return !filename.empty();
|
||||
return filename.empty();
|
||||
}
|
||||
String Package::name() const {
|
||||
// wxFileName is too slow (profiled)
|
||||
|
||||
+37
-10
@@ -111,24 +111,31 @@ Rotater::~Rotater() {
|
||||
|
||||
// ----------------------------------------------------------------------------- : RotatedDC
|
||||
|
||||
RotatedDC::RotatedDC(DC& dc, int angle, const RealRect& rect, double zoom, bool high_quality, bool is_internal)
|
||||
RotatedDC::RotatedDC(DC& dc, int angle, const RealRect& rect, double zoom, RenderQuality quality, bool is_internal)
|
||||
: Rotation(angle, rect, zoom, is_internal)
|
||||
, dc(dc), high_quality(high_quality)
|
||||
, dc(dc), quality(quality)
|
||||
{}
|
||||
|
||||
RotatedDC::RotatedDC(DC& dc, const Rotation& rotation, bool high_quality)
|
||||
RotatedDC::RotatedDC(DC& dc, const Rotation& rotation, RenderQuality quality)
|
||||
: Rotation(rotation)
|
||||
, dc(dc), high_quality(high_quality&&false)
|
||||
, dc(dc), quality(quality)
|
||||
{}
|
||||
|
||||
// ----------------------------------------------------------------------------- : RotatedDC : Drawing
|
||||
|
||||
void RotatedDC::DrawText (const String& text, const RealPoint& pos) {
|
||||
if (text.empty()) return;
|
||||
if (high_quality) {
|
||||
if (quality == QUALITY_AA) {
|
||||
RealRect r(pos, GetTextExtent(text));
|
||||
RealRect r_ext = trNoNeg(r);
|
||||
draw_resampled_text(dc, r_ext, revX(), revY(), angle, text);
|
||||
} else if (quality == QUALITY_SUB_PIXEL) {
|
||||
RealPoint p_ext = tr(pos)*text_scaling;
|
||||
double usx,usy;
|
||||
dc.GetUserScale(&usx, &usy);
|
||||
dc.SetUserScale(usx/text_scaling, usy/text_scaling);
|
||||
dc.DrawRotatedText(text, (int) p_ext.x, (int) p_ext.y, angle);
|
||||
dc.SetUserScale(usx, usy);
|
||||
} else {
|
||||
RealPoint p_ext = tr(pos);
|
||||
dc.DrawRotatedText(text, (int) p_ext.x, (int) p_ext.y, angle);
|
||||
@@ -172,24 +179,44 @@ void RotatedDC::SetTextForeground(const Color& color) { dc.SetTextForeground(col
|
||||
void RotatedDC::SetLogicalFunction(int function) { dc.SetLogicalFunction(function); }
|
||||
|
||||
void RotatedDC::SetFont(const wxFont& font) {
|
||||
SetFont(font, font.GetPointSize());
|
||||
if (quality == QUALITY_LOW) {
|
||||
dc.SetFont(font);
|
||||
} else {
|
||||
SetFont(font, font.GetPointSize());
|
||||
}
|
||||
}
|
||||
void RotatedDC::SetFont(wxFont font, double size) {
|
||||
font.SetPointSize((int) (trS(size) * (high_quality ? text_scaling : 1)));
|
||||
if (quality == QUALITY_LOW) {
|
||||
font.SetPointSize((int) trS(size));
|
||||
} else {
|
||||
font.SetPointSize((int) (trS(size) * text_scaling));
|
||||
}
|
||||
dc.SetFont(font);
|
||||
}
|
||||
|
||||
double RotatedDC::getFontSizeStep() const {
|
||||
return 1. / (high_quality ? text_scaling : 1);
|
||||
if (quality == QUALITY_LOW) {
|
||||
return 1;
|
||||
} else {
|
||||
return 1. / text_scaling;
|
||||
}
|
||||
}
|
||||
|
||||
RealSize RotatedDC::GetTextExtent(const String& text) const {
|
||||
int w, h;
|
||||
dc.GetTextExtent(text, &w, &h);
|
||||
return RealSize(w,h) / zoom / (high_quality ? text_scaling : 1);
|
||||
if (quality == QUALITY_LOW) {
|
||||
return RealSize(w,h) / zoom;
|
||||
} else {
|
||||
return RealSize(w,h) / zoom / text_scaling;
|
||||
}
|
||||
}
|
||||
double RotatedDC::GetCharHeight() const {
|
||||
return dc.GetCharHeight() / zoom / (high_quality ? text_scaling : 1);
|
||||
if (quality == QUALITY_LOW) {
|
||||
return dc.GetCharHeight() / zoom;
|
||||
} else {
|
||||
return dc.GetCharHeight() / zoom / text_scaling;
|
||||
}
|
||||
}
|
||||
|
||||
void RotatedDC::SetClippingRegion(const RealRect& rect) {
|
||||
|
||||
+11
-4
@@ -119,13 +119,20 @@ class Rotater {
|
||||
|
||||
// ----------------------------------------------------------------------------- : RotatedDC
|
||||
|
||||
/// Render quality of text
|
||||
enum RenderQuality {
|
||||
QUALITY_AA, ///< Our own anti aliassing
|
||||
QUALITY_SUB_PIXEL, ///< Sub-pixel positioning
|
||||
QUALITY_LOW, ///< Normal
|
||||
};
|
||||
|
||||
/// A DC with rotation applied
|
||||
/** All draw** functions take internal coordinates.
|
||||
*/
|
||||
class RotatedDC : public Rotation {
|
||||
public:
|
||||
RotatedDC(DC& dc, int angle, const RealRect& rect, double zoom, bool high_quality, bool is_internal = false);
|
||||
RotatedDC(DC& dc, const Rotation& rotation, bool high_quality);
|
||||
RotatedDC(DC& dc, int angle, const RealRect& rect, double zoom, RenderQuality quality, bool is_internal = false);
|
||||
RotatedDC(DC& dc, const Rotation& rotation, RenderQuality quality);
|
||||
|
||||
// --------------------------------------------------- : Drawing
|
||||
|
||||
@@ -165,8 +172,8 @@ class RotatedDC : public Rotation {
|
||||
inline wxDC& getDC() { return dc; }
|
||||
|
||||
private:
|
||||
wxDC& dc; ///< The actual dc
|
||||
bool high_quality; ///< Drawing using our own anti aliassing?
|
||||
wxDC& dc; ///< The actual dc
|
||||
RenderQuality quality; ///< Quality of the text
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------- : EOF
|
||||
|
||||
Reference in New Issue
Block a user