X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fdrawingview.cpp;fp=src%2Fdrawingview.cpp;h=d8726fed5d91d82d86e2616877306ba2a1401cb6;hb=cdde036d71eb0ea9b450345bd297c8730591b26b;hp=4ae021c6da555d0091cda947e9296638efb3e9c4;hpb=fce575a51ba1f26418869c20e63b9f388e118ab6;p=architektonas diff --git a/src/drawingview.cpp b/src/drawingview.cpp index 4ae021c..d8726fe 100644 --- a/src/drawingview.cpp +++ b/src/drawingview.cpp @@ -193,7 +193,6 @@ void DrawingView::DrawSubGrid(Painter * painter, uint32_t color, double step, Ve // void DrawingView::DeleteCurrentLayer(int layer) { -//printf("DrawingView::DeleteCurrentLayer(): currentLayer = %i\n", layer); VPVectorIter i = document.objects.begin(); while (i != document.objects.end()) @@ -230,7 +229,6 @@ void DrawingView::HandleLayerToggle(void) // void DrawingView::HandleLayerSwap(int layer1, int layer2) { -//printf("DrawingView: Swapping layers %i and %i.\n", layer1, layer2); HandleLayerSwap(layer1, layer2, document.objects); } @@ -253,42 +251,6 @@ void DrawingView::HandleLayerSwap(int layer1, int layer2, VPVector & v) } } -void DrawingView::HandlePenWidth(float width) -{ - for(VPVectorIter i=select.begin(); i!=select.end(); i++) - { - Object * obj = (Object *)(*i); - obj->thickness = width; - } - - supressSelected = true; - update(); -} - -void DrawingView::HandlePenStyle(int style) -{ - for(VPVectorIter i=select.begin(); i!=select.end(); i++) - { - Object * obj = (Object *)(*i); - obj->style = style; - } - - supressSelected = true; - update(); -} - -void DrawingView::HandlePenColor(uint32_t color) -{ - for(VPVectorIter i=select.begin(); i!=select.end(); i++) - { - Object * obj = (Object *)(*i); - obj->color = color; - } - - supressSelected = true; - update(); -} - void DrawingView::HandlePenStamp(QAction * action) { PenWidget * pw = (PenWidget *)action->parentWidget(); @@ -340,7 +302,6 @@ QPoint DrawingView::GetAdjustedClientPosition(int x, int y) void DrawingView::focusOutEvent(QFocusEvent * /*event*/) { -// printf("DrawingView::focusOutEvent()...\n"); // Make sure all modkeys being held are marked as released when the app // loses focus (N.B.: This only works because the app sets the focus policy // of this object to something other than Qt::NoFocus) @@ -355,9 +316,6 @@ void DrawingView::focusInEvent(QFocusEvent * /*event*/) setCursor(curMarker); else if (Global::penDropper) setCursor(curDropper); -//FocusOut already set this... -// else -// setCursor(Qt::ArrowCursor); } void DrawingView::paintEvent(QPaintEvent * /*event*/) @@ -723,16 +681,45 @@ Where is the text offset? It looks like it's drawing in the center, but obvious } // -// This toggles the selection being hovered (typically, only 1 object) +// This toggles the selection being hovered (typically, only 1 object). We +// toggle because the CTRL key might be held, in which case, we want to +// deselect a selected object. // -void DrawingView::AddHoveredToSelection(void) +void DrawingView::HandleSelectionClick(VPVector & v) { - for(VPVectorIter i=document.objects.begin(); i!=document.objects.end(); i++) + if (ctrlDown) + { + for(VPVectorIter i=v.begin(); i!=v.end(); i++) + { + Object * obj = (Object *)(*i); + + if (obj->hovered) + obj->selected = !obj->selected; + } + + return; + } + + for(VPVectorIter i=v.begin(); i!=v.end(); i++) + ((Object *)(*i))->selected = false; + + // Check if the hover changed, and if so, reset the selection stack + if (oldHover.size() != v.size()) { - if (((Object *)(*i))->hovered) -// ((Object *)(*i))->selected = true; - ((Object *)(*i))->selected = !((Object *)(*i))->selected; + oldHover = v; + currentSelect = 0; } + else + { + // Select next object in the stack under the cursor + currentSelect++; + + if (currentSelect >= v.size()) + currentSelect = 0; + } + + dragged = (Object *)v[currentSelect]; + dragged->selected = true; } VPVector DrawingView::GetSelection(void) @@ -1798,7 +1785,6 @@ void DrawingView::mousePressEvent(QMouseEvent * event) { if (event->button() == Qt::LeftButton) { -//printf("mousePressEvent::Qt::LeftButton numHovered=%li\n", numHovered); Vector point = Painter::QtToCartesianCoords(Vector(event->x(), event->y())); // Handle tool processing, if any @@ -1819,17 +1805,11 @@ void DrawingView::mousePressEvent(QMouseEvent * event) if (!ctrlDown) ClearSelected(document.objects); - // If any objects are being hovered on click, add them to the selection - // & return + // If any objects are being hovered on click, deal with 'em if (numHovered > 0) { - AddHoveredToSelection(); - update(); // needed?? -// GetHovered(hover); // prolly needed VPVector hover2 = GetHovered(); dragged = (Object *)hover2[0]; - draggingObject = true; -//printf("mousePressEvent::numHovered > 0 (hover2[0]=$%llx, type=%s)\n", dragged, objName[dragged->type]); // Alert the pen widget if (Global::penDropper) @@ -1838,26 +1818,27 @@ void DrawingView::mousePressEvent(QMouseEvent * event) Global::penWidth = dragged->thickness; Global::penStyle = dragged->style; emit ObjectSelected(dragged); - ClearSelected(document.objects); return; } - - if (Global::penStamp) + else if (Global::penStamp) { dragged->color = Global::penColor; dragged->thickness = Global::penWidth; dragged->style = Global::penStyle; return; } - - // See if anything is using just a straight click on a handle - if (HandleObjectClicked()) + // See if anything is using just a straight click on a custom + // object handle (like Dimension objects) + else if (HandleObjectClicked()) { - draggingObject = false; update(); return; } + draggingObject = true; + HandleSelectionClick(hover2); + update(); // needed?? + // Needed for grab & moving objects // We do it *after*... why? (doesn't seem to confer any advantage...) if (hoveringIntersection)