mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 04:57:00 -04:00
Dark mode
This commit is contained in:
@@ -70,11 +70,7 @@ typedef shared_ptr<wxMemoryDC> MemoryDCP;
|
||||
// Return a temporary DC with the same size as the parameter
|
||||
MemoryDCP getTempDC(DC& dc) {
|
||||
wxSize s = dc.GetSize();
|
||||
#ifdef __WXMSW__
|
||||
Bitmap buffer(s.GetWidth(), s.GetHeight(), 1);
|
||||
#else
|
||||
Bitmap buffer(s.GetWidth(), s.GetHeight(), 24);
|
||||
#endif
|
||||
Bitmap buffer(s.GetWidth(), s.GetHeight(), 24);
|
||||
MemoryDCP newDC(new wxMemoryDC);
|
||||
newDC->SelectObject(buffer);
|
||||
clearDC(*newDC, *wxBLACK_BRUSH);
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
// ----------------------------------------------------------------------------- : CompoundTextElement
|
||||
|
||||
void CompoundTextElement::draw(RotatedDC& dc, double scale, const RealRect& rect, const double* xs, DrawWhat what, size_t start, size_t end) const {
|
||||
void CompoundTextElement::draw(RotatedDC& dc, double scale, const RealRect& rect, const double* xs, DrawWhat what, size_t start, size_t end, bool native_look) const {
|
||||
for (auto const& e : children) {
|
||||
size_t start_ = max(start, e->start);
|
||||
size_t end_ = min(end, e->end);
|
||||
@@ -19,7 +19,7 @@ void CompoundTextElement::draw(RotatedDC& dc, double scale, const RealRect& rect
|
||||
e->draw(dc, scale,
|
||||
RealRect(rect.x + xs[start_ - start] - xs[0], rect.y,
|
||||
xs[end_ - start] - xs[start_ - start], rect.height),
|
||||
xs + start_ - start, what, start_, end_);
|
||||
xs + start_ - start, what, start_, end_, native_look);
|
||||
}
|
||||
if (end <= e->end) return; // nothing can be after this
|
||||
}
|
||||
@@ -54,18 +54,18 @@ double CompoundTextElement::scaleStep() const {
|
||||
|
||||
// ----------------------------------------------------------------------------- : AtomTextElement
|
||||
|
||||
void AtomTextElement::draw(RotatedDC& dc, double scale, const RealRect& rect, const double* xs, DrawWhat what, size_t start, size_t end) const {
|
||||
void AtomTextElement::draw(RotatedDC& dc, double scale, const RealRect& rect, const double* xs, DrawWhat what, size_t start, size_t end, bool native_look) const {
|
||||
if (what & DRAW_ACTIVE) {
|
||||
dc.SetPen(*wxTRANSPARENT_PEN);
|
||||
dc.SetBrush(background_color);
|
||||
dc.DrawRectangle(rect);
|
||||
}
|
||||
CompoundTextElement::draw(dc, scale, rect, xs, what, start, end);
|
||||
CompoundTextElement::draw(dc, scale, rect, xs, what, start, end, native_look);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : ErrorTextElement
|
||||
|
||||
void ErrorTextElement::draw(RotatedDC& dc, double scale, const RealRect& rect, const double* xs, DrawWhat what, size_t start, size_t end) const {
|
||||
void ErrorTextElement::draw(RotatedDC& dc, double scale, const RealRect& rect, const double* xs, DrawWhat what, size_t start, size_t end, bool native_look) const {
|
||||
// Draw wavy underline
|
||||
if (what & DRAW_ERRORS) {
|
||||
dc.SetPen(*wxRED_PEN);
|
||||
@@ -82,5 +82,5 @@ void ErrorTextElement::draw(RotatedDC& dc, double scale, const RealRect& rect, c
|
||||
}
|
||||
}
|
||||
// Draw the contents
|
||||
CompoundTextElement::draw(dc, scale, rect, xs, what, start, end);
|
||||
CompoundTextElement::draw(dc, scale, rect, xs, what, start, end, native_look);
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ public:
|
||||
/// 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, const 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, bool native_look) 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)
|
||||
@@ -77,7 +77,7 @@ public:
|
||||
, font(font), draw_as(draw_as), break_style(break_style)
|
||||
{}
|
||||
|
||||
void draw(RotatedDC& dc, double scale, const RealRect& rect, const double* xs, DrawWhat what, size_t start, size_t end) const override;
|
||||
void draw(RotatedDC& dc, double scale, const RealRect& rect, const double* xs, DrawWhat what, size_t start, size_t end, bool native_look) const override;
|
||||
void getCharInfo(RotatedDC& dc, double scale, vector<CharInfo>& out) const override;
|
||||
double minScale() const override;
|
||||
double scaleStep() const override;
|
||||
@@ -96,7 +96,7 @@ public:
|
||||
, font(font), ctx(*ctx)
|
||||
{}
|
||||
|
||||
void draw(RotatedDC& dc, double scale, const RealRect& rect, const double* xs, DrawWhat what, size_t start, size_t end) const override;
|
||||
void draw(RotatedDC& dc, double scale, const RealRect& rect, const double* xs, DrawWhat what, size_t start, size_t end, bool native_look) const override;
|
||||
void getCharInfo(RotatedDC& dc, double scale, vector<CharInfo>& out) const override;
|
||||
double minScale() const override;
|
||||
double scaleStep() const override;
|
||||
@@ -113,7 +113,7 @@ class CompoundTextElement : public TextElement {
|
||||
public:
|
||||
CompoundTextElement(size_t start, size_t end) : TextElement(start, end) {}
|
||||
|
||||
void draw(RotatedDC& dc, double scale, const RealRect& rect, const double* xs, DrawWhat what, size_t start, size_t end) const override;
|
||||
void draw(RotatedDC& dc, double scale, const RealRect& rect, const double* xs, DrawWhat what, size_t start, size_t end, bool native_look) const override;
|
||||
void getCharInfo(RotatedDC& dc, double scale, vector<CharInfo>& out) const override;
|
||||
double minScale() const override;
|
||||
double scaleStep() const override;
|
||||
@@ -130,7 +130,7 @@ class AtomTextElement : public CompoundTextElement {
|
||||
public:
|
||||
AtomTextElement(size_t start, size_t end, Color background_color) : CompoundTextElement(start, end), background_color(background_color) {}
|
||||
|
||||
void draw(RotatedDC& dc, double scale, const RealRect& rect, const double* xs, DrawWhat what, size_t start, size_t end) const override;
|
||||
void draw(RotatedDC& dc, double scale, const RealRect& rect, const double* xs, DrawWhat what, size_t start, size_t end, bool native_look) const override;
|
||||
private:
|
||||
Color background_color;
|
||||
};
|
||||
@@ -140,7 +140,7 @@ class ErrorTextElement : public CompoundTextElement {
|
||||
public:
|
||||
ErrorTextElement(size_t start, size_t end) : CompoundTextElement(start, end) {}
|
||||
|
||||
void draw(RotatedDC& dc, double scale, const RealRect& rect, const double* xs, DrawWhat what, size_t start, size_t end) const override;
|
||||
void draw(RotatedDC& dc, double scale, const RealRect& rect, const double* xs, DrawWhat what, size_t start, size_t end, bool native_look) const override;
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------- : TextElements
|
||||
|
||||
@@ -12,16 +12,23 @@
|
||||
|
||||
// ----------------------------------------------------------------------------- : FontTextElement
|
||||
|
||||
void FontTextElement::draw(RotatedDC& dc, double scale, const RealRect& rect, const 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, bool native_look) const {
|
||||
if ((what & draw_as) != draw_as) return; // don't draw
|
||||
// text
|
||||
String text = content.substr(start - this->start, end - start);
|
||||
if (!text.empty() && text.GetChar(text.size() - 1) == _('\n')) {
|
||||
text = text.substr(0, text.size() - 1); // don't draw last \n
|
||||
}
|
||||
// draw
|
||||
// draw
|
||||
Color font_color = font->color;
|
||||
RealSize margin(0, 0);
|
||||
if (native_look) {
|
||||
font->color = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);
|
||||
margin = RealSize(1., 0);
|
||||
}
|
||||
dc.SetFont(*font, scale);
|
||||
dc.DrawTextWithShadow(text, *font, rect.position());
|
||||
dc.DrawTextWithShadow(text, *font, rect.position() + margin);
|
||||
if (native_look) font->color = font_color;
|
||||
}
|
||||
|
||||
void FontTextElement::getCharInfo(RotatedDC& dc, double scale, vector<CharInfo>& out) const {
|
||||
|
||||
@@ -12,7 +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 {
|
||||
void SymbolTextElement::draw(RotatedDC& dc, double scale, const RealRect& rect, const double* xs, DrawWhat what, size_t start, size_t end, bool native_look) 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));
|
||||
|
||||
@@ -72,7 +72,7 @@ TextViewer::~TextViewer() {}
|
||||
|
||||
// ----------------------------------------------------------------------------- : Drawing
|
||||
|
||||
void TextViewer::draw(RotatedDC& dc, const TextStyle& style, DrawWhat what) {
|
||||
void TextViewer::draw(RotatedDC& dc, const TextStyle& style, DrawWhat what, bool native_look) {
|
||||
assert(!lines.empty());
|
||||
// draw anything?
|
||||
if (what == DRAW_NOTHING) return;
|
||||
@@ -88,11 +88,11 @@ void TextViewer::draw(RotatedDC& dc, const TextStyle& style, DrawWhat what) {
|
||||
// Draw characters separatly
|
||||
for (size_t i = 0 ; i < l.positions.size() - 1 ; ++i) {
|
||||
RealRect rect(l.positions[i], l.top, l.positions[i+1] - l.positions[i] , l.line_height);
|
||||
elements.draw(dc, scale, rect, &l.positions[i], what, l.start + i, l.start + i + 1);
|
||||
elements.draw(dc, scale, rect, &l.positions[i], what, l.start + i, l.start + i + 1, native_look);
|
||||
}
|
||||
} else {
|
||||
RealRect rect(l.positions.front(), l.top, l.width(), l.line_height);
|
||||
elements.draw(dc, scale, rect, &*l.positions.begin(), what, l.start, l.end());
|
||||
elements.draw(dc, scale, rect, &*l.positions.begin(), what, l.start, l.end(), native_look);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ public:
|
||||
/** The drawing information is cached,
|
||||
* before calling draw again with different text/style reset() should be called
|
||||
*/
|
||||
void draw(RotatedDC& dc, const TextStyle& style, DrawWhat what);
|
||||
void draw(RotatedDC& dc, const TextStyle& style, DrawWhat what, bool native_look);
|
||||
/// Draw an indicator for selected text
|
||||
void drawSelection(RotatedDC& dc, const TextStyle& style, size_t sel_start, size_t sel_end);
|
||||
/// Draw separators for <line> tags
|
||||
|
||||
@@ -21,7 +21,13 @@ bool ChoiceValueViewer::prepare(RotatedDC& dc) {
|
||||
}
|
||||
void ChoiceValueViewer::draw(RotatedDC& dc) {
|
||||
drawFieldBorder(dc);
|
||||
if (style().render_style & RENDER_HIDDEN) return;
|
||||
if (style().render_style & RENDER_HIDDEN) return;
|
||||
// render background
|
||||
if (nativeLook()) {
|
||||
dc.SetBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
|
||||
dc.SetPen(*wxTRANSPARENT_PEN);
|
||||
dc.DrawRectangle(RealRect(0, 0, dc.getWidth(), dc.getHeight()));
|
||||
}
|
||||
draw_choice_viewer(dc, *this, style(), value().value());
|
||||
}
|
||||
|
||||
@@ -101,11 +107,18 @@ void draw_choice_viewer(RotatedDC& dc, ValueViewer& viewer, ChoiceStyle& style,
|
||||
Alignment text_align = style.alignment;
|
||||
if (style.render_style & RENDER_IMAGE) {
|
||||
text_align = ALIGN_MIDDLE_LEFT; // can't align both text and image in the same way
|
||||
}
|
||||
Font& font = style.font;
|
||||
Color font_color = font.color;
|
||||
if (viewer.nativeLook()) {
|
||||
font.color = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);
|
||||
margin += 1.;
|
||||
}
|
||||
dc.SetFont(style.font, 1.0);
|
||||
dc.SetFont(font, 1.0);
|
||||
RealSize size = dc.GetTextExtent(text);
|
||||
RealPoint pos = align_in_rect(text_align, size, dc.getInternalRect()) + RealSize(margin, 0);
|
||||
dc.DrawTextWithShadow(text, style.font, pos);
|
||||
RealPoint text_pos = align_in_rect(text_align, size, dc.getInternalRect()) + RealSize(margin, 0);
|
||||
dc.DrawTextWithShadow(text, font, text_pos);
|
||||
if (viewer.nativeLook()) font.color = font_color;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,8 +16,6 @@ IMPLEMENT_VALUE_VIEWER(Color);
|
||||
|
||||
void ColorValueViewer::draw(RotatedDC& dc) {
|
||||
// draw in the value color
|
||||
dc.SetPen(*wxTRANSPARENT_PEN);
|
||||
dc.SetBrush(value().value());
|
||||
if (nativeLook()) {
|
||||
// native look
|
||||
// find name of color
|
||||
@@ -31,15 +29,20 @@ void ColorValueViewer::draw(RotatedDC& dc) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// draw name and color
|
||||
dc.SetPen(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT));
|
||||
dc.DrawRectangle(RealRect(0, 0, 40, dc.getHeight()));
|
||||
dc.SetBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
|
||||
}
|
||||
// draw background
|
||||
dc.SetPen(*wxTRANSPARENT_PEN);
|
||||
dc.SetBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
|
||||
dc.DrawRectangle(RealRect(40, 0, dc.getWidth()-40, dc.getHeight()));
|
||||
dc.DrawText(color_name, RealPoint(43, 3));
|
||||
// draw color
|
||||
dc.SetPen(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT));
|
||||
dc.SetBrush(value().value());
|
||||
dc.DrawRectangle(RealRect(0, 0, 40, dc.getHeight()));
|
||||
// draw name
|
||||
dc.DrawText(color_name, RealPoint(45, 3));
|
||||
} else {
|
||||
dc.SetPen(*wxTRANSPARENT_PEN);
|
||||
dc.SetBrush(value().value());
|
||||
// is there a mask?
|
||||
const AlphaMask& alpha_mask = getMask(dc);
|
||||
if (alpha_mask.isLoaded()) {
|
||||
|
||||
@@ -24,7 +24,13 @@ bool MultipleChoiceValueViewer::prepare(RotatedDC& dc) {
|
||||
void MultipleChoiceValueViewer::draw(RotatedDC& dc) {
|
||||
drawFieldBorder(dc);
|
||||
if (style().render_style & RENDER_HIDDEN) return;
|
||||
RealPoint pos = align_in_rect(style().alignment, RealSize(0,0), dc.getInternalRect());
|
||||
RealPoint pos = align_in_rect(style().alignment, RealSize(0,0), dc.getInternalRect());
|
||||
// render background
|
||||
if (nativeLook()) {
|
||||
dc.SetBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
|
||||
dc.SetPen(*wxTRANSPARENT_PEN);
|
||||
dc.DrawRectangle(RealRect(0, 0, dc.getWidth(), dc.getHeight()));
|
||||
}
|
||||
// selected choices
|
||||
vector<String> selected;
|
||||
value().get(selected);
|
||||
@@ -38,7 +44,7 @@ void MultipleChoiceValueViewer::draw(RotatedDC& dc) {
|
||||
if (active) select_it++;
|
||||
drawChoice(dc, pos, choice, active);
|
||||
}
|
||||
} else if (style().render_style & RENDER_LIST) {
|
||||
} else if (style().render_style & RENDER_LIST) {
|
||||
// render only selected choices
|
||||
FOR_EACH(choice, selected) {
|
||||
drawChoice(dc, pos, choice);
|
||||
@@ -70,13 +76,21 @@ void MultipleChoiceValueViewer::drawChoice(RotatedDC& dc, RealPoint& pos, const
|
||||
}
|
||||
}
|
||||
if (style().render_style & RENDER_TEXT) {
|
||||
// draw text
|
||||
// draw text
|
||||
Font& font = style().font;
|
||||
Color font_color = font.color;
|
||||
RealSize margin(0, 0);
|
||||
if (nativeLook()) {
|
||||
font.color = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);
|
||||
margin = RealSize(1., 0);
|
||||
}
|
||||
String text = tr(getStylePackage(), choice, capitalize_sentence);
|
||||
dc.SetFont(style().font,1);
|
||||
dc.SetFont(font,1);
|
||||
RealSize text_size = dc.GetTextExtent(text);
|
||||
RealPoint text_pos = align_in_rect(ALIGN_MIDDLE_LEFT, text_size, RealRect(pos.x + size.width + 1, pos.y, 0,size.height));
|
||||
dc.DrawTextWithShadow(text, style().font, text_pos);
|
||||
RealPoint text_pos = align_in_rect(ALIGN_MIDDLE_LEFT, text_size, RealRect(pos.x + size.width + 1, pos.y, 0,size.height)) + margin;
|
||||
dc.DrawTextWithShadow(text, font, text_pos);
|
||||
size = add_horizontal(size, text_size);
|
||||
if (nativeLook()) font.color = font_color;
|
||||
}
|
||||
// next position
|
||||
pos = move_in_direction(style().direction, pos, size, style().spacing);
|
||||
|
||||
@@ -43,7 +43,13 @@ void PackageChoiceValueViewer::initItems() {
|
||||
}
|
||||
|
||||
void PackageChoiceValueViewer::draw(RotatedDC& dc) {
|
||||
drawFieldBorder(dc);
|
||||
drawFieldBorder(dc);
|
||||
// draw background
|
||||
if (nativeLook()) {
|
||||
dc.SetBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
|
||||
dc.SetPen(*wxTRANSPARENT_PEN);
|
||||
dc.DrawRectangle(RealRect(0, 0, dc.getWidth(), dc.getHeight()));
|
||||
}
|
||||
// find item
|
||||
String text = value().package_name;
|
||||
Bitmap image;
|
||||
@@ -61,8 +67,16 @@ void PackageChoiceValueViewer::draw(RotatedDC& dc) {
|
||||
if (image.Ok()) {
|
||||
dc.DrawBitmap(image, RealPoint(0,0));
|
||||
}
|
||||
// draw text
|
||||
dc.SetFont(style().font, 1.0);
|
||||
RealPoint pos = align_in_rect(ALIGN_MIDDLE_LEFT, RealSize(0, dc.GetCharHeight()), dc.getInternalRect()) + RealSize(17., 0);
|
||||
dc.DrawTextWithShadow(text, style().font, pos);
|
||||
// draw text
|
||||
Font& font = style().font;
|
||||
Color font_color = font.color;
|
||||
RealSize margin(0, 0);
|
||||
if (nativeLook()) {
|
||||
font.color = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);
|
||||
margin = RealSize(1., 0);
|
||||
}
|
||||
dc.SetFont(font, 1.0);
|
||||
RealPoint pos = align_in_rect(ALIGN_MIDDLE_LEFT, RealSize(0, dc.GetCharHeight()), dc.getInternalRect()) + RealSize(17., 0) + margin;
|
||||
dc.DrawTextWithShadow(text, font, pos);
|
||||
if (nativeLook()) font.color = font_color;
|
||||
}
|
||||
|
||||
@@ -20,15 +20,21 @@ bool TextValueViewer::prepare(RotatedDC& dc) {
|
||||
}
|
||||
|
||||
void TextValueViewer::draw(RotatedDC& dc) {
|
||||
drawFieldBorder(dc);
|
||||
drawFieldBorder(dc);
|
||||
// draw background
|
||||
if (nativeLook()) {
|
||||
dc.SetBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
|
||||
dc.SetPen(*wxTRANSPARENT_PEN);
|
||||
dc.DrawRectangle(RealRect(0, 0, dc.getWidth(), dc.getHeight()));
|
||||
}
|
||||
if (!v.prepared()) {
|
||||
v.prepare(dc, value().value(), style(), getContext());
|
||||
dc.setStretch(getStretch());
|
||||
}
|
||||
DrawWhat what = drawWhat();
|
||||
v.draw(dc, style(), (DrawWhat)(what & DRAW_ACTIVE));
|
||||
v.draw(dc, style(), (DrawWhat)(what & DRAW_ACTIVE), nativeLook());
|
||||
setFieldBorderPen(dc);
|
||||
v.draw(dc, style(), (DrawWhat)(what & ~DRAW_ACTIVE));
|
||||
v.draw(dc, style(), (DrawWhat)(what & ~DRAW_ACTIVE), nativeLook());
|
||||
}
|
||||
|
||||
void TextValueViewer::onValueChange() {
|
||||
|
||||
Reference in New Issue
Block a user