mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 13:06:59 -04:00
New symbol part list control that shows previews and has a built in editor
git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@529 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
@@ -12,6 +12,29 @@
|
||||
#include <util/error.hpp>
|
||||
#include <script/value.hpp> // for some strange reason the profile build needs this :(
|
||||
|
||||
// ----------------------------------------------------------------------------- : Color
|
||||
|
||||
template <> void GetDefaultMember::handle(const AColor& col) {
|
||||
handle((const Color&)col);
|
||||
}
|
||||
template <> void Reader::handle(AColor& col) {
|
||||
UInt r,g,b,a;
|
||||
if (wxSscanf(getValue().c_str(),_("rgb(%u,%u,%u)"),&r,&g,&b)) {
|
||||
col.Set(r,g,b);
|
||||
col.alpha = 255;
|
||||
} else if (wxSscanf(getValue().c_str(),_("rgba(%u,%u,%u,%u)"),&r,&g,&b,&a)) {
|
||||
col.Set(r,g,b);
|
||||
col.alpha = a;
|
||||
}
|
||||
}
|
||||
template <> void Writer::handle(const AColor& col) {
|
||||
if (col.alpha == 255) {
|
||||
handle(String::Format(_("rgb(%u,%u,%u)"), col.Red(), col.Green(), col.Blue()));
|
||||
} else {
|
||||
handle(String::Format(_("rgba(%u,%u,%u,%u)"), col.Red(), col.Green(), col.Blue(), col.alpha));
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : Symbol filtering
|
||||
|
||||
void filter_symbol(Image& symbol, const SymbolFilter& filter) {
|
||||
|
||||
@@ -20,9 +20,10 @@ class SymbolFilter;
|
||||
/// Color with alpha channel
|
||||
class AColor : public Color {
|
||||
public:
|
||||
int alpha; ///< The alpha value, in the range [0..255]
|
||||
inline AColor(int r, int g, int b, int a = 255) : Color(r,g,b), alpha(a) {}
|
||||
inline AColor(const Color& color, int a = 255) : Color(color), alpha(a) {}
|
||||
Byte alpha; ///< The alpha value, in the range [0..255]
|
||||
inline AColor() : alpha(0) {}
|
||||
inline AColor(Byte r, Byte g, Byte b, Byte a = 255) : Color(r,g,b), alpha(a) {}
|
||||
inline AColor(const Color& color, Byte a = 255) : Color(color), alpha(a) {}
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------- : Symbol filtering
|
||||
@@ -69,14 +70,14 @@ intrusive_ptr<SymbolFilter> read_new<SymbolFilter>(Reader& reader);
|
||||
class SolidFillSymbolFilter : public SymbolFilter {
|
||||
public:
|
||||
inline SolidFillSymbolFilter() {}
|
||||
inline SolidFillSymbolFilter(Color fill_color, Color border_color)
|
||||
inline SolidFillSymbolFilter(const AColor& fill_color, const AColor& border_color)
|
||||
: fill_color(fill_color), border_color(border_color)
|
||||
{}
|
||||
virtual AColor color(double x, double y, SymbolSet point) const;
|
||||
virtual String fillType() const;
|
||||
virtual bool operator == (const SymbolFilter& that) const;
|
||||
private:
|
||||
Color fill_color, border_color;
|
||||
AColor fill_color, border_color;
|
||||
DECLARE_REFLECTION();
|
||||
};
|
||||
|
||||
|
||||
@@ -72,10 +72,8 @@ void SymbolViewer::draw(DC& dc) {
|
||||
}
|
||||
}
|
||||
}
|
||||
// Draw all parts, in reverse order (bottom to top)
|
||||
FOR_EACH_REVERSE(p, symbol->parts) {
|
||||
combineSymbolPart(dc, *p, paintedSomething, buffersFilled, borderDC, interiorDC);
|
||||
}
|
||||
// Draw all parts
|
||||
combineSymbolPart(dc, *symbol, paintedSomething, buffersFilled, borderDC, interiorDC);
|
||||
|
||||
// Output the final parts from the buffer
|
||||
if (buffersFilled) {
|
||||
@@ -118,7 +116,8 @@ void SymbolViewer::combineSymbolPart(DC& dc, const SymbolPart& part, bool& paint
|
||||
} else if (const SymbolSymmetry* s = part.isSymbolSymmetry()) {
|
||||
// symmetry, already handled above
|
||||
} else if (const SymbolGroup* g = part.isSymbolGroup()) {
|
||||
FOR_EACH_CONST(p, g->parts) {
|
||||
// Draw all parts, in reverse order (bottom to top)
|
||||
FOR_EACH_CONST_REVERSE(p, g->parts) {
|
||||
combineSymbolPart(dc, *p, paintedSomething, buffersFilled, borderDC, interiorDC);
|
||||
}
|
||||
}
|
||||
@@ -147,6 +146,10 @@ void SymbolViewer::highlightPart(DC& dc, const SymbolShape& shape, HighlightStyl
|
||||
dc.SetBrush(*wxTRANSPARENT_BRUSH);
|
||||
dc.SetPen (wxPen(Color(255,0,0), 2));
|
||||
dc.DrawPolygon((int)points.size(), &points[0]);
|
||||
} else if (style == HIGHLIGHT_BORDER_DOT) {
|
||||
dc.SetBrush(*wxTRANSPARENT_BRUSH);
|
||||
dc.SetPen (wxPen(Color(255,0,0), 1, wxDOT));
|
||||
dc.DrawPolygon((int)points.size(), &points[0]);
|
||||
} else {
|
||||
dc.SetLogicalFunction(wxOR);
|
||||
dc.SetBrush(Color(0,0,64));
|
||||
@@ -164,8 +167,13 @@ void SymbolViewer::highlightPart(DC& dc, const SymbolSymmetry& sym) {
|
||||
// TODO
|
||||
}
|
||||
void SymbolViewer::highlightPart(DC& dc, const SymbolGroup& group, HighlightStyle style) {
|
||||
if (style == HIGHLIGHT_BORDER) {
|
||||
dc.SetBrush(*wxTRANSPARENT_BRUSH);
|
||||
dc.SetPen (wxPen(Color(255,0,0), 2));
|
||||
dc.DrawRectangle(rotation.tr(RealRect(group.min_pos, RealSize(group.max_pos - group.min_pos))));
|
||||
}
|
||||
FOR_EACH_CONST(part, group.parts) {
|
||||
highlightPart(dc, *part, style);
|
||||
highlightPart(dc, *part, (HighlightStyle)(style | HIGHLIGHT_LESS));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,9 +21,11 @@ Image render_symbol(const SymbolP& symbol, double border_radius = 0.05, int size
|
||||
|
||||
// ----------------------------------------------------------------------------- : Symbol Viewer
|
||||
|
||||
enum HighlightStyle {
|
||||
HIGHLIGHT_BORDER,
|
||||
HIGHLIGHT_INTERIOR
|
||||
enum HighlightStyle
|
||||
{ HIGHLIGHT_BORDER = 0x01
|
||||
, HIGHLIGHT_INTERIOR = 0x02
|
||||
, HIGHLIGHT_LESS = 0x10
|
||||
, HIGHLIGHT_BORDER_DOT = HIGHLIGHT_BORDER | HIGHLIGHT_LESS
|
||||
};
|
||||
|
||||
/// Class that knows how to draw a symbol
|
||||
|
||||
Reference in New Issue
Block a user