Differential D20653 Diff 56543 plugins/paintops/defaultpaintops/duplicate/kis_duplicateop_settings.cpp
Changeset View
Changeset View
Standalone View
Standalone View
plugins/paintops/defaultpaintops/duplicate/kis_duplicateop_settings.cpp
Show All 34 Lines | |||||
35 | #include <kis_paintop_settings_widget.h> | 35 | #include <kis_paintop_settings_widget.h> | ||
36 | #include <kis_pressure_darken_option.h> | 36 | #include <kis_pressure_darken_option.h> | ||
37 | #include <kis_pressure_opacity_option.h> | 37 | #include <kis_pressure_opacity_option.h> | ||
38 | #include <kis_pressure_size_option.h> | 38 | #include <kis_pressure_size_option.h> | ||
39 | #include <kis_paint_action_type_option.h> | 39 | #include <kis_paint_action_type_option.h> | ||
40 | #include <kis_dom_utils.h> | 40 | #include <kis_dom_utils.h> | ||
41 | 41 | | |||
42 | KisDuplicateOpSettings::KisDuplicateOpSettings() | 42 | KisDuplicateOpSettings::KisDuplicateOpSettings() | ||
43 | : m_isOffsetNotUptodate(false) | 43 | : m_isOffsetNotUptodate(false), m_duringPaintingStroke(false) | ||
44 | { | 44 | { | ||
45 | } | 45 | } | ||
46 | 46 | | |||
47 | KisDuplicateOpSettings::~KisDuplicateOpSettings() | 47 | KisDuplicateOpSettings::~KisDuplicateOpSettings() | ||
48 | { | 48 | { | ||
49 | } | 49 | } | ||
50 | 50 | | |||
51 | bool KisDuplicateOpSettings::paintIncremental() | 51 | bool KisDuplicateOpSettings::paintIncremental() | ||
Show All 24 Lines | 75 | if (modifiers & Qt::ControlModifier) { | |||
76 | if (!m_sourceNode || !(modifiers & Qt::AltModifier)) { | 76 | if (!m_sourceNode || !(modifiers & Qt::AltModifier)) { | ||
77 | m_sourceNode = currentNode; | 77 | m_sourceNode = currentNode; | ||
78 | } | 78 | } | ||
79 | m_position = info.pos(); | 79 | m_position = info.pos(); | ||
80 | m_isOffsetNotUptodate = true; | 80 | m_isOffsetNotUptodate = true; | ||
81 | ignoreEvent = false; | 81 | ignoreEvent = false; | ||
82 | } | 82 | } | ||
83 | else { | 83 | else { | ||
84 | if (m_isOffsetNotUptodate) { | 84 | bool resetOrigin = getBool(DUPLICATE_RESET_SOURCE_POINT); | ||
85 | if (m_isOffsetNotUptodate || resetOrigin) { | ||||
85 | m_offset = info.pos() - m_position; | 86 | m_offset = info.pos() - m_position; | ||
86 | m_isOffsetNotUptodate = false; | 87 | m_isOffsetNotUptodate = false; | ||
87 | } | 88 | } | ||
89 | m_duringPaintingStroke = true; | ||||
88 | ignoreEvent = true; | 90 | ignoreEvent = true; | ||
89 | } | 91 | } | ||
90 | 92 | | |||
91 | return ignoreEvent; | 93 | return ignoreEvent; | ||
92 | } | 94 | } | ||
93 | 95 | | |||
96 | bool KisDuplicateOpSettings::mouseReleaseEvent() | ||||
97 | { | ||||
98 | m_duringPaintingStroke = false; | ||||
99 | bool ignoreEvent = true; | ||||
100 | return ignoreEvent; | ||||
101 | } | ||||
102 | | ||||
103 | | ||||
94 | KisNodeWSP KisDuplicateOpSettings::sourceNode() const | 104 | KisNodeWSP KisDuplicateOpSettings::sourceNode() const | ||
95 | { | 105 | { | ||
96 | return m_sourceNode; | 106 | return m_sourceNode; | ||
97 | } | 107 | } | ||
98 | 108 | | |||
99 | void KisDuplicateOpSettings::activate() | 109 | void KisDuplicateOpSettings::activate() | ||
100 | { | 110 | { | ||
101 | } | 111 | } | ||
Show All 22 Lines | |||||
124 | KisPaintOpSettingsSP KisDuplicateOpSettings::clone() const | 134 | KisPaintOpSettingsSP KisDuplicateOpSettings::clone() const | ||
125 | { | 135 | { | ||
126 | KisPaintOpSettingsSP setting = KisBrushBasedPaintOpSettings::clone(); | 136 | KisPaintOpSettingsSP setting = KisBrushBasedPaintOpSettings::clone(); | ||
127 | KisDuplicateOpSettings* s = dynamic_cast<KisDuplicateOpSettings*>(setting.data()); | 137 | KisDuplicateOpSettings* s = dynamic_cast<KisDuplicateOpSettings*>(setting.data()); | ||
128 | s->m_offset = m_offset; | 138 | s->m_offset = m_offset; | ||
129 | s->m_isOffsetNotUptodate = m_isOffsetNotUptodate; | 139 | s->m_isOffsetNotUptodate = m_isOffsetNotUptodate; | ||
130 | s->m_position = m_position; | 140 | s->m_position = m_position; | ||
131 | s->m_sourceNode = m_sourceNode; | 141 | s->m_sourceNode = m_sourceNode; | ||
142 | s->m_duringPaintingStroke = m_duringPaintingStroke; | ||||
132 | 143 | | |||
133 | return setting; | 144 | return setting; | ||
134 | } | 145 | } | ||
135 | 146 | | |||
136 | QPainterPath KisDuplicateOpSettings::brushOutline(const KisPaintInformation &info, const OutlineMode &mode) | 147 | QPainterPath KisDuplicateOpSettings::brushOutline(const KisPaintInformation &info, const OutlineMode &mode) | ||
137 | { | 148 | { | ||
138 | QPainterPath path; | 149 | QPainterPath path; | ||
139 | 150 | | |||
140 | OutlineMode forcedMode = mode; | 151 | OutlineMode forcedMode = mode; | ||
141 | 152 | | |||
142 | if (!forcedMode.isVisible) { | 153 | if (!forcedMode.isVisible) { | ||
143 | forcedMode.isVisible = true; | 154 | forcedMode.isVisible = true; | ||
144 | forcedMode.forceCircle = true; | 155 | forcedMode.forceCircle = true; | ||
145 | } | 156 | } | ||
146 | 157 | | |||
147 | // clone tool should always show an outline | 158 | // clone tool should always show an outline | ||
148 | path = KisBrushBasedPaintOpSettings::brushOutlineImpl(info, forcedMode, 1.0); | 159 | path = KisBrushBasedPaintOpSettings::brushOutlineImpl(info, forcedMode, 1.0); | ||
149 | 160 | | |||
150 | QPainterPath copy(path); | 161 | QPainterPath copy(path); | ||
151 | QRectF rect2 = copy.boundingRect(); | 162 | QRectF rect2 = copy.boundingRect(); | ||
152 | if (m_isOffsetNotUptodate || !getBool(DUPLICATE_MOVE_SOURCE_POINT)) { | 163 | bool shouldStayInOrigin = m_isOffsetNotUptodate // the clone brush right now waits for first stroke with a new origin, so stays at origin point | ||
164 | || !getBool(DUPLICATE_MOVE_SOURCE_POINT) // the brush always use the same source point, so stays at origin point | ||||
165 | || (!m_duringPaintingStroke && getBool(DUPLICATE_RESET_SOURCE_POINT)); // during the stroke, with reset Origin selected, outline should stay at origin point | ||||
166 | | ||||
167 | if (shouldStayInOrigin) { | ||||
153 | copy.translate(m_position - info.pos()); | 168 | copy.translate(m_position - info.pos()); | ||
154 | } | 169 | } | ||
155 | else { | 170 | else { | ||
156 | copy.translate(-m_offset); | 171 | copy.translate(-m_offset); | ||
157 | } | 172 | } | ||
158 | 173 | | |||
159 | path.addPath(copy); | 174 | path.addPath(copy); | ||
160 | 175 | | |||
▲ Show 20 Lines • Show All 86 Lines • Show Last 20 Lines |