Permalink
Browse files

Replace ISettings with Preferences

Changes:
* Move FreehandAlgorithm/InkType/RotationAlgorithm/SelectionMode to
  app::tools namespace
* Removed ISettings, IToolSettings, IBrushSettings, ISelectionSettings,
  and IColorSwatchesStore (and implementations from UISettingsImpl)
* Added app::tools::PreferenceGlue to do some adjustments that
  UIToolSettingsImpl was doing
* Remove signals from App related to brush size/angle changes, and current
  tool change (there events can be observed directly from Preferences)
* Remove ColorBar::FgColor/BgColor, these options can be observed from
  Preferences::colorBar.fg/bgColor
  • Loading branch information...
dacap committed May 18, 2015
1 parent 026972a commit f6be0c3be6c3b0547116f676ad8c9e1234e3ab71
Showing with 615 additions and 1,448 deletions.
  1. +12 −29 data/pref.xml
  2. +0 −1 src/app/CMakeLists.txt
  3. +5 −1 src/app/app.cpp
  4. +2 −5 src/app/app.h
  5. +1 −2 src/app/app_render.cpp
  6. +1 −1 src/app/check_update.cpp
  7. +0 −3 src/app/check_update_delegate.h
  8. +0 −1 src/app/commands/cmd_background_from_layer.cpp
  9. +0 −1 src/app/commands/cmd_canvas_size.cpp
  10. +12 −12 src/app/commands/cmd_change_brush.cpp
  11. +1 −7 src/app/commands/cmd_configure_tools.cpp
  12. +0 −1 src/app/commands/cmd_discard_brush.cpp
  13. +1 −1 src/app/commands/cmd_export_sprite_sheet.cpp
  14. +6 −8 src/app/commands/cmd_eyedropper.cpp
  15. +1 −1 src/app/commands/cmd_fullscreen_preview.cpp
  16. +7 −7 src/app/commands/cmd_grid.cpp
  17. +1 −1 src/app/commands/cmd_import_sprite_sheet.cpp
  18. +1 −1 src/app/commands/cmd_move_mask.cpp
  19. +2 −7 src/app/commands/cmd_new_brush.cpp
  20. +2 −2 src/app/commands/cmd_onionskin.cpp
  21. +4 −7 src/app/commands/cmd_options.cpp
  22. +9 −8 src/app/commands/cmd_palette_editor.cpp
  23. +1 −1 src/app/commands/cmd_repeat_last_export.cpp
  24. +1 −1 src/app/commands/cmd_scroll.cpp
  25. +1 −1 src/app/commands/cmd_undo.cpp
  26. +1 −1 src/app/commands/cmd_zoom.cpp
  27. +2 −2 src/app/commands/filters/cmd_convolution_matrix.cpp
  28. +2 −1 src/app/commands/filters/cmd_despeckle.cpp
  29. +0 −13 src/app/context.cpp
  30. +0 −9 src/app/context.h
  31. +1 −1 src/app/crash/backup_observer.cpp
  32. +6 −13 src/app/document.cpp
  33. +0 −1 src/app/document_api.cpp
  34. +1 −1 src/app/file_selector.cpp
  35. +4 −5 src/app/modules/gui.cpp
  36. +4 −4 src/app/pref/option.h
  37. +15 −0 src/app/pref/preferences.cpp
  38. +12 −0 src/app/pref/preferences.h
  39. +0 −35 src/app/settings/ink_type.h
  40. +0 −138 src/app/settings/settings.h
  41. +0 −63 src/app/settings/settings_observers.h
  42. +0 −498 src/app/settings/ui_settings_impl.cpp
  43. +0 −63 src/app/settings/ui_settings_impl.h
  44. +10 −7 src/app/{settings → tools}/freehand_algorithm.h
  45. +24 −0 src/app/tools/ink_type.h
  46. +9 −16 src/app/tools/inks.h
  47. +8 −8 src/app/{settings → tools}/rotation_algorithm.h
  48. +8 −9 src/app/{settings → tools}/selection_mode.h
  49. +47 −0 src/app/tools/tool_box.cpp
  50. +4 −0 src/app/tools/tool_box.h
  51. +13 −13 src/app/tools/tool_loop.h
  52. +0 −1 src/app/ui/ani_controls.cpp
  53. +36 −13 src/app/ui/color_bar.cpp
  54. +5 −4 src/app/ui/color_bar.h
  55. +1 −2 src/app/ui/configure_timeline_popup.cpp
  56. +122 −150 src/app/ui/context_bar.cpp
  57. +10 −10 src/app/ui/context_bar.h
  58. +5 −37 src/app/ui/editor/cursor.cpp
  59. +59 −48 src/app/ui/editor/editor.cpp
  60. +7 −5 src/app/ui/editor/editor.h
  61. +2 −2 src/app/ui/editor/editor_view.cpp
  62. +0 −1 src/app/ui/editor/editor_view.h
  63. +11 −9 src/app/ui/editor/moving_pixels_state.cpp
  64. +3 −5 src/app/ui/editor/moving_pixels_state.h
  65. +10 −10 src/app/ui/editor/pixels_movement.cpp
  66. +4 −5 src/app/ui/editor/pixels_movement.h
  67. +1 −2 src/app/ui/editor/standby_state.cpp
  68. +2 −3 src/app/ui/editor/state_with_wheel_behavior.cpp
  69. +62 −81 src/app/ui/editor/tool_loop_impl.cpp
  70. +0 −5 src/app/ui/home_view.cpp
  71. +0 −1 src/app/ui/home_view.h
  72. +2 −4 src/app/ui/keyboard_shortcuts.cpp
  73. +4 −5 src/app/ui/main_window.cpp
  74. +2 −2 src/app/ui/news_listbox.cpp
  75. +7 −6 src/app/ui/status_bar.cpp
  76. +1 −1 src/app/ui/timeline.cpp
  77. +7 −7 src/app/ui/toolbar.cpp
  78. +3 −5 src/app/ui_context.cpp
  79. +0 −1 src/app/util/clipboard.cpp
  80. +1 −10 src/gen/pref_types.cpp
  81. +4 −1 src/ui/int_entry.cpp
  82. +2 −1 src/ui/int_entry.h
View
@@ -4,11 +4,6 @@
<preferences>
<types>
- <enum id="InkType">
- <value id="DEFAULT" value="0" />
- <value id="SET_ALPHA" value="1" />
- <value id="LOCK_ALPHA" value="2" />
- </enum>
<enum id="RightClickMode">
<value id="DEFAULT" value="0" />
<value id="PAINT_BGCOLOR" value="0" />
@@ -19,25 +14,11 @@
<value id="MERGE" value="0" />
<value id="RED_BLUE_TINT" value="1" />
</enum>
- <enum id="FreehandAlgorithm">
- <value id="REGULAR" value="0" />
- <value id="PIXEL_PERFECT" value="1" />
- <value id="DOTS" value="2" />
- </enum>
<enum id="BrushType">
<value id="CIRCLE" value="0" />
<value id="SQUARE" value="1" />
<value id="LINE" value="2" />
</enum>
- <enum id="SelectionMode">
- <value id="DEFAULT" value="0" />
- <value id="ADD" value="1" />
- <value id="SUBTRACT" value="2" />
- </enum>
- <enum id="RotationAlgorithm">
- <value id="FAST" value="0" />
- <value id="ROTSPRITE" value="1" />
- </enum>
<enum id="BgType">
<value id="CHECKED_16x16" value="0" />
<value id="CHECKED_8x8" value="1" />
@@ -74,9 +55,6 @@
<option id="right_click_mode" type="RightClickMode" default="RightClickMode::PAINT_BGCOLOR" migrate="Options.RightClickMode" />
<option id="grab_alpha" type="bool" default="false" migrate="Options.GrabAlpha" />
<option id="auto_select_layer" type="bool" default="false" migrate="Options.AutoSelectLayer" />
- <option id="fg_color" type="app::Color" />
- <option id="bg_color" type="app::Color" />
- <option id="current_tool" type="std::string" default="&quot;pencil&quot;" />
</section>
<section id="experimental" text="Experimental">
<option id="ui_scale" type="int" default="1" />
@@ -89,6 +67,11 @@
</section>
<section id="color_bar">
<option id="box_size" type="int" default="11" />
+ <option id="fg_color" type="app::Color" />
+ <option id="bg_color" type="app::Color" />
+ </section>
+ <section id="tool_box">
+ <option id="active_tool" type="std::string" default="&quot;pencil&quot;" />
</section>
<section id="updater">
<option id="inits" type="int" default="0" migrate="Updater.Inits" />
@@ -103,6 +86,11 @@
<section id="brush">
<option id="pattern" type="doc::BrushPattern" default="doc::BrushPattern::DEFAULT" />
</section>
+ <section id="selection">
+ <option id="mode" type="app::tools::SelectionMode" default="app::tools::SelectionMode::DEFAULT" />
+ <option id="transparent_color" type="app::Color" />
+ <option id="rotation_algorithm" type="app::tools::RotationAlgorithm" default="app::tools::RotationAlgorithm::DEFAULT" />
+ </section>
</global>
<tool>
@@ -111,8 +99,8 @@
<option id="contiguous" type="bool" default="true" />
<option id="filled" type="bool" default="false" />
<option id="filled_preview" type="bool" default="false" />
- <option id="ink" type="InkType" />
- <option id="freehand_algorithm" type="FreehandAlgorithm" />
+ <option id="ink" type="app::tools::InkType" default="app::tools::InkType::DEFAULT" />
+ <option id="freehand_algorithm" type="app::tools::FreehandAlgorithm" default="app::tools::FreehandAlgorithm::DEFAULT" />
<section id="brush">
<option id="type" type="BrushType" default="BrushType::CIRCLE" />
<option id="size" type="int" default="1" />
@@ -122,11 +110,6 @@
<option id="width" type="int" default="16" />
<option id="speed" type="int" default="32" />
</section>
- <section id="selection">
- <option id="mode" type="SelectionMode" />
- <option id="transparent_color" type="app::Color" />
- <option id="rotation_algorithm" type="RotationAlgorithm" />
- </section>
</tool>
<document>
View
@@ -286,7 +286,6 @@ add_library(app-lib
res/resources_loader.cpp
resource_finder.cpp
send_crash.cpp
- settings/ui_settings_impl.cpp
shell.cpp
snap_to_grid.cpp
thumbnail_generator.cpp
View
@@ -40,7 +40,6 @@
#include "app/recent_files.h"
#include "app/resource_finder.h"
#include "app/send_crash.h"
-#include "app/settings/settings.h"
#include "app/shell.h"
#include "app/tools/tool_box.h"
#include "app/ui/color_bar.h"
@@ -657,6 +656,11 @@ tools::ToolBox* App::getToolBox() const
return &m_modules->m_toolbox;
}
+tools::Tool* App::activeTool() const
+{
+ return getToolBox()->getToolById(preferences().toolBox.activeTool());
+}
+
RecentFiles* App::getRecentFiles() const
{
ASSERT(m_modules != NULL);
View
@@ -39,6 +39,7 @@ namespace app {
class RecentFiles;
namespace tools {
+ class Tool;
class ToolBox;
}
@@ -64,6 +65,7 @@ namespace app {
void run();
tools::ToolBox* getToolBox() const;
+ tools::Tool* activeTool() const;
RecentFiles* getRecentFiles() const;
MainWindow* getMainWindow() const { return m_mainWindow; }
Preferences& preferences() const;
@@ -76,11 +78,6 @@ namespace app {
// App Signals
Signal0<void> Exit;
Signal0<void> PaletteChange;
- Signal0<void> BrushSizeBeforeChange;
- Signal0<void> BrushSizeAfterChange;
- Signal0<void> BrushAngleBeforeChange;
- Signal0<void> BrushAngleAfterChange;
- Signal0<void> CurrentToolChange;
private:
typedef std::vector<std::string> FileList;
View
@@ -11,7 +11,6 @@
#include "app/app_render.h"
-#include "app/app.h"
#include "app/color_utils.h"
#include "app/pref/preferences.h"
#include "render/render.h"
@@ -29,7 +28,7 @@ AppRender::AppRender(app::Document* doc, doc::PixelFormat pixelFormat)
void AppRender::setupBackground(app::Document* doc, doc::PixelFormat pixelFormat)
{
- DocumentPreferences& docPref = App::instance()->preferences().document(doc);
+ DocumentPreferences& docPref = Preferences::instance().document(doc);
render::BgType bgType;
gfx::Size tile;
View
@@ -78,7 +78,7 @@ class CheckUpdateBackgroundJob : public updater::CheckUpdateDelegate
CheckUpdateThreadLauncher::CheckUpdateThreadLauncher(CheckUpdateDelegate* delegate)
: m_delegate(delegate)
- , m_preferences(delegate->getPreferences())
+ , m_preferences(Preferences::instance())
, m_doCheck(true)
, m_received(false)
, m_inits(m_preferences.updater.inits())
@@ -15,15 +15,12 @@
namespace app {
- class Preferences;
-
class CheckUpdateDelegate {
public:
virtual ~CheckUpdateDelegate() { }
virtual void onCheckingUpdates() = 0;
virtual void onUpToDate() = 0;
virtual void onNewUpdate(const std::string& url, const std::string& version) = 0;
- virtual Preferences& getPreferences() = 0;
};
} // namespace app
@@ -13,7 +13,6 @@
#include "app/context_access.h"
#include "app/document_api.h"
#include "app/modules/gui.h"
-#include "app/settings/settings.h"
#include "app/ui/color_bar.h"
#include "app/transaction.h"
#include "doc/layer.h"
@@ -16,7 +16,6 @@
#include "app/load_widget.h"
#include "app/modules/editors.h"
#include "app/modules/gui.h"
-#include "app/settings/settings.h"
#include "app/ui/button_set.h"
#include "app/ui/color_bar.h"
#include "app/ui/editor/editor.h"
@@ -15,7 +15,7 @@
#include "app/commands/command.h"
#include "app/commands/params.h"
#include "app/context.h"
-#include "app/settings/settings.h"
+#include "app/pref/preferences.h"
#include "app/tools/tool.h"
#include "app/ui/context_bar.h"
#include "app/ui/main_window.h"
@@ -73,29 +73,29 @@ void ChangeBrushCommand::onLoadParams(const Params& params)
void ChangeBrushCommand::onExecute(Context* context)
{
- tools::Tool* current_tool = context->settings()->getCurrentTool();
- IToolSettings* tool_settings = context->settings()->getToolSettings(current_tool);
- IBrushSettings* brush = tool_settings->getBrush();
+ tools::Tool* tool = App::instance()->activeTool();
+ ToolPreferences::Brush& brush =
+ Preferences::instance().tool(tool).brush;
switch (m_change) {
case None:
// Do nothing
break;
case IncrementSize:
- if (brush->getSize() < doc::Brush::kMaxBrushSize)
- brush->setSize(brush->getSize()+1);
+ if (brush.size() < doc::Brush::kMaxBrushSize)
+ brush.size(brush.size()+1);
break;
case DecrementSize:
- if (brush->getSize() > doc::Brush::kMinBrushSize)
- brush->setSize(brush->getSize()-1);
+ if (brush.size() > doc::Brush::kMinBrushSize)
+ brush.size(brush.size()-1);
break;
case IncrementAngle:
- if (brush->getAngle() < 180)
- brush->setAngle(brush->getAngle()+1);
+ if (brush.angle() < 180)
+ brush.angle(brush.angle()+1);
break;
case DecrementAngle:
- if (brush->getAngle() > 0)
- brush->setAngle(brush->getAngle()-1);
+ if (brush.angle() > 0)
+ brush.angle(brush.angle()-1);
break;
case CustomBrush:
App::instance()->getMainWindow()->getContextBar()
@@ -19,7 +19,6 @@
#include "app/modules/gfx.h"
#include "app/modules/gui.h"
#include "app/pref/preferences.h"
-#include "app/settings/settings.h"
#include "app/ui/color_button.h"
#include "app/ui/editor/editor.h"
#include "app/ui/status_bar.h"
@@ -68,13 +67,8 @@ class ToolsConfigurationWindow : public app::gen::ToolsConfiguration,
}
private:
- ISettings* settings() {
- ASSERT(m_ctx);
- return m_ctx->settings();
- }
-
Preferences& preferences() {
- return App::instance()->preferences();
+ return Preferences::instance();
}
DocumentPreferences& docPref() {
@@ -13,7 +13,6 @@
#include "app/commands/command.h"
#include "app/commands/commands.h"
#include "app/context_access.h"
-#include "app/settings/settings.h"
#include "app/tools/tool_box.h"
#include "app/ui/context_bar.h"
#include "app/ui/main_window.h"
@@ -422,7 +422,7 @@ void ExportSpriteSheetCommand::onExecute(Context* context)
{
Document* document(context->activeDocument());
Sprite* sprite = document->sprite();
- DocumentPreferences& docPref(App::instance()->preferences().document(document));
+ DocumentPreferences& docPref(Preferences::instance().document(document));
if (m_useUI && context->isUiAvailable()) {
ExportSpriteSheetWindow window(document, sprite, docPref);
@@ -17,7 +17,6 @@
#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"
#include "app/ui/color_bar.h"
@@ -84,8 +83,8 @@ void EyedropperCommand::onExecute(Context* context)
gfx::Point pixelPos = editor->screenToEditor(ui::get_mouse_position());
// Check if we've to grab alpha channel or the merged color.
- ISettings* settings = UIContext::instance()->settings();
- bool grabAlpha = App::instance()->preferences().editor.grabAlpha();
+ Preferences& pref = Preferences::instance();
+ bool grabAlpha = pref.editor.grabAlpha();
ColorPicker picker;
picker.pickColor(editor->getSite(),
@@ -96,15 +95,14 @@ void EyedropperCommand::onExecute(Context* context)
if (grabAlpha) {
tools::ToolBox* toolBox = App::instance()->getToolBox();
- for (tools::ToolIterator it=toolBox->begin(), end=toolBox->end(); it!=end; ++it) {
- settings->getToolSettings(*it)->setOpacity(picker.alpha());
- }
+ for (auto tool : *toolBox)
+ pref.tool(tool).opacity(picker.alpha());
}
if (m_background)
- settings->setBgColor(picker.color());
+ pref.colorBar.bgColor(picker.color());
else
- settings->setFgColor(picker.color());
+ pref.colorBar.fgColor(picker.color());
}
Command* CommandFactory::createEyedropperCommand()
@@ -59,7 +59,7 @@ class PreviewWindow : public Window {
// will call other sub-commands (e.g. previous frame, next frame,
// etc.).
View* view = View::getView(editor);
- DocumentPreferences& docPref = App::instance()->preferences().document(m_doc);
+ DocumentPreferences& docPref = Preferences::instance().document(m_doc);
m_tiled = (filters::TiledMode)docPref.tiled.mode();
// Free mouse
Oops, something went wrong.

0 comments on commit f6be0c3

Please sign in to comment.