Changeset View
Changeset View
Standalone View
Standalone View
libs/ui/tool/kis_tool_paint.cc
Show First 20 Lines • Show All 74 Lines • ▼ Show 20 Line(s) | |||||
75 | #include <brushengine/kis_paintop.h> | 75 | #include <brushengine/kis_paintop.h> | ||
76 | #include <brushengine/kis_paintop_preset.h> | 76 | #include <brushengine/kis_paintop_preset.h> | ||
77 | #include <kis_action_manager.h> | 77 | #include <kis_action_manager.h> | ||
78 | #include <kis_action.h> | 78 | #include <kis_action.h> | ||
79 | #include "strokes/kis_color_picker_stroke_strategy.h" | 79 | #include "strokes/kis_color_picker_stroke_strategy.h" | ||
80 | #include <kis_canvas_resource_provider.h> | 80 | #include <kis_canvas_resource_provider.h> | ||
81 | 81 | | |||
82 | 82 | | |||
83 | KisToolPaint::KisToolPaint(KoCanvasBase * canvas, const QCursor & cursor) | 83 | KisToolPaint::KisToolPaint(KoCanvasBase *canvas, const QCursor &cursor) | ||
84 | : KisTool(canvas, cursor), | 84 | : KisTool(canvas, cursor), | ||
85 | m_showColorPreview(false), | 85 | m_showColorPreview(false), | ||
86 | m_colorPreviewShowComparePlate(false), | 86 | m_colorPreviewShowComparePlate(false), | ||
87 | m_colorPickerDelayTimer(), | 87 | m_colorPickerDelayTimer(), | ||
88 | m_isOutlineEnabled(true) | 88 | m_isOutlineEnabled(true) | ||
89 | { | 89 | { | ||
90 | m_specialHoverModifier = false; | 90 | m_specialHoverModifier = false; | ||
91 | m_optionsWidgetLayout = 0; | 91 | m_optionsWidgetLayout = 0; | ||
Show All 10 Lines | 101 | do { | |||
102 | m_standardBrushSizes.push_back(brushSize); | 102 | m_standardBrushSizes.push_back(brushSize); | ||
103 | int increment = qMax(1, int(std::ceil(qreal(brushSize) / 15))); | 103 | int increment = qMax(1, int(std::ceil(qreal(brushSize) / 15))); | ||
104 | brushSize += increment; | 104 | brushSize += increment; | ||
105 | } while (brushSize < maxSize); | 105 | } while (brushSize < maxSize); | ||
106 | 106 | | |||
107 | m_standardBrushSizes.push_back(maxSize); | 107 | m_standardBrushSizes.push_back(maxSize); | ||
108 | } | 108 | } | ||
109 | 109 | | |||
110 | KisCanvas2 * kiscanvas = dynamic_cast<KisCanvas2*>(canvas); | 110 | KisCanvas2 *kiscanvas = dynamic_cast<KisCanvas2*>(canvas); | ||
111 | KisActionManager *actionManager = kiscanvas->viewManager()->actionManager(); | 111 | KisActionManager *actionManager = kiscanvas->viewManager()->actionManager(); | ||
112 | 112 | | |||
113 | // XXX: Perhaps a better place for these? | 113 | // XXX: Perhaps a better place for these? | ||
114 | if (!actionManager->actionByName("increase_brush_size")) { | 114 | if (!actionManager->actionByName("increase_brush_size")) { | ||
115 | KisAction *increaseBrushSize = new KisAction(i18n("Increase Brush Size")); | 115 | KisAction *increaseBrushSize = new KisAction(i18n("Increase Brush Size")); | ||
116 | increaseBrushSize->setShortcut(Qt::Key_BracketRight); | 116 | increaseBrushSize->setShortcut(Qt::Key_BracketRight); | ||
117 | actionManager->addAction("increase_brush_size", increaseBrushSize); | 117 | actionManager->addAction("increase_brush_size", increaseBrushSize); | ||
118 | } | 118 | } | ||
▲ Show 20 Lines • Show All 219 Lines • ▼ Show 20 Line(s) | 337 | case PickBgImage: | |||
338 | useCursor(KisCursor::pickerImageBackgroundCursor()); | 338 | useCursor(KisCursor::pickerImageBackgroundCursor()); | ||
339 | activatePickColor(delayedAction); | 339 | activatePickColor(delayedAction); | ||
340 | break; | 340 | break; | ||
341 | default: | 341 | default: | ||
342 | break; | 342 | break; | ||
343 | }; | 343 | }; | ||
344 | 344 | | |||
345 | repaintDecorations(); | 345 | repaintDecorations(); | ||
346 | | ||||
347 | } | 346 | } | ||
348 | 347 | | |||
349 | bool KisToolPaint::isPickingAction(AlternateAction action) { | 348 | bool KisToolPaint::isPickingAction(AlternateAction action) { | ||
350 | return action == PickFgNode || | 349 | return action == PickFgNode || | ||
351 | action == PickBgNode || | 350 | action == PickBgNode || | ||
352 | action == PickFgImage || | 351 | action == PickFgImage || | ||
353 | action == PickBgImage; | 352 | action == PickBgImage; | ||
354 | } | 353 | } | ||
▲ Show 20 Lines • Show All 140 Lines • ▼ Show 20 Line(s) | 493 | { | |||
495 | KisTool::mouseReleaseEvent(event); | 494 | KisTool::mouseReleaseEvent(event); | ||
496 | if (mode() == KisTool::HOVER_MODE) { | 495 | if (mode() == KisTool::HOVER_MODE) { | ||
497 | requestUpdateOutline(event->point, event); | 496 | requestUpdateOutline(event->point, event); | ||
498 | } | 497 | } | ||
499 | } | 498 | } | ||
500 | 499 | | |||
501 | QWidget * KisToolPaint::createOptionWidget() | 500 | QWidget * KisToolPaint::createOptionWidget() | ||
502 | { | 501 | { | ||
503 | QWidget * optionWidget = new QWidget(); | 502 | QWidget *optionWidget = new QWidget(); | ||
504 | optionWidget->setObjectName(toolId()); | 503 | optionWidget->setObjectName(toolId()); | ||
505 | 504 | | |||
506 | QVBoxLayout* verticalLayout = new QVBoxLayout(optionWidget); | 505 | QVBoxLayout *verticalLayout = new QVBoxLayout(optionWidget); | ||
507 | verticalLayout->setObjectName("KisToolPaint::OptionWidget::VerticalLayout"); | 506 | verticalLayout->setObjectName("KisToolPaint::OptionWidget::VerticalLayout"); | ||
508 | verticalLayout->setContentsMargins(0,0,0,0); | 507 | verticalLayout->setContentsMargins(0,0,0,0); | ||
509 | verticalLayout->setSpacing(5); | 508 | verticalLayout->setSpacing(5); | ||
510 | 509 | | |||
511 | // See https://bugs.kde.org/show_bug.cgi?id=316896 | 510 | // See https://bugs.kde.org/show_bug.cgi?id=316896 | ||
512 | QWidget *specialSpacer = new QWidget(optionWidget); | 511 | QWidget *specialSpacer = new QWidget(optionWidget); | ||
513 | specialSpacer->setObjectName("SpecialSpacer"); | 512 | specialSpacer->setObjectName("SpecialSpacer"); | ||
514 | specialSpacer->setFixedSize(0, 0); | 513 | specialSpacer->setFixedSize(0, 0); | ||
515 | verticalLayout->addWidget(specialSpacer); | 514 | verticalLayout->addWidget(specialSpacer); | ||
516 | verticalLayout->addWidget(specialSpacer); | 515 | verticalLayout->addWidget(specialSpacer); | ||
517 | 516 | | |||
518 | m_optionsWidgetLayout = new QGridLayout(); | 517 | m_optionsWidgetLayout = new QGridLayout(); | ||
519 | m_optionsWidgetLayout->setColumnStretch(1, 1); | 518 | m_optionsWidgetLayout->setColumnStretch(1, 1); | ||
520 | 519 | | |||
521 | verticalLayout->addLayout(m_optionsWidgetLayout); | 520 | verticalLayout->addLayout(m_optionsWidgetLayout); | ||
522 | m_optionsWidgetLayout->setContentsMargins(0,0,0,0); | 521 | m_optionsWidgetLayout->setContentsMargins(0,0,0,0); | ||
523 | m_optionsWidgetLayout->setSpacing(5); | 522 | m_optionsWidgetLayout->setSpacing(5); | ||
524 | 523 | | |||
525 | if (!quickHelp().isEmpty()) { | 524 | if (!quickHelp().isEmpty()) { | ||
526 | QPushButton* push = new QPushButton(KisIconUtils::loadIcon("help-contents"), QString(), optionWidget); | 525 | QPushButton *push = new QPushButton(KisIconUtils::loadIcon("help-contents"), QString(), optionWidget); | ||
527 | connect(push, SIGNAL(clicked()), this, SLOT(slotPopupQuickHelp())); | 526 | connect(push, SIGNAL(clicked()), this, SLOT(slotPopupQuickHelp())); | ||
528 | 527 | | |||
529 | QHBoxLayout* hLayout = new QHBoxLayout(optionWidget); | 528 | QHBoxLayout *hLayout = new QHBoxLayout(optionWidget); | ||
530 | hLayout->addWidget(push); | 529 | hLayout->addWidget(push); | ||
531 | hLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Fixed)); | 530 | hLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Fixed)); | ||
532 | verticalLayout->addLayout(hLayout); | 531 | verticalLayout->addLayout(hLayout); | ||
533 | } | 532 | } | ||
534 | 533 | | |||
535 | return optionWidget; | 534 | return optionWidget; | ||
536 | } | 535 | } | ||
537 | 536 | | |||
▲ Show 20 Lines • Show All 82 Lines • ▼ Show 20 Line(s) | |||||
620 | { | 619 | { | ||
621 | QWhatsThis::showText(QCursor::pos(), quickHelp()); | 620 | QWhatsThis::showText(QCursor::pos(), quickHelp()); | ||
622 | } | 621 | } | ||
623 | 622 | | |||
624 | void KisToolPaint::setupPaintAction(KisRecordedPaintAction* action) | 623 | void KisToolPaint::setupPaintAction(KisRecordedPaintAction* action) | ||
625 | { | 624 | { | ||
626 | KisTool::setupPaintAction(action); | 625 | KisTool::setupPaintAction(action); | ||
627 | action->setOpacity(m_opacity / qreal(255.0)); | 626 | action->setOpacity(m_opacity / qreal(255.0)); | ||
628 | const KoCompositeOp* op = compositeOp(); | 627 | const KoCompositeOp *op = compositeOp(); | ||
629 | if (op) { | 628 | if (op) { | ||
630 | action->setCompositeOp(op->id()); | 629 | action->setCompositeOp(op->id()); | ||
631 | } | 630 | } | ||
632 | } | 631 | } | ||
633 | 632 | | |||
634 | KisToolPaint::NodePaintAbility KisToolPaint::nodePaintAbility() | 633 | KisToolPaint::NodePaintAbility KisToolPaint::nodePaintAbility() | ||
635 | { | 634 | { | ||
636 | KisNodeSP node = currentNode(); | 635 | KisNodeSP node = currentNode(); | ||
▲ Show 20 Lines • Show All 179 Lines • Show Last 20 Lines |