diff --git a/libs/ui/kis_popup_palette.h b/libs/ui/kis_popup_palette.h --- a/libs/ui/kis_popup_palette.h +++ b/libs/ui/kis_popup_palette.h @@ -20,16 +20,10 @@ #ifndef KIS_POPUP_PALETTE_H #define KIS_POPUP_PALETTE_H -#include -#include -#include #include #include -#include -#include "kis_action_manager.h" #include "KisViewManager.h" #include "kactioncollection.h" -#include "kis_coordinates_converter.h" #include "kis_tool_button.h" #include "kis_highlighted_button.h" #include @@ -69,7 +63,7 @@ int selectedColor() const; void setParent(QWidget *parent); - void tabletEvent(QTabletEvent * event) override; + void tabletEvent(QTabletEvent *event) override; protected: @@ -92,7 +86,6 @@ void setHoveredColor(int x); int hoveredColor() const; - private: void setVisible(bool b) override; @@ -105,21 +98,21 @@ int numSlots(); void adjustLayout(const QPoint &p); -private: +private: int m_hoveredPreset {0}; int m_hoveredColor {0}; int m_selectedColor {0}; - KisCoordinatesConverter* m_coordinatesConverter; + KisCoordinatesConverter *m_coordinatesConverter; - KisViewManager* m_viewManager; - KisActionManager* m_actionManager; - KisFavoriteResourceManager* m_resourceManager; - KisColorSelectorInterface* m_triangleColorSelector {0}; + KisViewManager *m_viewManager; + KisActionManager *m_actionManager; + KisFavoriteResourceManager *m_resourceManager; + KisColorSelectorInterface *m_triangleColorSelector {0}; const KoColorDisplayRendererInterface *m_displayRenderer; QScopedPointer m_colorChangeCompressor; - KActionCollection* m_actionCollection; + KActionCollection *m_actionCollection; QTimer m_timer; @@ -175,8 +168,6 @@ void slotCanvasonlyModeClicked(); void slotZoomToOneHundredPercentClicked(); void slotZoomSliderChanged(int zoom); - - }; #endif // KIS_POPUP_PALETTE_H diff --git a/libs/ui/kis_popup_palette.cpp b/libs/ui/kis_popup_palette.cpp --- a/libs/ui/kis_popup_palette.cpp +++ b/libs/ui/kis_popup_palette.cpp @@ -22,32 +22,20 @@ #include "kis_canvas2.h" #include "kis_config.h" #include "kis_popup_palette.h" -#include "kis_paintop_box.h" #include "kis_favorite_resource_manager.h" #include "kis_icon_utils.h" -#include #include "KisResourceServerProvider.h" #include #include #include #include -#include "KoColorSpaceRegistry.h" -#include #include -#include -#include #include #include -#include #include -#include -#include -#include #include "kis_signal_compressor.h" -#include #include "brushhud/kis_brush_hud.h" #include "brushhud/kis_round_hud_button.h" -#include #include "kis_signals_blocker.h" #include "kis_canvas_controller.h" @@ -260,7 +248,6 @@ } else { m_triangleColorSelector->slotSetColor(color); } - } void KisPopupPalette::slotEmitColorChanged() @@ -321,7 +308,6 @@ KIS_ASSERT_RECOVER_RETURN(m_brushHud); if (isVisible() && parentWidget()) { - float hudMargin = 30.0; const QRect fitRect = kisGrowRect(parentWidget()->rect(), -20.0); // -20 is widget margin const QPoint paletteCenterOffset(m_popupPaletteSize / 2, m_popupPaletteSize / 2); @@ -375,16 +361,14 @@ void KisPopupPalette::showPopupPalette(bool show) { if (show) { - // don't set the zoom slider if we are outside of the zoom slider bounds. It will change the zoom level to within // the bounds and cause the canvas to jump between the slider's min and max if (m_coordinatesConverter->zoomInPercent() > zoomSliderMinValue && m_coordinatesConverter->zoomInPercent() < zoomSliderMaxValue ){ KisSignalsBlocker b(zoomCanvasSlider); zoomCanvasSlider->setValue(m_coordinatesConverter->zoomInPercent()); // sync the zoom slider } - emit sigEnableChangeFGColor(!show); } else { emit sigTriggerTimer(); @@ -426,13 +410,13 @@ painter.setRenderHint(QPainter::Antialiasing); painter.setRenderHint(QPainter::SmoothPixmapTransform); - //painting background color indicator + // painting background color indicator QPainterPath bgColor; bgColor.addEllipse(QPoint( 50, 80), 30, 30); painter.fillPath(bgColor, m_displayRenderer->toQColor(m_resourceManager->bgColor())); painter.drawPath(bgColor); - //painting foreground color indicator + // painting foreground color indicator QPainterPath fgColor; fgColor.addEllipse(QPoint( 60, 50), 30, 30); painter.fillPath(fgColor, m_displayRenderer->toQColor(m_triangleColorSelector->getCurrentColor())); @@ -451,7 +435,6 @@ painter.drawPath(backgroundContainer); - // create a path slightly inside the container circle. this will create a 'track' to indicate that we can rotate the canvas // with the indicator QPainterPath rotationTrackPath; @@ -464,9 +447,6 @@ painter.setPen(pen); painter.drawPath(rotationTrackPath); - - - // this thing will help indicate where the starting brush preset is at. // also what direction they go to give sor order to the presets populated /* @@ -482,15 +462,11 @@ brushDir.lineTo(brushDir.currentPosition().x()-2, brushDir.currentPosition().y() + 6); painter.drawPath(brushDir); - */ - // the following things needs to be based off the center, so let's translate the painter painter.translate(m_popupPaletteSize / 2, m_popupPaletteSize / 2); - - // create the canvas rotation handle QPainterPath rotationIndicator = drawRotationIndicator(m_coordinatesConverter->rotationAngle(), true); @@ -508,8 +484,6 @@ painter.restore(); } - - // create a reset canvas rotation indicator to bring the canvas back to 0 degrees QPainterPath resetRotationIndicator = drawRotationIndicator(0, false); @@ -521,12 +495,10 @@ painter.restore(); - - - //painting favorite brushes + // painting favorite brushes QList images(m_resourceManager->favoritePresetImages()); - //painting favorite brushes pixmap/icon + // painting favorite brushes pixmap/icon QPainterPath presetPath; for (int pos = 0; pos < numSlots(); pos++) { painter.save(); @@ -558,7 +530,6 @@ } // paint recent colors area. - painter.setPen(Qt::NoPen); float rotationAngle = -360.0 / m_resourceManager->recentColorsTotal(); @@ -582,7 +553,7 @@ } - //painting hovered color + // painting hovered color if (hoveredColor() > -1) { painter.setPen(QPen(palette().color(QPalette::Highlight), 2, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin)); @@ -597,7 +568,7 @@ } } - //painting selected color + // painting selected color if (selectedColor() > -1) { painter.setPen(QPen(palette().color(QPalette::Highlight).darker(130), 2, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin)); @@ -661,20 +632,18 @@ indicatorRectangle.width(), indicatorRectangle.height() ); return canvasRotationIndicator; - } -void KisPopupPalette::mouseMoveEvent(QMouseEvent* event) +void KisPopupPalette::mouseMoveEvent(QMouseEvent *event) { QPointF point = event->localPos(); event->accept(); setToolTip(QString()); setHoveredPreset(-1); setHoveredColor(-1); - // calculate if we are over the canvas rotation knob // before we started painting, we moved the painter to the center of the widget, so the X/Y positions are offset. we need to // correct them first before looking for a click event intersection @@ -690,7 +659,6 @@ m_isOverCanvasRotationIndicator = false; } - if (m_isRotatingCanvasIndicator) { // we are rotating the canvas, so calculate the rotation angle based off the center // calculate the angle we are at first @@ -711,7 +679,6 @@ emit sigUpdateCanvas(); } - // don't highlight the presets if we are in the middle of rotating the canvas if (m_isRotatingCanvasIndicator == false) { QPainterPath pathColor(drawDonutPathFull(m_popupPaletteSize / 2, m_popupPaletteSize / 2, m_colorHistoryInnerRadius, m_colorHistoryOuterRadius)); @@ -732,12 +699,10 @@ } } - - update(); } -void KisPopupPalette::mousePressEvent(QMouseEvent* event) +void KisPopupPalette::mousePressEvent(QMouseEvent *event) { QPointF point = event->localPos(); event->accept(); @@ -762,20 +727,20 @@ QRect correctedResetCanvasRotationIndicator = QRect(rotationCorrectedXPos, rotationCorrectedYPos, m_resetCanvasRotationIndicatorRect.width(), m_resetCanvasRotationIndicatorRect.height()); - if (correctedResetCanvasRotationIndicator.contains(point.x(), point.y())) { - float angleDifference = -m_coordinatesConverter->rotationAngle(); // the rotation function accepts diffs, so find it ou - m_coordinatesConverter->rotate(m_coordinatesConverter->widgetCenterPoint(), angleDifference); - m_viewManager->canvasBase()->notifyZoomChanged(); // refreshes the canvas after rotation + float angleDifference = -m_coordinatesConverter->rotationAngle(); // the rotation function accepts diffs + KisCanvasController *canvasController = + dynamic_cast(m_viewManager->canvasBase()->canvasController()); + canvasController->rotateCanvas(angleDifference); emit sigUpdateCanvas(); } } } void KisPopupPalette::slotShowTagsPopup() { - KisPaintOpPresetResourceServer* rServer = KisResourceServerProvider::instance()->paintOpPresetServer(); + KisPaintOpPresetResourceServer *rServer = KisResourceServerProvider::instance()->paintOpPresetServer(); QStringList tags = rServer->tagNamesList(); std::sort(tags.begin(), tags.end()); @@ -785,7 +750,7 @@ menu.addAction(tag); } - QAction* action = menu.exec(QCursor::pos()); + QAction *action = menu.exec(QCursor::pos()); if (action) { m_resourceManager->setCurrentTag(action->text()); } @@ -796,44 +761,37 @@ } void KisPopupPalette::slotmirroModeClicked() { - QAction* action = m_actionCollection->action("mirror_canvas"); + QAction *action = m_actionCollection->action("mirror_canvas"); if (action) { action->trigger(); } } void KisPopupPalette::slotCanvasonlyModeClicked() { - QAction* action = m_actionCollection->action("view_show_canvas_only"); + QAction *action = m_actionCollection->action("view_show_canvas_only"); if (action) { action->trigger(); } } - void KisPopupPalette::slotZoomToOneHundredPercentClicked() { - QAction* action = m_actionCollection->action("zoom_to_100pct"); + QAction *action = m_actionCollection->action("zoom_to_100pct"); if (action) { action->trigger(); } // also move the zoom slider to 100% position so they are in sync zoomCanvasSlider->setValue(100); - - } - - - -void KisPopupPalette::tabletEvent(QTabletEvent* event) { +void KisPopupPalette::tabletEvent(QTabletEvent *event) { event->ignore(); } - -void KisPopupPalette::mouseReleaseEvent(QMouseEvent * event) +void KisPopupPalette::mouseReleaseEvent(QMouseEvent *event) { QPointF point = event->localPos(); event->accept(); @@ -879,7 +837,7 @@ return pos; } -bool KisPopupPalette::isPointInPixmap(QPointF& point, int pos) +bool KisPopupPalette::isPointInPixmap(QPointF &point, int pos) { if (createPathFromPresetIndex(pos).contains(point + QPointF(-m_popupPaletteSize / 2, -m_popupPaletteSize / 2))) { return true; @@ -893,7 +851,6 @@ QPainterPath KisPopupPalette::createPathFromPresetIndex(int index) { - qreal angleSlice = 360.0 / numSlots() ; // how many degrees each slice will get // the starting angle of the slice we need to draw. the negative sign makes us go clockwise.