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);
}