Skip to content

Commit

Permalink
Fix issue 406: persist ISelectionSettings
Browse files Browse the repository at this point in the history
  • Loading branch information
dacap committed Jun 14, 2014
1 parent 095d31a commit 153071f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
5 changes: 3 additions & 2 deletions src/app/settings/ui_settings_impl.cpp
Expand Up @@ -183,7 +183,7 @@ class UISelectionSettingsImpl
, public base::Observable<SelectionSettingsObserver> {
public:
UISelectionSettingsImpl();
~UISelectionSettingsImpl();
virtual ~UISelectionSettingsImpl();

SelectionMode getSelectionMode();
app::Color getMoveTransparentColor();
Expand Down Expand Up @@ -827,6 +827,8 @@ UISelectionSettingsImpl::UISelectionSettingsImpl() :

UISelectionSettingsImpl::~UISelectionSettingsImpl()
{
set_config_int("Tools", "SelectionMode", (int)m_selectionMode);
set_config_int("Tools", "RotAlgorithm", (int)m_rotationAlgorithm);
}

SelectionMode UISelectionSettingsImpl::getSelectionMode()
Expand Down Expand Up @@ -859,7 +861,6 @@ void UISelectionSettingsImpl::setMoveTransparentColor(app::Color color)
void UISelectionSettingsImpl::setRotationAlgorithm(RotationAlgorithm algorithm)
{
m_rotationAlgorithm = algorithm;
set_config_int("Tools", "RotAlgorithm", m_rotationAlgorithm);
notifyObservers(&SelectionSettingsObserver::onSetRotationAlgorithm, algorithm);
}

Expand Down
18 changes: 15 additions & 3 deletions src/app/ui/context_bar.cpp
Expand Up @@ -395,16 +395,23 @@ class ContextBar::RotAlgorithmField : public ComboBox
{
public:
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("RotSprite", kRotSpriteRotationAlgorithm));
m_lockChange = false;

setSelectedItemIndex((int)
UIContext::instance()->settings()->selection()
->getRotationAlgorithm());
setSelectedItemIndex((int)UIContext::instance()->settings()
->selection()->getRotationAlgorithm());
}

protected:
void onChange() OVERRIDE {
if (m_lockChange)
return;

UIContext::instance()->settings()->selection()
->setRotationAlgorithm(static_cast<Item*>(getSelectedItem())->algo());
}
Expand All @@ -426,6 +433,8 @@ class ContextBar::RotAlgorithmField : public ComboBox
private:
RotationAlgorithm m_algo;
};

bool m_lockChange;
};

class ContextBar::FreehandAlgorithmField : public CheckBox
Expand Down Expand Up @@ -457,6 +466,9 @@ class ContextBar::SelectionModeField : public ButtonSet
PART_SELECTION_REPLACE,
PART_SELECTION_ADD,
PART_SELECTION_SUBTRACT) {
setSelectedItem(
(int)UIContext::instance()->settings()
->selection()->getSelectionMode());
}

void setupTooltips(TooltipManager* tooltipManager)
Expand Down

0 comments on commit 153071f

Please sign in to comment.