Skip to content

Commit

Permalink
Replace ISettings::get/setGrabAlpha() with Preferences class
Browse files Browse the repository at this point in the history
  • Loading branch information
dacap committed May 13, 2015
1 parent 8c6c77e commit 00ff895
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 22 deletions.
2 changes: 1 addition & 1 deletion data/pref.xml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
<option id="zoom_from_center_with_keys" type="bool" default="false" />
<option id="show_scrollbars" type="bool" default="true" migrate="Options.ShowScrollbars" />
<option id="right_click_mode" type="RightClickMode" default="RightClickMode::PAINT_BGCOLOR" migrate="Options.RightClickMode" />
<option id="grab_alpha" type="bool" default="false" />
<option id="grab_alpha" type="bool" default="false" migrate="Options.GrabAlpha" />
<option id="auto_select_layer" type="bool" default="false" />
<option id="fg_color" type="app::Color" />
<option id="bg_color" type="app::Color" />
Expand Down
3 changes: 2 additions & 1 deletion src/app/commands/cmd_eyedropper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "app/commands/commands.h"
#include "app/commands/params.h"
#include "app/modules/editors.h"
#include "app/pref/preferences.h"
#include "app/settings/settings.h"
#include "app/tools/tool.h"
#include "app/tools/tool_box.h"
Expand Down Expand Up @@ -84,7 +85,7 @@ void EyedropperCommand::onExecute(Context* context)

// Check if we've to grab alpha channel or the merged color.
ISettings* settings = UIContext::instance()->settings();
bool grabAlpha = settings->getGrabAlpha();
bool grabAlpha = App::instance()->preferences().editor.grabAlpha();

ColorPicker picker;
picker.pickColor(editor->getSite(),
Expand Down
2 changes: 0 additions & 2 deletions src/app/settings/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,12 @@ namespace app {
virtual ~ISettings() { }

// General settings
virtual bool getGrabAlpha() = 0;
virtual bool getAutoSelectLayer() = 0;
virtual app::Color getFgColor() = 0;
virtual app::Color getBgColor() = 0;
virtual tools::Tool* getCurrentTool() = 0;
virtual app::ColorSwatches* getColorSwatches() = 0;

virtual void setGrabAlpha(bool state) = 0;
virtual void setAutoSelectLayer(bool state) = 0;
virtual void setFgColor(const app::Color& color) = 0;
virtual void setBgColor(const app::Color& color) = 0;
Expand Down
12 changes: 0 additions & 12 deletions src/app/settings/ui_settings_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ UISettingsImpl::UISettingsImpl()
: m_currentTool(NULL)
, m_colorSwatches(NULL)
, m_selectionSettings(new UISelectionSettingsImpl)
, m_grabAlpha(get_config_bool("Options", "GrabAlpha", false))
, m_autoSelectLayer(get_config_bool("Options", "AutoSelectLayer", false))
{
m_colorSwatches = new app::ColorSwatches("Default");
Expand All @@ -90,7 +89,6 @@ UISettingsImpl::UISettingsImpl()

UISettingsImpl::~UISettingsImpl()
{
set_config_bool("Options", "GrabAlpha", m_grabAlpha);
set_config_bool("Options", "AutoSelectLayer", m_autoSelectLayer);

for (auto it : m_toolSettings)
Expand All @@ -103,11 +101,6 @@ UISettingsImpl::~UISettingsImpl()
//////////////////////////////////////////////////////////////////////
// General settings

bool UISettingsImpl::getGrabAlpha()
{
return m_grabAlpha;
}

bool UISettingsImpl::getAutoSelectLayer()
{
return m_autoSelectLayer;
Expand Down Expand Up @@ -138,11 +131,6 @@ app::ColorSwatches* UISettingsImpl::getColorSwatches()
return m_colorSwatches;
}

void UISettingsImpl::setGrabAlpha(bool state)
{
m_grabAlpha = state;
}

void UISettingsImpl::setAutoSelectLayer(bool state)
{
m_autoSelectLayer = state;
Expand Down
2 changes: 0 additions & 2 deletions src/app/settings/ui_settings_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,12 @@ namespace app {
~UISettingsImpl();

// ISettings implementation
bool getGrabAlpha() override;
bool getAutoSelectLayer() override;
app::Color getFgColor() override;
app::Color getBgColor() override;
tools::Tool* getCurrentTool() override;
app::ColorSwatches* getColorSwatches() override;

void setGrabAlpha(bool state) override;
void setAutoSelectLayer(bool state) override;
void setFgColor(const app::Color& color) override;
void setBgColor(const app::Color& color) override;
Expand Down
7 changes: 4 additions & 3 deletions src/app/ui/context_bar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -751,7 +751,7 @@ class ContextBar::GrabAlphaField : public CheckBox
void onClick(Event& ev) override {
CheckBox::onClick(ev);

UIContext::instance()->settings()->setGrabAlpha(isSelected());
App::instance()->preferences().editor.grabAlpha(isSelected());

releaseFocus();
}
Expand Down Expand Up @@ -915,6 +915,7 @@ void ContextBar::updateForTool(tools::Tool* tool)
ISettings* settings = UIContext::instance()->settings();
IToolSettings* toolSettings = nullptr;
IBrushSettings* brushSettings = nullptr;
Preferences& preferences = App::instance()->preferences();

if (tool) {
toolSettings = settings->getToolSettings(tool);
Expand All @@ -936,7 +937,7 @@ void ContextBar::updateForTool(tools::Tool* tool)
}

m_brushPatternField->setBrushPattern(
App::instance()->preferences().brush.pattern());
preferences.brush.pattern());

if (toolSettings) {
m_tolerance->setTextf("%d", toolSettings->getTolerance());
Expand All @@ -952,7 +953,7 @@ void ContextBar::updateForTool(tools::Tool* tool)
}

if (settings) {
m_grabAlpha->setSelected(settings->getGrabAlpha());
m_grabAlpha->setSelected(preferences.editor.grabAlpha());
m_autoSelectLayer->setSelected(settings->getAutoSelectLayer());
}

Expand Down
3 changes: 2 additions & 1 deletion src/app/ui/editor/standby_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "app/commands/commands.h"
#include "app/commands/params.h"
#include "app/ini_file.h"
#include "app/pref/preferences.h"
#include "app/settings/settings.h"
#include "app/tools/ink.h"
#include "app/tools/pick_ink.h"
Expand Down Expand Up @@ -371,7 +372,7 @@ bool StandbyState::onUpdateStatusBar(Editor* editor)
}
// For eye-dropper
else if (ink->isEyedropper()) {
bool grabAlpha = UIContext::instance()->settings()->getGrabAlpha();
bool grabAlpha = App::instance()->preferences().editor.grabAlpha();
ColorPicker picker;
picker.pickColor(editor->getSite(),
spritePos,
Expand Down

0 comments on commit 00ff895

Please sign in to comment.