[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdegraphics/kolourpaint (silent)
From: Clarence Dang <dang () kde ! org>
Date: 2006-08-27 1:49:31
Message-ID: 1156643371.941010.30241.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 577559 by dang:
SVN_SILENT style, comments
M +3 -1 tools/kptoolflowbase.cpp
M +27 -31 widgets/kptoolwidgetbrush.cpp
M +6 -6 widgets/kptoolwidgetbrush.h
M +16 -12 widgets/kptoolwidgeterasersize.cpp
M +4 -3 widgets/kptoolwidgeterasersize.h
--- trunk/KDE/kdegraphics/kolourpaint/tools/kptoolflowbase.cpp #577558:577559
@@ -78,6 +78,8 @@
kpToolWidgetBrush::DrawPackage brushDrawPackageForMouseButton [2];
kpToolWidgetEraserSize::DrawPackage eraserDrawPackageForMouseButton [2];
+ // Each element points to one of the above (both elements from the same
+ // array).
void *drawPackageForMouseButton [2];
int brushWidth, brushHeight;
@@ -521,7 +523,7 @@
return d->currentCommand;
}
-// protected
+// protected slot
void kpToolFlowBase::updateBrushAndCursor ()
{
#if DEBUG_KP_TOOL_FLOW_BASE && 1
--- trunk/KDE/kdegraphics/kolourpaint/widgets/kptoolwidgetbrush.cpp #577558:577559
@@ -119,34 +119,31 @@
{
for (int i = 0; i < BRUSH_SIZE_NUM_COLS; i++)
{
- int w = (width () - 2/*margin*/ - 2/*spacing*/) / BRUSH_SIZE_NUM_COLS;
- int h = (height () - 2/*margin*/ - 3/*spacing*/) / BRUSH_SIZE_NUM_ROWS;
- QPixmap previewPixmap ((w <= 0 ? width () : w),
- (h <= 0 ? height () : h));
-
const int s = ::BrushSizes [shape][i];
- Q_ASSERT (s <= previewPixmap.width ());
- Q_ASSERT (s <= previewPixmap.height ());
- const QRect rect = QRect ((previewPixmap.width () - s) / 2,
- (previewPixmap.height () - s) / 2,
- s,
- s);
- #if DEBUG_KP_TOOL_WIDGET_BRUSH
- kDebug () << "kpToolWidgetBrush::kpToolWidgetBrush() rect=" << rect << endl;
- #endif
+ const int w = (width () - 2/*margin*/ - 2/*spacing*/)
+ / BRUSH_SIZE_NUM_COLS;
+ const int h = (height () - 2/*margin*/ - 3/*spacing*/)
+ / BRUSH_SIZE_NUM_ROWS;
+ Q_ASSERT (w > 0 && h > 0);
+ Q_ASSERT (w >= s && h >= s);
+ QPixmap previewPixmap (w, h);
kpPainter::fillRect (&previewPixmap,
0, 0, previewPixmap.width (), previewPixmap.height (),
kpColor::transparent);
DrawPackage pack = drawFunctionDataForRowCol (kpColor::black, shape, i);
- ::Draw (&previewPixmap, rect.topLeft (), &pack);
+ ::Draw (&previewPixmap,
+ QPoint ((previewPixmap.width () - s) / 2,
+ (previewPixmap.height () - s) / 2),
+ &pack);
+
addOption (previewPixmap, brushName (shape, i)/*tooltip*/);
}
-
+
startNewOptionRow ();
}
@@ -195,6 +192,20 @@
// public
+int kpToolWidgetBrush::brushSize () const
+{
+ return ::BrushSizes [selectedRow ()][selectedCol ()];
+}
+
+// public
+bool kpToolWidgetBrush::brushIsDiagonalLine () const
+{
+ // sync: <brushes>
+ return (selectedRow () >= 2);
+}
+
+
+// public
kpTempPixmap::UserFunctionType kpToolWidgetBrush::drawFunction () const
{
return &::Draw;
@@ -224,21 +235,6 @@
}
-// public
-int kpToolWidgetBrush::brushSize () const
-{
- return ::BrushSizes [selectedRow ()][selectedCol ()];
-}
-
-
-// public
-bool kpToolWidgetBrush::brushIsDiagonalLine () const
-{
- // sync: <brushes>
- return (selectedRow () >= 2);
-}
-
-
// protected slot virtual [base kpToolWidgetBase]
bool kpToolWidgetBrush::setSelected (int row, int col, bool saveAsDefault)
{
--- trunk/KDE/kdegraphics/kolourpaint/widgets/kptoolwidgetbrush.h #577558:577559
@@ -47,8 +47,11 @@
private:
QString brushName (int shape, int whichSize) const;
-
+
public:
+ int brushSize () const;
+ bool brushIsDiagonalLine () const;
+
struct DrawPackage
{
int row;
@@ -57,19 +60,16 @@
};
// Call the function returned by <drawFunction> to render the current
- // brush onto the document, in <color>. Pass the pointer returned by
+ // brush onto an image/document, in <color>. Pass the pointer returned by
// <drawFunctionData> to it.
//
// TODO: change function + data -> object
kpTempPixmap::UserFunctionType drawFunction () const;
+
static DrawPackage drawFunctionDataForRowCol (const kpColor &color,
int row, int col);
DrawPackage drawFunctionData (const kpColor &color) const;
-
- int brushSize () const;
- bool brushIsDiagonalLine () const;
-
signals:
void brushChanged ();
--- trunk/KDE/kdegraphics/kolourpaint/widgets/kptoolwidgeterasersize.cpp #577558:577559
@@ -43,8 +43,9 @@
#include <kptool.h>
-static int eraserSizes [] = {2, 3, 5, 9, 17, 29};
-static const int numEraserSizes = int (sizeof (eraserSizes) / sizeof (eraserSizes [0]));
+static int EraserSizes [] = {2, 3, 5, 9, 17, 29};
+static const int NumEraserSizes =
+ int (sizeof (::EraserSizes) / sizeof (::EraserSizes [0]));
static void Draw (QPixmap *destPixmap, const QPoint &topLeft, void *userData)
@@ -52,7 +53,7 @@
kpToolWidgetEraserSize::DrawPackage *pack =
static_cast <kpToolWidgetEraserSize::DrawPackage *> (userData);
- const int size = ::eraserSizes [pack->selected];
+ const int size = ::EraserSizes [pack->selected];
kpPainter::fillRect (destPixmap,
topLeft.x (), topLeft.y (), size, size,
@@ -67,7 +68,7 @@
kpToolWidgetEraserSize::DrawPackage *pack =
static_cast <kpToolWidgetEraserSize::DrawPackage *> (userData);
- const int size = ::eraserSizes [pack->selected];
+ const int size = ::EraserSizes [pack->selected];
// Would 1-pixel border on all sides completely cover the color of the
// eraser?
@@ -86,12 +87,12 @@
{
setInvertSelectedPixmap ();
- for (int i = 0; i < numEraserSizes; i++)
+ for (int i = 0; i < ::NumEraserSizes; i++)
{
if (i == 3 || i == 5)
startNewOptionRow ();
- const int s = eraserSizes [i];
+ const int s = ::EraserSizes [i];
QPixmap previewPixmap (s, s);
@@ -124,6 +125,13 @@
// public
+int kpToolWidgetEraserSize::eraserSize () const
+{
+ return ::EraserSizes [selected ()];
+}
+
+
+// public
kpTempPixmap::UserFunctionType kpToolWidgetEraserSize::drawFunction () const
{
return &::Draw;
@@ -135,6 +143,7 @@
return &::DrawCursor;
}
+
// public static
kpToolWidgetEraserSize::DrawPackage kpToolWidgetEraserSize::drawFunctionDataForSelected (
const kpColor &color, int selectedIndex)
@@ -147,6 +156,7 @@
return pack;
}
+// public
kpToolWidgetEraserSize::DrawPackage kpToolWidgetEraserSize::drawFunctionData (
const kpColor &color) const
{
@@ -154,12 +164,6 @@
}
-int kpToolWidgetEraserSize::eraserSize () const
-{
- return eraserSizes [selected ()];
-}
-
-
// protected slot virtual [base kpToolWidgetBase]
bool kpToolWidgetEraserSize::setSelected (int row, int col, bool saveAsDefault)
{
--- trunk/KDE/kdegraphics/kolourpaint/widgets/kptoolwidgeterasersize.h #577558:577559
@@ -48,6 +48,8 @@
kpToolWidgetEraserSize (QWidget *parent, const QString &name);
virtual ~kpToolWidgetEraserSize ();
+ int eraserSize () const;
+
struct DrawPackage
{
int selected;
@@ -55,7 +57,7 @@
};
// Call the function returned by <drawFunction> to render the current
- // brush onto the document, in <color>. Pass the pointer returned by
+ // brush onto an image/document, in <color>. Pass the pointer returned by
// <drawFunctionData> to it.
//
// <drawCursorFunction> is to same as <drawFunction> but adds a black
@@ -64,12 +66,11 @@
// TODO: change function + data -> object
kpTempPixmap::UserFunctionType drawFunction () const;
kpTempPixmap::UserFunctionType drawCursorFunction () const;
+
static DrawPackage drawFunctionDataForSelected (const kpColor &color,
int selectedIndex);
DrawPackage drawFunctionData (const kpColor &color) const;
- int eraserSize () const;
-
signals:
void eraserSizeChanged (int size);
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic