mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 04:57:00 -04:00
Various tweaks and fixes, mostly to the drop down lists
git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@620 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
// ----------------------------------------------------------------------------- : SymbolTextElement
|
||||
|
||||
void SymbolTextElement::draw(RotatedDC& dc, double scale, const RealRect& rect, const double* xs, DrawWhat what, size_t start, size_t end) const {
|
||||
if (!(what & DRAW_NORMAL)) return;
|
||||
if (font.font) {
|
||||
font.font->draw(dc, ctx, rect, font.size * scale, font.alignment, content.substr(start - this->start, end-start));
|
||||
}
|
||||
|
||||
@@ -40,9 +40,9 @@ struct TextViewer::Line {
|
||||
return top + line_height > 0 && top < rot.getInternalSize().height;
|
||||
}
|
||||
|
||||
/// Draws a selection indicator on this line from start to end
|
||||
/// Get a rectangle of the selection on this line
|
||||
/** start and end need not be in this line */
|
||||
void drawSelection(RotatedDC& dc, size_t start, size_t end);
|
||||
RealRect selectionRectangle(const Rotation& rot, size_t start, size_t end);
|
||||
};
|
||||
|
||||
size_t TextViewer::Line::posToIndex(double x) const {
|
||||
@@ -89,6 +89,13 @@ void TextViewer::draw(RotatedDC& dc, const TextStyle& style, DrawWhat what) {
|
||||
}
|
||||
}
|
||||
|
||||
/// Intersection between two rectangles
|
||||
RealRect intersect(const RealRect& a, const RealRect& b) {
|
||||
RealPoint tl = piecewise_max(a.topLeft(), b.topLeft());
|
||||
RealPoint br = piecewise_min(a.bottomRight(), b.bottomRight());
|
||||
return RealRect(tl, RealSize(br - tl));
|
||||
}
|
||||
|
||||
void TextViewer::drawSelection(RotatedDC& dc, const TextStyle& style, size_t sel_start, size_t sel_end) {
|
||||
Rotater r(dc, style.getRotation());
|
||||
if (sel_start == sel_end) return;
|
||||
@@ -96,18 +103,25 @@ void TextViewer::drawSelection(RotatedDC& dc, const TextStyle& style, size_t sel
|
||||
dc.SetBrush(*wxBLACK_BRUSH);
|
||||
dc.SetPen(*wxTRANSPARENT_PEN);
|
||||
dc.SetLogicalFunction(wxINVERT);
|
||||
RealRect prev_rect(0,0,0,0);
|
||||
FOR_EACH(l, lines) {
|
||||
l.drawSelection(dc, sel_start, sel_end);
|
||||
RealRect rect = l.selectionRectangle(dc, sel_start, sel_end);
|
||||
if (rect.height > 0) dc.DrawRectangle(rect);
|
||||
// compensate for overlap between lines
|
||||
RealRect overlap = intersect(rect, prev_rect);
|
||||
if (overlap.height > 0 && overlap.width > 0) dc.DrawRectangle(overlap);
|
||||
prev_rect = rect;
|
||||
}
|
||||
dc.SetLogicalFunction(wxCOPY);
|
||||
}
|
||||
|
||||
void TextViewer::Line::drawSelection(RotatedDC& dc, size_t sel_start, size_t sel_end) {
|
||||
if (!visible(dc)) return;
|
||||
if (sel_start < end() && sel_end > start) {
|
||||
RealRect TextViewer::Line::selectionRectangle(const Rotation& rot, size_t sel_start, size_t sel_end) {
|
||||
if (visible(rot) && sel_start < end() && sel_end > start) {
|
||||
double x1 = positions[max(start, sel_start) - start];
|
||||
double x2 = positions[min(end(), sel_end) - start];
|
||||
dc.DrawRectangle(RealRect(x1, top, x2 - x1, line_height));
|
||||
return RealRect(x1, top, x2 - x1, line_height);
|
||||
} else {
|
||||
return RealRect(0,0,0,0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ void ChoiceValueViewer::draw(RotatedDC& dc) {
|
||||
} else {
|
||||
img_options.width = (int) dc.trX(style().width);
|
||||
img_options.height = (int) dc.trY(style().height);
|
||||
img_options.preserve_aspect = style().alignment == ALIGN_STRETCH ? ASPECT_STRETCH : ASPECT_FIT;
|
||||
img_options.preserve_aspect = (style().alignment & ALIGN_STRETCH) ? ASPECT_STRETCH : ASPECT_FIT;
|
||||
}
|
||||
Image image = img.generate(img_options, true);
|
||||
ImageCombine combine = img.combine();
|
||||
|
||||
@@ -70,8 +70,8 @@ void ColorValueViewer::draw(RotatedDC& dc) {
|
||||
|
||||
bool ColorValueViewer::containsPoint(const RealPoint& p) const {
|
||||
// distance to each side
|
||||
double left = p.x - style().left, right = style().left + style().width - p.x - 1;
|
||||
double top = p.y - style().top, bottom = style().top + style().height - p.y - 1;
|
||||
double left = p.x - style().left, right = style().right - p.x - 1;
|
||||
double top = p.y - style().top, bottom = style().bottom - p.y - 1;
|
||||
if (left < 0 || right < 0 || top < 0 || bottom < 0 || // outside bounding box
|
||||
(left >= style().left_width && right >= style().right_width && // outside horizontal border
|
||||
top >= style().top_width && bottom >= style().bottom_width)) { // outside vertical border
|
||||
|
||||
@@ -29,10 +29,12 @@ void TextValueViewer::draw(RotatedDC& dc) {
|
||||
if (!v.prepared()) {
|
||||
v.prepare(dc, value().value(), style(), viewer.getContext());
|
||||
}
|
||||
if (viewer.drawFocus() && isCurrent()) {
|
||||
v.draw(dc, style(), DRAW_ACTIVE);
|
||||
}
|
||||
v.draw(dc, style(), (DrawWhat)(
|
||||
DRAW_NORMAL
|
||||
| (viewer.drawBorders() ? DRAW_BORDERS : 0)
|
||||
| (viewer.drawFocus() && isCurrent() ? DRAW_ACTIVE : 0)
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user