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

List:       kde-commits
Subject:    branches/work/~dang/kdegraphics/kolourpaint/tools/selection
From:       Clarence Dang <dang () kde ! org>
Date:       2007-08-05 8:18:34
Message-ID: 1186301914.732101.28987.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 696548 by dang:

More kpAbstractSelectionTool refactoring:

* Change haventBegunDrawUserMessage() to invoke the new "HaventBegunDrawUserMessage" \
                operation
  - This removes yet more duplicate drag-type detection code
  - Yet another win for aspect-oriented programming

* haventBegunDrawUserMessage*()
  - Rename * to match operation type
  - Make them pure virtual and push down implementations into
    kpAbstractImageSelectionTool, since they were already reimplemented
    by kpToolText anyway



 M  +20 -0     image/kpAbstractImageSelectionTool.cpp  
 M  +5 -0      image/kpAbstractImageSelectionTool.h  
 M  +2 -14     kpAbstractSelectionTool.cpp  
 M  +6 -9      kpAbstractSelectionTool.h  
 M  +3 -8      kpAbstractSelectionTool_Create.cpp  
 M  +3 -6      kpAbstractSelectionTool_Move.cpp  
 M  +3 -6      kpAbstractSelectionTool_ResizeScale.cpp  
 M  +16 -10    text/kpToolText.cpp  
 M  +4 -3      text/kpToolText.h  


--- branches/work/~dang/kdegraphics/kolourpaint/tools/selection/image/kpAbstractImageSelectionTool.cpp \
#696547:696548 @@ -58,6 +58,26 @@
 }
 
 
+// protected virtual [kpAbstractSelectionTool]
+QString kpAbstractSelectionTool::haventBegunDrawUserMessageCreate () const
+{
+    // TODO: This is wrong because you can still use RMB.
+    return i18n ("Left drag to create selection.");
+}
+
+// protected virtual [kpAbstractSelectionTool]
+QString kpAbstractSelectionTool::haventBegunDrawUserMessageMove () const
+{
+    return i18n ("Left drag to move selection.");
+}
+
+// protected virtual [kpAbstractSelectionTool]
+QString kpAbstractSelectionTool::haventBegunDrawUserMessageResizeScale () const
+{
+    return i18n ("Left drag to scale selection.");
+}
+
+
 // private
 void kpAbstractImageSelectionTool::pullSelectionFromDocumentIfNeeded ()
 {
--- branches/work/~dang/kdegraphics/kolourpaint/tools/selection/image/kpAbstractImageSelectionTool.h \
#696547:696548 @@ -48,6 +48,11 @@
     virtual QString nameOfCreateCommand () const;
 
 protected:
+    virtual QString haventBegunDrawUserMessageResizeScale () const;
+    virtual QString haventBegunDrawUserMessageMove () const;
+    virtual QString haventBegunDrawUserMessageCreate () const;
+
+protected:
     virtual void pullSelectionFromDocumentIfNeeded ();
 
 
--- branches/work/~dang/kdegraphics/kolourpaint/tools/selection/kpAbstractSelectionTool.cpp \
#696547:696548 @@ -146,7 +146,7 @@
 }
 
 
-// public
+// protected
 QString kpAbstractSelectionTool::haventBegunDrawUserMessage () const
 {
 #if DEBUG_KP_TOOL_SELECTION && 0
@@ -159,19 +159,7 @@
     if (d->cancelledShapeButStillHoldingButtons)
         return i18n ("Let go of all the mouse buttons.");
 
-    kpAbstractSelection *sel = document ()->selection ();
-    if (sel && onSelectionResizeHandle () && !controlOrShiftPressed ())
-    {
-        return /*virtual*/haventBegunDrawUserMessageOnResizeHandle ();
-    }
-    else if (sel && sel->contains (currentPoint ()))
-    {
-        return /*virtual*/haventBegunDrawUserMessageInsideSelection ();
-    }
-    else
-    {
-        return /*virtual*/haventBegunDrawUserMessageOutsideSelection ();
-    }
+    return operation (calculateDragType (), HaventBegunDrawUserMessage);
 }
 
 
--- branches/work/~dang/kdegraphics/kolourpaint/tools/selection/kpAbstractSelectionTool.h \
#696547:696548 @@ -86,14 +86,13 @@
 
 protected:
     // Appropriate one called by haventBegunDrawUserMessage().
-    // Subclasses may wish to reimplement.
-    virtual QString haventBegunDrawUserMessageOnResizeHandle () const;
-    virtual QString haventBegunDrawUserMessageInsideSelection () const;
-    virtual QString haventBegunDrawUserMessageOutsideSelection () const;
+    virtual QString haventBegunDrawUserMessageResizeScale () const = 0;
+    virtual QString haventBegunDrawUserMessageMove () const = 0;
+    virtual QString haventBegunDrawUserMessageCreate () const = 0;
 
-public:
     QString haventBegunDrawUserMessage () const;
 
+public:
     virtual void begin ();
     virtual void end ();
     virtual void reselect ();
@@ -119,10 +118,8 @@
 
         SetCursor,
 
-        // Argument #0 is a boolean stating whether we are called very often
-        // and should guard calls to setUserMessage() with a NOP check, to
-        // avoid unnecessary statusbar updates.
-        SetHaventBegunDrawUserMessage
+        // Returns the message for the given drag mode and operation.
+        HaventBegunDrawUserMessage
     };
 
     QVariant createOperation (Operation op,
--- branches/work/~dang/kdegraphics/kolourpaint/tools/selection/kpAbstractSelectionTool_Create.cpp \
#696547:696548 @@ -74,14 +74,6 @@
 }
 
 
-// protected virtual
-QString kpAbstractSelectionTool::haventBegunDrawUserMessageOutsideSelection () const
-{
-    // TODO: This is wrong because you can still use RMB.
-    return i18n ("Left drag to create selection.");
-}
-
-
 // private
 void kpAbstractSelectionTool::setCursorCreate ()
 {
@@ -219,6 +211,9 @@
 {
     switch (op)
     {
+    case HaventBegunDrawUserMessage:
+        return /*virtual*/haventBegunDrawUserMessageCreate ();
+
     case SetCursor:
         setCursorCreate ();
         break;
--- branches/work/~dang/kdegraphics/kolourpaint/tools/selection/kpAbstractSelectionTool_Move.cpp \
#696547:696548 @@ -94,12 +94,6 @@
 
 
 // protected virtual
-QString kpAbstractSelectionTool::haventBegunDrawUserMessageInsideSelection () const
-{
-    return i18n ("Left drag to move selection.");
-}
-
-// protected virtual
 void kpAbstractSelectionTool::setSelectionBorderForMove ()
 {
     // don't show border while moving
@@ -329,6 +323,9 @@
 {
     switch (op)
     {
+    case HaventBegunDrawUserMessage:
+        return /*virtual*/haventBegunDrawUserMessageMove ();
+
     case SetCursor:
         setCursorMove ();
         break;
--- branches/work/~dang/kdegraphics/kolourpaint/tools/selection/kpAbstractSelectionTool_ResizeScale.cpp \
#696547:696548 @@ -119,12 +119,6 @@
 
 
 // protected virtual
-QString kpAbstractSelectionTool::haventBegunDrawUserMessageOnResizeHandle () const
-{
-    return i18n ("Left drag to scale selection.");
-}
-
-// protected virtual
 void kpAbstractSelectionTool::setSelectionBorderForResizeScale ()
 {
     viewManager ()->setQueueUpdates ();
@@ -371,6 +365,9 @@
 {
     switch (op)
     {
+    case HaventBegunDrawUserMessage:
+        return /*virtual*/haventBegunDrawUserMessageResizeScale ();
+
     case SetCursor:
         setCursorResizeScale ();
         break;
--- branches/work/~dang/kdegraphics/kolourpaint/tools/selection/text/kpToolText.cpp \
#696547:696548 @@ -111,6 +111,9 @@
 {
     switch (op)
     {
+    case HaventBegunDrawUserMessage:
+        return haventBegunDrawUserMessageSelectText ();
+
     case SetCursor:
         setCursorSelectText ();
         break;
@@ -164,28 +167,31 @@
 }
 
 
-// protected virtual [base kpAbstractSelectionTool]
-QString kpToolText::haventBegunDrawUserMessageOnResizeHandle () const
+// protected virtual [kpAbstractSelectionTool]
+QString kpToolText::haventBegunDrawUserMessageResizeScale () const
 {
     return i18n ("Left drag to resize text box.");
 }
 
-// protected virtual [base kpAbstractSelectionTool]
-QString kpToolText::haventBegunDrawUserMessageInsideSelection () const
+// protected virtual [kpAbstractSelectionTool]
+QString kpToolText::haventBegunDrawUserMessageMove () const
 {
-    if (onSelectionToSelectText () && !controlOrShiftPressed ())
-        return i18n ("Left click to change cursor position.");
-    else
-        return i18n ("Left drag to move text box.");
+    return i18n ("Left drag to move text box.");
 }
 
-// protected virtual [base kpAbstractSelectionTool]
-QString kpToolText::haventBegunDrawUserMessageOutsideSelection () const
+// protected virtual [kpAbstractSelectionTool]
+QString kpToolText::haventBegunDrawUserMessageCreate () const
 {
     return i18n ("Left drag to create text box.");
 }
 
+// protected
+QString kpToolText::haventBegunDrawUserMessageSelectText () const
+{
+    return i18n ("Left click to change cursor position.");
+}
 
+
 //
 // Command Handling
 //
--- branches/work/~dang/kdegraphics/kolourpaint/tools/selection/text/kpToolText.h \
#696547:696548 @@ -65,9 +65,10 @@
     bool onSelectionToSelectText () const;
 
 protected:
-    virtual QString haventBegunDrawUserMessageOnResizeHandle () const;
-    virtual QString haventBegunDrawUserMessageInsideSelection () const;
-    virtual QString haventBegunDrawUserMessageOutsideSelection () const;
+    virtual QString haventBegunDrawUserMessageResizeScale () const;
+    virtual QString haventBegunDrawUserMessageMove () const;
+    virtual QString haventBegunDrawUserMessageCreate () const;
+    QString haventBegunDrawUserMessageSelectText () const;
 
 
 //


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

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