Added clone() function to Value.

Added support for per-card styling

git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@430 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
twanvl
2007-06-24 01:30:34 +00:00
parent df9bb78e51
commit f0628317a3
25 changed files with 147 additions and 21 deletions
+24 -2
View File
@@ -12,6 +12,8 @@
#include <data/stylesheet.hpp>
#include <util/error.hpp>
DECLARE_TYPEOF_COLLECTION(IndexMap<FieldP COMMA ValueP>);
// ----------------------------------------------------------------------------- : Add card
AddCardAction::AddCardAction(Set& set)
@@ -91,13 +93,15 @@ void DisplayChangeAction::perform(bool to_undo) {
ChangeCardStyleAction::ChangeCardStyleAction(const CardP& card, const StyleSheetP& stylesheet)
: card(card), stylesheet(stylesheet)
: card(card), stylesheet(stylesheet), has_styling(false) // styling_data(empty)
{}
String ChangeCardStyleAction::getName(bool to_undo) const {
return _("Change style");
}
void ChangeCardStyleAction::perform(bool to_undo) {
swap(card->stylesheet, stylesheet);
swap(card->stylesheet, stylesheet);
swap(card->has_styling, has_styling);
swap(card->styling_data, styling_data);
}
@@ -117,3 +121,21 @@ void ChangeSetStyleAction::perform(bool to_undo) {
set.stylesheet = stylesheet;
}
}
ChangeCardHasStylingAction::ChangeCardHasStylingAction(Set& set, const CardP& card)
: set(set), card(card)
{
if (!card->has_styling) {
// copy of the set's styling data
styling_data.cloneFrom( set.stylingDataFor(set.stylesheetFor(card)) );
} else {
// the new styling data is empty
}
}
String ChangeCardHasStylingAction::getName(bool to_undo) const {
return _("Use custom style");
}
void ChangeCardHasStylingAction::perform(bool to_undo) {
card->has_styling = !card->has_styling;
swap(card->styling_data, styling_data);
}
+21 -2
View File
@@ -20,6 +20,8 @@
class Set;
DECLARE_POINTER_TYPE(Card);
DECLARE_POINTER_TYPE(StyleSheet);
DECLARE_POINTER_TYPE(Field);
DECLARE_POINTER_TYPE(Value);
// ----------------------------------------------------------------------------- : Add card
@@ -93,8 +95,10 @@ class ChangeCardStyleAction : public DisplayChangeAction {
virtual void perform(bool to_undo);
//private:
CardP card; ///< The affected card
StyleSheetP stylesheet; ///< Its new stylesheet
CardP card; ///< The affected card
StyleSheetP stylesheet; ///< Its old stylesheet
bool has_styling; ///< Its old has_styling
IndexMap<FieldP,ValueP> styling_data; ///< Its old styling data
};
/// Changing the style of a set to that of a card
@@ -111,5 +115,20 @@ class ChangeSetStyleAction : public DisplayChangeAction {
StyleSheetP stylesheet; ///< The old stylesheet of the set
};
/// Changing the styling of a card to become custom/non-custom
/** i.e. toggle card->has_styling */
class ChangeCardHasStylingAction : public DisplayChangeAction {
public:
ChangeCardHasStylingAction(Set& set, const CardP& card);
virtual String getName(bool to_undo) const;
virtual void perform(bool to_undo);
//private:
Set& set; ///< The set to copy styling from
CardP card; ///< The affected card
IndexMap<FieldP,ValueP> styling_data; ///< The old styling of the card
};
// ----------------------------------------------------------------------------- : EOF
#endif