mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 13:06:59 -04:00
default smart pointer type switched to intrusive_ptr
git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@337 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
@@ -22,6 +22,8 @@ DECLARE_TYPEOF_NO_REV(IndexMap<FieldP COMMA StyleP>);
|
||||
|
||||
// ----------------------------------------------------------------------------- : DataViewer
|
||||
|
||||
DataViewer::DataViewer() : drawing(false) {}
|
||||
DataViewer::~DataViewer() {}
|
||||
|
||||
// ----------------------------------------------------------------------------- : Drawing
|
||||
|
||||
@@ -84,10 +86,11 @@ Rotation DataViewer::getRotation() const {
|
||||
|
||||
void DataViewer::setCard(const CardP& card, bool refresh) {
|
||||
if (!card) return; // TODO: clear viewer?
|
||||
if (!refresh && this->card == card && this->stylesheet == set->stylesheetFor(card)) return; // already set
|
||||
StyleSheetP new_stylesheet = set->stylesheetForP(card);
|
||||
if (!refresh && this->card == card && this->stylesheet == new_stylesheet) return; // already set
|
||||
assert(set);
|
||||
this->card = card;
|
||||
stylesheet = set->stylesheetFor(card);
|
||||
stylesheet = new_stylesheet;
|
||||
setStyles(stylesheet, stylesheet->card_style);
|
||||
setData(card->data);
|
||||
onChangeSize();
|
||||
|
||||
@@ -22,7 +22,8 @@ class Context;
|
||||
/// A viewer can generate an image of some values, usually a card.
|
||||
class DataViewer : public SetView {
|
||||
public:
|
||||
DataViewer() : drawing(false) {}
|
||||
DataViewer();
|
||||
~DataViewer();
|
||||
|
||||
// --------------------------------------------------- : Drawing
|
||||
|
||||
@@ -57,7 +58,7 @@ class DataViewer : public SetView {
|
||||
/// The rotation to use
|
||||
virtual Rotation getRotation() const;
|
||||
/// The card we are viewing
|
||||
inline CardP getCard() const { return card; }
|
||||
inline const CardP& getCard() const { return card; }
|
||||
/// Invalidate and redraw (the area of) a single value viewer
|
||||
virtual void redraw(const ValueViewer&) {}
|
||||
|
||||
|
||||
@@ -53,24 +53,24 @@ Image render_symbol(const SymbolP& symbol, const SymbolFilter& filter, double bo
|
||||
|
||||
// ----------------------------------------------------------------------------- : SymbolFilter
|
||||
|
||||
IMPLEMENT_REFLECTION(SymbolFilter) {
|
||||
IMPLEMENT_REFLECTION_NO_SCRIPT(SymbolFilter) {
|
||||
REFLECT_IF_NOT_READING {
|
||||
String fill_type = fillType();
|
||||
REFLECT(fill_type);
|
||||
}
|
||||
}
|
||||
template <> void GetMember::handle(const shared_ptr<SymbolFilter>& f) {
|
||||
template <> void GetMember::handle(const intrusive_ptr<SymbolFilter>& f) {
|
||||
handle(*f);
|
||||
}
|
||||
|
||||
template <>
|
||||
shared_ptr<SymbolFilter> read_new<SymbolFilter>(Reader& reader) {
|
||||
intrusive_ptr<SymbolFilter> read_new<SymbolFilter>(Reader& reader) {
|
||||
// there must be a fill type specified
|
||||
String fill_type;
|
||||
reader.handle(_("fill type"), fill_type);
|
||||
if (fill_type == _("solid")) return new_shared<SolidFillSymbolFilter>();
|
||||
else if (fill_type == _("linear gradient")) return new_shared<LinearGradientSymbolFilter>();
|
||||
else if (fill_type == _("radial gradient")) return new_shared<RadialGradientSymbolFilter>();
|
||||
if (fill_type == _("solid")) return new_intrusive<SolidFillSymbolFilter>();
|
||||
else if (fill_type == _("linear gradient")) return new_intrusive<LinearGradientSymbolFilter>();
|
||||
else if (fill_type == _("radial gradient")) return new_intrusive<RadialGradientSymbolFilter>();
|
||||
else {
|
||||
throw ParseError(_ERROR_1_("unsupported fill type", fill_type));
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ enum SymbolSet
|
||||
// ----------------------------------------------------------------------------- : SymbolFilter
|
||||
|
||||
/// Base class for symbol filters
|
||||
class SymbolFilter {
|
||||
class SymbolFilter : public IntrusivePtrVirtualBase {
|
||||
public:
|
||||
virtual ~SymbolFilter() {}
|
||||
/// What color should the symbol have at location (x, y)?
|
||||
@@ -59,7 +59,7 @@ class SymbolFilter {
|
||||
};
|
||||
|
||||
template <>
|
||||
shared_ptr<SymbolFilter> read_new<SymbolFilter>(Reader& reader);
|
||||
intrusive_ptr<SymbolFilter> read_new<SymbolFilter>(Reader& reader);
|
||||
|
||||
// ----------------------------------------------------------------------------- : SymbolFilter types
|
||||
|
||||
|
||||
@@ -128,14 +128,14 @@ struct TextElementsFromString {
|
||||
else if (is_substr(text, tag_start, _("<atom"))) {
|
||||
// 'atomic' indicator
|
||||
size_t end_tag = min(end, match_close_tag(text, tag_start));
|
||||
shared_ptr<AtomTextElement> e(new AtomTextElement(text, pos, end_tag));
|
||||
intrusive_ptr<AtomTextElement> e(new AtomTextElement(text, pos, end_tag));
|
||||
fromString(e->elements, text, pos, end_tag, style, ctx);
|
||||
te.elements.push_back(e);
|
||||
pos = skip_tag(text, end_tag);
|
||||
} else if (is_substr(text, tag_start, _( "<error"))) {
|
||||
// error indicator
|
||||
size_t end_tag = min(end, match_close_tag(text, tag_start));
|
||||
shared_ptr<ErrorTextElement> e(new ErrorTextElement(text, pos, end_tag));
|
||||
intrusive_ptr<ErrorTextElement> e(new ErrorTextElement(text, pos, end_tag));
|
||||
fromString(e->elements, text, pos, end_tag, style, ctx);
|
||||
te.elements.push_back(e);
|
||||
pos = skip_tag(text, end_tag);
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include <util/prec.hpp>
|
||||
#include <util/rotation.hpp>
|
||||
#include <util/real_point.hpp>
|
||||
#include <data/font.hpp>
|
||||
|
||||
DECLARE_POINTER_TYPE(TextElement);
|
||||
DECLARE_POINTER_TYPE(Font);
|
||||
@@ -47,7 +48,7 @@ struct CharInfo {
|
||||
};
|
||||
|
||||
/// A section of text that can be rendered using a TextViewer
|
||||
class TextElement {
|
||||
class TextElement : public IntrusivePtrBase<TextElement> {
|
||||
public:
|
||||
/// The text of which a subsection is drawn
|
||||
String text;
|
||||
|
||||
@@ -303,7 +303,7 @@ void TextViewer::setExactScrollPosition(double pos) {
|
||||
void TextViewer::prepareElements(const String& text, const TextStyle& style, Context& ctx) {
|
||||
if (style.always_symbol) {
|
||||
elements.elements.clear();
|
||||
elements.elements.push_back(new_shared5<SymbolTextElement>(text, 0, text.size(), style.symbol_font, &ctx));
|
||||
elements.elements.push_back(new_intrusive5<SymbolTextElement>(text, 0, text.size(), style.symbol_font, &ctx));
|
||||
} else {
|
||||
elements.fromString(text, 0, text.size(), style, ctx);
|
||||
}
|
||||
|
||||
@@ -101,6 +101,6 @@ void ColorValueViewer::loadMask(const Rotation& rot) const {
|
||||
if (image.LoadFile(*image_file)) {
|
||||
Image resampled(w,h);
|
||||
resample(image, resampled);
|
||||
alpha_mask = new_shared1<AlphaMask>(resampled);
|
||||
alpha_mask = new_intrusive1<AlphaMask>(resampled);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ void ImageValueViewer::loadMask(const Rotation& rot) const {
|
||||
if (image.LoadFile(*image_file)) {
|
||||
Image resampled(w,h);
|
||||
resample(image, resampled);
|
||||
alpha_mask = new_shared1<AlphaMask>(resampled);
|
||||
alpha_mask = new_intrusive1<AlphaMask>(resampled);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ DECLARE_POINTER_TYPE(Value);
|
||||
|
||||
/// The virtual viewer control for a single field on a card (or in the set data)
|
||||
/** A viewer can only display a value, not edit it, ValueEditor is used for that */
|
||||
class ValueViewer : public StyleListener{
|
||||
class ValueViewer : public StyleListener {
|
||||
public:
|
||||
/// Construct a ValueViewer, set the value at a later time
|
||||
ValueViewer(DataViewer& parent, const StyleP& style);
|
||||
|
||||
Reference in New Issue
Block a user