Fix issue 406: persist ISelectionSettings

This commit is contained in:
David Capello 2014-06-14 01:35:04 -03:00
parent 095d31a91d
commit 153071f082
2 changed files with 18 additions and 5 deletions

View File

@ -183,7 +183,7 @@ class UISelectionSettingsImpl
, public base::Observable<SelectionSettingsObserver> { , public base::Observable<SelectionSettingsObserver> {
public: public:
UISelectionSettingsImpl(); UISelectionSettingsImpl();
~UISelectionSettingsImpl(); virtual ~UISelectionSettingsImpl();
SelectionMode getSelectionMode(); SelectionMode getSelectionMode();
app::Color getMoveTransparentColor(); app::Color getMoveTransparentColor();
@ -827,6 +827,8 @@ UISelectionSettingsImpl::UISelectionSettingsImpl() :
UISelectionSettingsImpl::~UISelectionSettingsImpl() UISelectionSettingsImpl::~UISelectionSettingsImpl()
{ {
set_config_int("Tools", "SelectionMode", (int)m_selectionMode);
set_config_int("Tools", "RotAlgorithm", (int)m_rotationAlgorithm);
} }
SelectionMode UISelectionSettingsImpl::getSelectionMode() SelectionMode UISelectionSettingsImpl::getSelectionMode()
@ -859,7 +861,6 @@ void UISelectionSettingsImpl::setMoveTransparentColor(app::Color color)
void UISelectionSettingsImpl::setRotationAlgorithm(RotationAlgorithm algorithm) void UISelectionSettingsImpl::setRotationAlgorithm(RotationAlgorithm algorithm)
{ {
m_rotationAlgorithm = algorithm; m_rotationAlgorithm = algorithm;
set_config_int("Tools", "RotAlgorithm", m_rotationAlgorithm);
notifyObservers(&SelectionSettingsObserver::onSetRotationAlgorithm, algorithm); notifyObservers(&SelectionSettingsObserver::onSetRotationAlgorithm, algorithm);
} }

View File

@ -395,16 +395,23 @@ class ContextBar::RotAlgorithmField : public ComboBox
{ {
public: public:
RotAlgorithmField() { RotAlgorithmField() {
// We use "m_lockChange" variable to avoid setting the rotation
// algorithm when we call ComboBox::addItem() (because the first
// addItem() generates an onChange() event).
m_lockChange = true;
addItem(new Item("Fast Rotation", kFastRotationAlgorithm)); addItem(new Item("Fast Rotation", kFastRotationAlgorithm));
addItem(new Item("RotSprite", kRotSpriteRotationAlgorithm)); addItem(new Item("RotSprite", kRotSpriteRotationAlgorithm));
m_lockChange = false;
setSelectedItemIndex((int) setSelectedItemIndex((int)UIContext::instance()->settings()
UIContext::instance()->settings()->selection() ->selection()->getRotationAlgorithm());
->getRotationAlgorithm());
} }
protected: protected:
void onChange() OVERRIDE { void onChange() OVERRIDE {
if (m_lockChange)
return;
UIContext::instance()->settings()->selection() UIContext::instance()->settings()->selection()
->setRotationAlgorithm(static_cast<Item*>(getSelectedItem())->algo()); ->setRotationAlgorithm(static_cast<Item*>(getSelectedItem())->algo());
} }
@ -426,6 +433,8 @@ private:
private: private:
RotationAlgorithm m_algo; RotationAlgorithm m_algo;
}; };
bool m_lockChange;
}; };
class ContextBar::FreehandAlgorithmField : public CheckBox class ContextBar::FreehandAlgorithmField : public CheckBox
@ -457,6 +466,9 @@ public:
PART_SELECTION_REPLACE, PART_SELECTION_REPLACE,
PART_SELECTION_ADD, PART_SELECTION_ADD,
PART_SELECTION_SUBTRACT) { PART_SELECTION_SUBTRACT) {
setSelectedItem(
(int)UIContext::instance()->settings()
->selection()->getSelectionMode());
} }
void setupTooltips(TooltipManager* tooltipManager) void setupTooltips(TooltipManager* tooltipManager)