mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 13:06:59 -04:00
added native look editor and the set info panel
git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@82 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
@@ -27,23 +27,26 @@ void DataViewer::draw(DC& dc) {
|
||||
StyleSheetP stylesheet = set->stylesheetFor(card);
|
||||
StyleSheetSettings& ss = settings.stylesheetSettingsFor(*stylesheet);
|
||||
RotatedDC rdc(dc, ss.card_angle(), stylesheet->getCardRect(), ss.card_zoom(), ss.card_anti_alias() && !nativeLook());
|
||||
draw(rdc);
|
||||
draw(rdc, set->stylesheet->card_background);
|
||||
}
|
||||
void DataViewer::draw(RotatedDC& dc) {
|
||||
void DataViewer::draw(RotatedDC& dc, const Color& background) {
|
||||
if (!set) return; // no set specified, don't draw anything
|
||||
// fill with background color
|
||||
dc.SetPen(*wxTRANSPARENT_PEN);
|
||||
dc.SetBrush(set->stylesheet->card_background);
|
||||
dc.SetBrush(background);
|
||||
dc.DrawRectangle(dc.getInternalRect());
|
||||
// update style scripts
|
||||
if (card) set->updateFor(card);
|
||||
// draw values
|
||||
FOR_EACH(v, viewers) { // draw low z index fields first
|
||||
if (v->getStyle()->visible) {// visible
|
||||
v->draw(dc);
|
||||
drawViewer(dc, *v);
|
||||
}
|
||||
}
|
||||
}
|
||||
void DataViewer::drawViewer(RotatedDC& dc, ValueViewer& v) {
|
||||
v.draw(dc);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : Utility for ValueViewers
|
||||
|
||||
@@ -80,8 +83,9 @@ void DataViewer::setStyles(IndexMap<FieldP,StyleP>& styles) {
|
||||
viewers.clear();
|
||||
FOR_EACH(s, styles) {
|
||||
if ((s->visible || s->visible.isScripted()) &&
|
||||
(s->width || s->width .isScripted()) &&
|
||||
(s->height || s->height .isScripted())) {
|
||||
nativeLook() || (
|
||||
(s->width || s->width .isScripted()) &&
|
||||
(s->height || s->height .isScripted()))) {
|
||||
// no need to make a viewer for things that are always invisible
|
||||
viewers.push_back(makeViewer(s));
|
||||
// REMOVEME //TODO //%%%
|
||||
|
||||
@@ -28,9 +28,11 @@ class DataViewer : public SetView {
|
||||
// --------------------------------------------------- : Drawing
|
||||
|
||||
/// Draw the current (card/data) to the given dc
|
||||
void draw(DC& dc);
|
||||
virtual void draw(DC& dc);
|
||||
/// Draw the current (card/data) to the given dc
|
||||
virtual void draw(RotatedDC& dc);
|
||||
virtual void draw(RotatedDC& dc, const Color& background);
|
||||
/// Draw a single viewer
|
||||
virtual void drawViewer(RotatedDC& dc, ValueViewer& v);
|
||||
|
||||
// --------------------------------------------------- : Utility for ValueViewers
|
||||
|
||||
|
||||
@@ -14,13 +14,13 @@ DECLARE_TYPEOF_COLLECTION(TextElementP);
|
||||
|
||||
// ----------------------------------------------------------------------------- : TextElements
|
||||
|
||||
void TextElements::draw(RotatedDC& dc, double scale, const RealRect& rect, double* xs, DrawWhat what, size_t start, size_t end) const {
|
||||
void TextElements::draw(RotatedDC& dc, double scale, const RealRect& rect, const double* xs, DrawWhat what, size_t start, size_t end) const {
|
||||
FOR_EACH_CONST(e, elements) {
|
||||
size_t start_ = max(start, e->start);
|
||||
size_t end_ = min(end, e->end);
|
||||
if (start_ < end_) {
|
||||
e->draw(dc, scale,
|
||||
RealRect(rect.position.x + xs[start_-start], rect.position.y,
|
||||
RealRect(rect.position.x + xs[start_-start] - xs[0], rect.position.y,
|
||||
xs[end_-start] - xs[start_-start], rect.size.height),
|
||||
xs + start_ - start, what, start_, end_);
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ class TextElement {
|
||||
/// Draw a subsection section of the text in the given rectangle
|
||||
/** xs give the x coordinates for each character
|
||||
* this->start <= start < end <= this->end <= text.size() */
|
||||
virtual void draw (RotatedDC& dc, double scale, const RealRect& rect, double* xs, DrawWhat what, size_t start, size_t end) const = 0;
|
||||
virtual void draw (RotatedDC& dc, double scale, const RealRect& rect, const double* xs, DrawWhat what, size_t start, size_t end) const = 0;
|
||||
/// Get information on all characters in the range [start...end) and store them in out
|
||||
virtual void getCharInfo(RotatedDC& dc, double scale, vector<CharInfo>& out) const = 0;
|
||||
/// Return the minimum scale factor allowed (starts at 1)
|
||||
@@ -96,7 +96,7 @@ class TextElement {
|
||||
class TextElements : public vector<TextElementP> {
|
||||
public:
|
||||
/// Draw all the elements (as need to show the range start..end)
|
||||
void draw (RotatedDC& dc, double scale, const RealRect& rect, double* xs, DrawWhat what, size_t start, size_t end) const;
|
||||
void draw (RotatedDC& dc, double scale, const RealRect& rect, const double* xs, DrawWhat what, size_t start, size_t end) const;
|
||||
// Get information on all characters in the range [start...end) and store them in out
|
||||
void getCharInfo(RotatedDC& dc, double scale, size_t start, size_t end, vector<CharInfo>& out) const;
|
||||
/// Return the minimum scale factor allowed by all elements
|
||||
@@ -131,7 +131,7 @@ class FontTextElement : public SimpleTextElement {
|
||||
, font(font)
|
||||
{}
|
||||
|
||||
virtual void draw (RotatedDC& dc, double scale, const RealRect& rect, double* xs, DrawWhat what, size_t start, size_t end) const;
|
||||
virtual void draw (RotatedDC& dc, double scale, const RealRect& rect, const double* xs, DrawWhat what, size_t start, size_t end) const;
|
||||
virtual void getCharInfo(RotatedDC& dc, double scale, vector<CharInfo>& out) const;
|
||||
virtual double minScale() const;
|
||||
private:
|
||||
@@ -147,7 +147,7 @@ class SymbolTextElement : public SimpleTextElement {
|
||||
, font(font), ctx(*ctx)
|
||||
{}
|
||||
|
||||
virtual void draw (RotatedDC& dc, double scale, const RealRect& rect, double* xs, DrawWhat what, size_t start, size_t end) const;
|
||||
virtual void draw (RotatedDC& dc, double scale, const RealRect& rect, const double* xs, DrawWhat what, size_t start, size_t end) const;
|
||||
virtual void getCharInfo(RotatedDC& dc, double scale, vector<CharInfo>& out) const;
|
||||
virtual double minScale() const;
|
||||
private:
|
||||
@@ -172,7 +172,7 @@ class HorizontalLineTextElement : public TextElement {
|
||||
public:
|
||||
HorizontalLineTextElement(const String& text, size_t start ,size_t end) : TextElement(text, start, end) {}
|
||||
|
||||
virtual void draw (RotatedDC& dc, double scale, const RealRect& rect, double* xs, DrawWhat what, size_t start, size_t end) const;
|
||||
virtual void draw (RotatedDC& dc, double scale, const RealRect& rect, const double* xs, DrawWhat what, size_t start, size_t end) const;
|
||||
virtual void getCharInfo(RotatedDC& dc, double scale, vector<CharInfo>& out) const;
|
||||
virtual double minScale() const;
|
||||
};
|
||||
@@ -185,7 +185,7 @@ class CompoundTextElement : public TextElement {
|
||||
public:
|
||||
CompoundTextElement(const String& text, size_t start ,size_t end) : TextElement(text, start, end) {}
|
||||
|
||||
virtual void draw (RotatedDC& dc, double scale, const RealRect& rect, double* xs, DrawWhat what, size_t start, size_t end) const;
|
||||
virtual void draw (RotatedDC& dc, double scale, const RealRect& rect, const double* xs, DrawWhat what, size_t start, size_t end) const;
|
||||
virtual RealSize charSize(RotatedDC& dc, double scale, size_t index) const;
|
||||
|
||||
private:
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
// ----------------------------------------------------------------------------- : FontTextElement
|
||||
|
||||
void FontTextElement::draw(RotatedDC& dc, double scale, const RealRect& rect, double* xs, DrawWhat what, size_t start, size_t end) const {
|
||||
void FontTextElement::draw(RotatedDC& dc, double scale, const RealRect& rect, const double* xs, DrawWhat what, size_t start, size_t end) const {
|
||||
dc.SetFont(font->font, font->size * scale);
|
||||
|
||||
if (end != start && text.substr(end-1, 1) == _("\n")) end -= 1; // don't draw the newline character at the end
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
// ----------------------------------------------------------------------------- : HorizontalLineTextElement
|
||||
|
||||
void HorizontalLineTextElement::draw(RotatedDC& dc, double scale, const RealRect& rect, double* xs, DrawWhat what, size_t start, size_t end) const {
|
||||
void HorizontalLineTextElement::draw(RotatedDC& dc, double scale, const RealRect& rect, const double* xs, DrawWhat what, size_t start, size_t end) const {
|
||||
// handled by TextViewer
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
// ----------------------------------------------------------------------------- : SymbolTextElement
|
||||
|
||||
void SymbolTextElement::draw(RotatedDC& dc, double scale, const RealRect& rect, double* xs, DrawWhat what, size_t start, size_t end) const {
|
||||
void SymbolTextElement::draw(RotatedDC& dc, double scale, const RealRect& rect, const double* xs, DrawWhat what, size_t start, size_t end) const {
|
||||
if (font.font) {
|
||||
font.font->draw(dc, ctx, rect, font.size * scale, font.alignment, text.substr(start, end-start));
|
||||
}
|
||||
|
||||
@@ -257,11 +257,11 @@ bool TextViewer::prepareLinesScale(RotatedDC& dc, const String& text, const Text
|
||||
}
|
||||
|
||||
double TextViewer::lineLeft(RotatedDC& dc, const TextStyle& style, double y) {
|
||||
return 0;
|
||||
return 0 + style.padding_left;
|
||||
// return style.mask.rowLeft(y, dc.getInternalSize()) + style.padding_left;
|
||||
}
|
||||
double TextViewer::lineRight(RotatedDC& dc, const TextStyle& style, double y) {
|
||||
return style.width;
|
||||
return style.width - style.padding_right;
|
||||
// return style.mask.rowRight(y, dc.getInternalSize()) - style.padding_right;
|
||||
}
|
||||
ContourMask::ContourMask() {} // MOVEME //@@
|
||||
|
||||
Reference in New Issue
Block a user