1 /* This file is part of Dilay
2  * Copyright © 2015-2018 Alexander Bau
3  * Use and redistribute under the terms of the GNU General Public License
4  */
5 #include <QCheckBox>
6 #include "cache.hpp"
7 #include "tool/sculpt/util/brush.hpp"
8 #include "tools.hpp"
9 #include "view/two-column-grid.hpp"
10 #include "view/util.hpp"
11 
12 struct ToolSculptPinch::Impl
13 {
14   ToolSculptPinch* self;
15 
ImplToolSculptPinch::Impl16   Impl (ToolSculptPinch* s)
17     : self (s)
18   {
19   }
20 
runSetupBrushToolSculptPinch::Impl21   void runSetupBrush (SculptBrush& brush)
22   {
23     auto& params = brush.initParameters<SBPinchParameters> ();
24 
25     params.invert (this->self->cache ().get<bool> ("invert", false));
26   }
27 
runSetupCursorToolSculptPinch::Impl28   void runSetupCursor (ViewCursor&) {}
29 
runSetupPropertiesToolSculptPinch::Impl30   void runSetupProperties (ViewTwoColumnGrid& properties)
31   {
32     auto& params = this->self->brush ().parameters<SBPinchParameters> ();
33 
34     QCheckBox& invertEdit = ViewUtil::checkBox (QObject::tr ("Invert"), params.invert ());
35     ViewUtil::connect (invertEdit, [this, &params](bool i) {
36       params.invert (i);
37       this->self->cache ().set ("invert", i);
38     });
39     properties.add (invertEdit);
40   }
41 
runSetupToolTipToolSculptPinch::Impl42   void runSetupToolTip (ViewToolTip& toolTip)
43   {
44     this->self->addDefaultToolTip (toolTip, true, false);
45   }
46 
runSculptPointingEventToolSculptPinch::Impl47   bool runSculptPointingEvent (const ViewPointingEvent& e)
48   {
49     const std::function<void()> toggleInvert = [this]() {
50       this->self->brush ().parameters<SBPinchParameters> ().toggleInvert ();
51     };
52     return this->self->drawlikeStroke (e, false, &toggleInvert);
53   }
54 };
55 
56 DELEGATE_TOOL_SCULPT (ToolSculptPinch)
57