[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-kimageshop
Subject:    Patch: Brush Outline with Crosshair
From:       Silvio Heinrich <plassy () web ! de>
Date:       2011-01-04 0:12:39
Message-ID: 4D2265F7.9070100 () web ! de
[Download RAW message or body]

Now i send the separated patches starting with the crosshair thing.
The crosshair is now painted and the invisible cursor is used.

["BrushOutlineCrosshair.patch" (text/x-diff)]

From 85875a0b55dff75b3fb1a7cbfd64e53094448b28 Mon Sep 17 00:00:00 2001
From: Silvio Heinrich <plassy@web.de>
Date: Tue, 28 Dec 2010 17:55:36 +0100
Subject: [PATCH 1/2] Add "Brush Outline and Crosshair" option to the general \
settings.

it will use the crosshair cursor and paints the brush outline simultaneously
this helps seeing the middle of the brush when using large brushes
---
 krita/image/kis_global.h             |    5 ++-
 krita/ui/forms/wdggeneralsettings.ui |    5 ++++
 krita/ui/tool/kis_tool_freehand.cc   |    6 ++--
 krita/ui/tool/kis_tool_paint.cc      |   38 ++++++++++++++++++++++++++++++++-
 4 files changed, 47 insertions(+), 7 deletions(-)

diff --git a/krita/image/kis_global.h b/krita/image/kis_global.h
index e66e806..beb8717 100644
--- a/krita/image/kis_global.h
+++ b/krita/image/kis_global.h
@@ -43,9 +43,10 @@ enum enumCursorStyle {
     CURSOR_STYLE_CROSSHAIR = 1,
     CURSOR_STYLE_POINTER = 2,
     CURSOR_STYLE_OUTLINE = 3,
-    CURSOR_STYLE_NO_CURSOR = 4
+    CURSOR_STYLE_CROSS_OUTLINE = 4,
+    CURSOR_STYLE_NO_CURSOR = 5
 #if defined(HAVE_OPENGL)
-    , CURSOR_STYLE_3D_MODEL = 5
+    , CURSOR_STYLE_3D_MODEL = 6
 #endif
 };
 
diff --git a/krita/ui/forms/wdggeneralsettings.ui \
b/krita/ui/forms/wdggeneralsettings.ui index aea9174..13e0e31 100644
--- a/krita/ui/forms/wdggeneralsettings.ui
+++ b/krita/ui/forms/wdggeneralsettings.ui
@@ -45,6 +45,11 @@
      </item>
      <item>
       <property name="text">
+       <string>Brush Outline and Crosshair</string>
+      </property>
+     </item>
+     <item>
+      <property name="text">
        <string>No Cursor</string>
       </property>
      </item>
diff --git a/krita/ui/tool/kis_tool_freehand.cc b/krita/ui/tool/kis_tool_freehand.cc
index a41e40e..7077bca 100644
--- a/krita/ui/tool/kis_tool_freehand.cc
+++ b/krita/ui/tool/kis_tool_freehand.cc
@@ -134,7 +134,7 @@ void KisToolFreehand::mousePressEvent(KoPointerEvent *e)
     m_outlineDocPoint = e->point;
 
     KisConfig cfg;
-    if(cfg.cursorStyle() == CURSOR_STYLE_OUTLINE) {
+    if(cfg.cursorStyle() == CURSOR_STYLE_OUTLINE || cfg.cursorStyle() == \
CURSOR_STYLE_CROSS_OUTLINE) {  updateOutlineRect();
     }
 
@@ -197,7 +197,7 @@ void KisToolFreehand::mouseMoveEvent(KoPointerEvent *e)
         m_outlineDocPoint = e->point;
 
         KisConfig cfg;
-        if(cfg.cursorStyle() == CURSOR_STYLE_OUTLINE) {
+        if(cfg.cursorStyle() == CURSOR_STYLE_OUTLINE || cfg.cursorStyle() == \
CURSOR_STYLE_CROSS_OUTLINE) {  updateOutlineRect();
         }
 
@@ -571,7 +571,7 @@ void KisToolFreehand::paint(QPainter& gc, const KoViewConverter \
&converter)  
         if(m_explicitShowOutline ||
            mode() == KisTool::GESTURE_MODE ||
-           (cfg.cursorStyle() == CURSOR_STYLE_OUTLINE &&
+           ((cfg.cursorStyle() == CURSOR_STYLE_OUTLINE || cfg.cursorStyle() == \
CURSOR_STYLE_CROSS_OUTLINE) &&  (mode() == HOVER_MODE ||
              (mode() == PAINT_MODE && cfg.showOutlineWhilePainting())))) {
 
diff --git a/krita/ui/tool/kis_tool_paint.cc b/krita/ui/tool/kis_tool_paint.cc
index 7e0ef4a..1121985 100644
--- a/krita/ui/tool/kis_tool_paint.cc
+++ b/krita/ui/tool/kis_tool_paint.cc
@@ -353,10 +353,44 @@ void KisToolPaint::resetCursorStyle()
 {
     KisTool::resetCursorStyle();
     KisConfig cfg;
-    if (cfg.cursorStyle() == CURSOR_STYLE_OUTLINE) {
+    
+    switch(cfg.cursorStyle())
+    {
+    case CURSOR_STYLE_OUTLINE:
+        if (m_supportOutline) {
+            useCursor(KisCursor::blankCursor());
+            break;
+        }
+        
+    case CURSOR_STYLE_CROSS_OUTLINE:
+        if (m_supportOutline) {
+            useCursor(KisCursor::crossCursor());
+            break;
+        }
+        
+#if defined(HAVE_OPENGL)
+    case CURSOR_STYLE_3D_MODEL:
+        if(isCanvasOpenGL()) {
+            if (m_supportOutline) {
+                useCursor(KisCursor::blankCursor());
+                break;
+            }
+        } else {
+            useCursor(KisCursor::arrowCursor());
+            break;
+        }
+#endif
+
+    default:
+        useCursor(cursor());
+        break;
+    }
+/*
+    if (cfg.cursorStyle() == CURSOR_STYLE_OUTLINE || cfg.cursorStyle() == \
CURSOR_STYLE_CROSS_OUTLINE) {  if (m_supportOutline) {
             // do not show cursor, tool will paint outline
             useCursor(KisCursor::blankCursor());
+            useCursor(KisCursor::crossCursor());
         } else {
             // if the tool does not support outline, use tool icon cursor
             useCursor(cursor());
@@ -377,7 +411,7 @@ void KisToolPaint::resetCursorStyle()
         }
     }
 #endif
-
+//*/
 
 }
 
-- 
1.7.1


From 89e165d60cf3ab9b9ea0b431517c7923bde8389c Mon Sep 17 00:00:00 2001
From: Silvio Heinrich <plassy@web.de>
Date: Mon, 3 Jan 2011 23:32:33 +0100
Subject: [PATCH 2/2] In "Brush Outline and Crosshair" mode Paint the crosshair \
instead of using the crosshair cursor

---
 krita/image/kis_global.h           |    1 +
 krita/ui/tool/kis_tool_freehand.cc |   29 +++++++++++++++++++++--
 krita/ui/tool/kis_tool_freehand.h  |    4 ++-
 krita/ui/tool/kis_tool_paint.cc    |   43 +++--------------------------------
 4 files changed, 34 insertions(+), 43 deletions(-)

diff --git a/krita/image/kis_global.h b/krita/image/kis_global.h
index beb8717..e74d7ef 100644
--- a/krita/image/kis_global.h
+++ b/krita/image/kis_global.h
@@ -1,6 +1,7 @@
 /*
  *  Copyright (c) 2000 Matthias Elter <elter@kde.org>
  *  Copyright (c) 2002 Patrick Julien <freak@codepimps.org>
+ *  Copyright (c) 2011 Silvio Heinrich <plassy@web.de>
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
diff --git a/krita/ui/tool/kis_tool_freehand.cc b/krita/ui/tool/kis_tool_freehand.cc
index 7077bca..7079fab 100644
--- a/krita/ui/tool/kis_tool_freehand.cc
+++ b/krita/ui/tool/kis_tool_freehand.cc
@@ -5,6 +5,7 @@
  *  Copyright (c) 2004 Bart Coppens <kde@bartcoppens.be>
  *  Copyright (c) 2007,2008,2010 Cyrille Berger <cberger@cberger.net>
  *  Copyright (c) 2009 Lukáš Tvrdý <lukast.dev@gmail.com>
+ *  Copyright (c) 2011 Silvio Heinrich <plassy@web.de>
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -578,7 +579,8 @@ void KisToolFreehand::paint(QPainter& gc, const KoViewConverter \
&converter)  outlineMode = KisPaintOpSettings::CursorIsOutline;
         }
 
-        QPainterPath path = getOutlinePath(m_outlineDocPoint, outlineMode);
+        bool         withCrossHair = (cfg.cursorStyle() == \
CURSOR_STYLE_CROSS_OUTLINE); +        QPainterPath path          = \
getOutlinePath(m_outlineDocPoint, outlineMode, withCrossHair);  \
paintToolOutline(&gc,pixelToView(path));  }
 }
@@ -593,8 +595,20 @@ QPointF KisToolFreehand::adjustPosition(const QPointF& point, \
const QPointF& str  }
 
 QPainterPath KisToolFreehand::getOutlinePath(const QPointF &documentPos,
-                                             KisPaintOpSettings::OutlineMode \
outlineMode) +                                             \
KisPaintOpSettings::OutlineMode outlineMode, +                                        \
bool withCrossHair)  {
+    static const int off = 1;
+    static const int len = 5;
+    static const int spc = 3;
+    
+    static const QPointF crossHairPts[8] = {
+        QPointF(-off,0), QPointF(-len,0),
+        QPointF(+off,0), QPointF(+len,0),
+        QPointF(0,-off), QPointF(0,-len),
+        QPointF(0,+off), QPointF(0,+len)
+    };
+    
     qreal scale = 1.0;
     qreal rotation = 0;
     if (m_painter && m_painter->paintOp()){
@@ -605,6 +619,15 @@ QPainterPath KisToolFreehand::getOutlinePath(const QPointF \
&documentPos,  QPointF imagePos = currentImage()->documentToPixel(documentPos);
     QPainterPath path = currentPaintOpPreset()->settings()->
         brushOutline(imagePos, outlineMode, scale, rotation);
+    
+    qreal brushExtend = qMax(path.boundingRect().width(), \
path.boundingRect().height()); +    
+    if(brushExtend >= (len+spc)*2 && withCrossHair) {
+        for(int i=0; i<8; i+=2) {
+            path.moveTo(imagePos + crossHairPts[i+0]);
+            path.lineTo(imagePos + crossHairPts[i+1]);
+        }
+    }
 
     return path;
 }
@@ -623,7 +646,7 @@ void KisToolFreehand::decreaseBrushSize()
 
 void KisToolFreehand::updateOutlineRect()
 {
-    QRectF outlinePixelRect = getOutlinePath(m_outlineDocPoint, \
KisPaintOpSettings::CursorIsOutline).boundingRect(); +    QRectF outlinePixelRect = \
getOutlinePath(m_outlineDocPoint, KisPaintOpSettings::CursorIsOutline, \
                false).boundingRect();
     QRectF outlineDocRect = currentImage()->pixelToDocument(outlinePixelRect);
 
     if(!m_oldOutlineRect.isEmpty()) {
diff --git a/krita/ui/tool/kis_tool_freehand.h b/krita/ui/tool/kis_tool_freehand.h
index f03c577..0d820fc 100644
--- a/krita/ui/tool/kis_tool_freehand.h
+++ b/krita/ui/tool/kis_tool_freehand.h
@@ -1,5 +1,6 @@
 /*
  *  Copyright (c) 2003-2008 Boudewijn Rempt <boud@valdyas.org>
+ *  Copyright (c) 2011 Silvio Heinrich <plassy@web.de>
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -107,7 +108,8 @@ private:
 
     void updateOutlineRect();
     QPainterPath getOutlinePath(const QPointF &documentPos,
-                                KisPaintOpSettings::OutlineMode outlineMode);
+                                KisPaintOpSettings::OutlineMode outlineMode,
+                                bool withCrossHair);
 
 private slots:
     void increaseBrushSize();
diff --git a/krita/ui/tool/kis_tool_paint.cc b/krita/ui/tool/kis_tool_paint.cc
index 1121985..0d36d25 100644
--- a/krita/ui/tool/kis_tool_paint.cc
+++ b/krita/ui/tool/kis_tool_paint.cc
@@ -1,5 +1,6 @@
 /*
  *  Copyright (c) 2003-2009 Boudewijn Rempt <boud@valdyas.org>
+ *  Copyright (c) 2011 Silvio Heinrich <plassy@web.de>
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -353,51 +354,17 @@ void KisToolPaint::resetCursorStyle()
 {
     KisTool::resetCursorStyle();
     KisConfig cfg;
-    
-    switch(cfg.cursorStyle())
-    {
-    case CURSOR_STYLE_OUTLINE:
-        if (m_supportOutline) {
-            useCursor(KisCursor::blankCursor());
-            break;
-        }
-        
-    case CURSOR_STYLE_CROSS_OUTLINE:
-        if (m_supportOutline) {
-            useCursor(KisCursor::crossCursor());
-            break;
-        }
-        
-#if defined(HAVE_OPENGL)
-    case CURSOR_STYLE_3D_MODEL:
-        if(isCanvasOpenGL()) {
-            if (m_supportOutline) {
-                useCursor(KisCursor::blankCursor());
-                break;
-            }
-        } else {
-            useCursor(KisCursor::arrowCursor());
-            break;
-        }
-#endif
-
-    default:
-        useCursor(cursor());
-        break;
-    }
-/*
     if (cfg.cursorStyle() == CURSOR_STYLE_OUTLINE || cfg.cursorStyle() == \
CURSOR_STYLE_CROSS_OUTLINE) {  if (m_supportOutline) {
             // do not show cursor, tool will paint outline
             useCursor(KisCursor::blankCursor());
-            useCursor(KisCursor::crossCursor());
         } else {
             // if the tool does not support outline, use tool icon cursor
             useCursor(cursor());
         }
     }
-
-#if defined(HAVE_OPENGL)
+    
+    #if defined(HAVE_OPENGL)
     // TODO: maybe m_support 3D outline would be cooler. So far just freehand tool \
support 3D_MODEL cursor style  if (cfg.cursorStyle() == CURSOR_STYLE_3D_MODEL) {
         if(isCanvasOpenGL()) {
@@ -410,9 +377,7 @@ void KisToolPaint::resetCursorStyle()
             useCursor(KisCursor::arrowCursor());
         }
     }
-#endif
-//*/
-
+    #endif
 }
 
 void KisToolPaint::updateTabletPressureSamples()
-- 
1.7.1



_______________________________________________
kimageshop mailing list
kimageshop@kde.org
https://mail.kde.org/mailman/listinfo/kimageshop


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic