mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 04:57:00 -04:00
finished symbol rendering
git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@90 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
@@ -7,9 +7,51 @@
|
||||
// ----------------------------------------------------------------------------- : Includes
|
||||
|
||||
#include <render/value/symbol.hpp>
|
||||
#include <render/symbol/filter.hpp>
|
||||
#include <data/set.hpp>
|
||||
#include <data/symbol.hpp>
|
||||
#include <gui/util.hpp> // draw_checker
|
||||
#include <util/error.hpp>
|
||||
|
||||
DECLARE_TYPEOF_COLLECTION(SymbolStyle::VariationP);
|
||||
|
||||
// ----------------------------------------------------------------------------- : SymbolValueViewer
|
||||
|
||||
void SymbolValueViewer::draw(RotatedDC& dc) {
|
||||
// TODO
|
||||
drawFieldBorder(dc);
|
||||
// draw checker background
|
||||
draw_checker(dc, style().getRect());
|
||||
double wh = min(style().width, style().height);
|
||||
// try to load symbol
|
||||
if (symbols.empty() && !value().filename.empty()) {
|
||||
try {
|
||||
// load symbol
|
||||
SymbolP symbol = getSet().readFile<SymbolP>(value().filename);
|
||||
// render and filter variations
|
||||
FOR_EACH(variation, style().variations) {
|
||||
Image img = render_symbol(symbol, *variation->filter, variation->border_radius);
|
||||
Image resampled(wh, wh, false);
|
||||
resample(img, resampled);
|
||||
symbols.push_back(Bitmap(resampled));
|
||||
}
|
||||
} catch (const Error& e) {
|
||||
handle_error(e);
|
||||
}
|
||||
}
|
||||
// draw image, if any
|
||||
for (size_t i = 0 ; i < symbols.size() ; ++i) {
|
||||
// todo : labels?
|
||||
dc.DrawBitmap(symbols[i], style().getPos() + RealSize(i * (wh + 2), 0));
|
||||
}
|
||||
// draw helper text if there are no symbols
|
||||
if (symbols.empty()) {
|
||||
dc.SetFont(wxFont(10,wxSWISS,wxNORMAL,wxNORMAL));
|
||||
dc.SetTextForeground(*wxBLACK);
|
||||
RealSize text_size = dc.GetTextExtent(_("double click to edit symbol"));
|
||||
dc.DrawText(_("double click to edit symbol"), align_in_rect(ALIGN_MIDDLE_CENTER, text_size, style().getRect()));
|
||||
}
|
||||
}
|
||||
|
||||
void SymbolValueViewer::onValueChange() {
|
||||
symbols.clear();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user