~ubuntu-branches/ubuntu/precise/koffice/precise

« back to all changes in this revision

Viewing changes to krita/plugins/tools/defaulttools/kis_tool_move.cc

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2010-09-21 15:36:35 UTC
  • mfrom: (1.4.1 upstream) (60.2.11 maverick)
  • Revision ID: james.westby@ubuntu.com-20100921153635-6tejqkiro2u21ydi
Tags: 1:2.2.2-0ubuntu3
Add kubuntu_03_fix-crash-on-closing-sqlite-connection-2.2.2.diff and
kubuntu_04_support-large-memo-values-for-msaccess-2.2.2.diff as
recommended by upstream http://kexi-
project.org/wiki/wikiview/index.php@Kexi2.2_Patches.html#sqlite_stab
ility

Show diffs side-by-side

added added

removed removed

Lines of Context:
79
79
        const KoColorSpace* cs = layer->projection()->colorSpace();
80
80
        KoColor color(cs);
81
81
        layer->projection()->pixel(x, y, &color);
82
 
        if (cs->alpha(color.data()) == OPACITY_TRANSPARENT) {
 
82
        if (cs->opacityU8(color.data()) == OPACITY_TRANSPARENT_U8) {
83
83
            return 0;
84
84
        }
85
85
    }
97
97
                    layer->projection()->pixel(x, y, &color);
98
98
 
99
99
                    // XXX:; have threshold here? Like, only a little bit transparent, we don't select it?
100
 
                    if (cs->alpha(color.data()) != OPACITY_TRANSPARENT) {
 
100
                    if (cs->opacityU8(color.data()) != OPACITY_TRANSPARENT_U8) {
101
101
                        foundNode = node;
102
102
                    }
103
103
                }
113
113
 
114
114
void KisToolMove::mousePressEvent(KoPointerEvent *e)
115
115
{
116
 
    if (m_canvas && e->button() == Qt::LeftButton) {
 
116
    if (canvas() && e->button() == Qt::LeftButton) {
117
117
        QPointF pos = convertToPixelCoord(e);
118
118
 
119
119
        KisNodeSP node;
128
128
 
129
129
        KisSelectionSP selection = currentSelection();
130
130
 
131
 
        if (cs->alpha(color.data()) == OPACITY_TRANSPARENT
 
131
        if (cs->opacityU8(color.data()) == OPACITY_TRANSPARENT_U8
132
132
                || m_optionsWidget->radioSelectedLayer->isChecked()
133
133
                || e->modifiers() == Qt::ControlModifier) {
134
134
            node = currentNode();
139
139
            node = findNode(node, pos.x(), pos.y());
140
140
 
141
141
            // if there is a selection, we cannot move the group
142
 
            if (!selection && (m_optionsWidget->radioGroup->isChecked() or e->modifiers() == (Qt::ControlModifier | Qt::ShiftModifier))) {
 
142
            if (!selection && (m_optionsWidget->radioGroup->isChecked() || e->modifiers() == (Qt::ControlModifier | Qt::ShiftModifier))) {
143
143
                node = node->parent();
144
144
            }
145
145
        }
154
154
        }
155
155
 
156
156
        if (selection && !selection->isTotallyUnselected(image->bounds())) {
157
 
            selection->convertToQImage(0).save("selection.png");
 
157
            //selection->convertToQImage(0).save("selection.png");
158
158
            // Create a temporary layer with the contents of the selection of the current layer.
159
159
            Q_ASSERT(!node->inherits("KisGroupLayer"));
160
160
 
169
169
                KisPainter gc(dev);
170
170
                gc.setSelection(selection);
171
171
                gc.setCompositeOp(COMPOSITE_OVER);
172
 
                gc.setOpacity(OPACITY_OPAQUE);
 
172
                gc.setOpacity(OPACITY_OPAQUE_U8);
173
173
                QRect rc = oldLayer->extent();
174
174
                gc.bitBlt(rc.topLeft(), oldLayer->paintDevice(), rc);
175
175
                gc.end();
181
181
                // deselect away the selection???
182
182
                selection->clear();
183
183
 
184
 
                KisCanvas2* kisCanvas = dynamic_cast<KisCanvas2*>(m_canvas);
 
184
                KisCanvas2* kisCanvas = dynamic_cast<KisCanvas2*>(canvas());
185
185
                KisView2* view = 0;
186
186
                if (kisCanvas) {
187
187
                    view = kisCanvas->view();
213
213
 
214
214
void KisToolMove::mouseMoveEvent(KoPointerEvent *e)
215
215
{
216
 
    if (m_canvas && m_dragging) {
 
216
    if (canvas() && m_dragging) {
217
217
        QPointF posf = convertToPixelCoord(e);
218
218
        QPoint pos = QPoint(static_cast<int>(posf.x()), static_cast<int>(posf.y()));
219
219
        if ((e->modifiers() & Qt::AltModifier) || (e->modifiers() & Qt::ControlModifier)) {
231
231
void KisToolMove::mouseReleaseEvent(KoPointerEvent *e)
232
232
{
233
233
    if (m_dragging) {
234
 
        if (m_canvas && e->button() == Qt::LeftButton) {
 
234
        if (canvas() && e->button() == Qt::LeftButton) {
235
235
            QPointF pos = convertToPixelCoord(e);
236
236
            if (m_selectedNode) {
237
237
                drag(QPoint(static_cast<int>(pos.x()), static_cast<int>(pos.y())));
240
240
                QUndoCommand *cmd = new KisNodeMoveCommand(m_selectedNode, m_layerStart, m_layerPosition);
241
241
                Q_CHECK_PTR(cmd);
242
242
 
243
 
                m_canvas->addCommand(cmd);
 
243
                canvas()->addCommand(cmd);
244
244
                currentImage()->undoAdapter()->endMacro();
245
245
            }
246
246
            currentImage()->setModified();