Commit ae734675 authored by Vera Lukman's avatar Vera Lukman

The bug in the pop up palette is now fixed! Clicking outside the pop up...

The bug in the pop up palette is now fixed! Clicking outside the pop up palette to hide it no longer stores the colour to the recently used list.

svn path=/trunk/koffice/; revision=1086827
parent 0edea510
......@@ -68,7 +68,7 @@ KAboutData * newKritaAboutData()
aboutData->addAuthor(ki18n("Toshitaka Fujioka"), KLocalizedString(), "fujioka@kde.org");
aboutData->addAuthor(ki18n("Thomas Zander"), KLocalizedString(), "zander@kde.org");
aboutData->addAuthor(ki18n("Tom Burdick"), KLocalizedString(), "tburdi1@uic.edu");
aboutData->addAuthor(ki18n("Vera Lukman"), KLocalizedString(), "shichan.karachu@gmail.com");
aboutData->addAuthor(ki18n("Vera Lukman"), KLocalizedString(), "shicmap@gmail.com");
aboutData->addAuthor(ki18n("Sander Koning"), KLocalizedString(), "sanderkoning@kde.nl");
aboutData->addAuthor(ki18n("Andreas Lundin"), KLocalizedString(), "adde@update.uu.se");
return aboutData;
......
......@@ -26,6 +26,7 @@
#include <QImage>
#include <QPainter>
#include <QDebug>
#include <KoCanvasBase.h>
#include <KoID.h>
......@@ -51,8 +52,8 @@
KisCanvasResourceProvider::KisCanvasResourceProvider(KisView2 * view)
: m_view(view)
{
//WARNING: this doesn't seem to be true for the first color that is selected automatically by the system
m_fGChanged = true;
m_enablefGChange = true;
}
KisCanvasResourceProvider::~KisCanvasResourceProvider()
......@@ -329,10 +330,18 @@ const KoColorProfile *KisCanvasResourceProvider::getScreenProfile(int screen)
void KisCanvasResourceProvider::slotPainting()
{
if (m_fGChanged) {
qDebug() << "[KisCanvasResourceProvider::slotPainting] m_fGChanged: " << m_fGChanged << " | m_enablefGChange: " << m_enablefGChange;
if (m_fGChanged && m_enablefGChange) {
emit sigFGColorUsed(fgColor());
m_fGChanged = false;
}
m_enablefGChange = true;
}
void KisCanvasResourceProvider::slotEnableChangeColor(bool b)
{
m_enablefGChange = b;
qDebug() << "[KisCanvasResourceProvider::slotEnableChangeColor] m_enablefGChange: " << m_enablefGChange;
}
#include "kis_canvas_resource_provider.moc"
......@@ -104,6 +104,7 @@ public slots:
void slotNodeActivated(const KisNodeSP node);
void slotGeneratorConfigurationActivated(KisFilterConfiguration * generatorConfiguration);
void slotPainting();
void slotEnableChangeColor(bool b);
/**
* Set the image size in pixels. The resource provider will store
......@@ -135,6 +136,13 @@ private:
const KoColorProfile * m_displayProfile;
bool m_fGChanged;
// This is a flag to handle a bug:
// If pop up palette is visible and a new colour is selected, the new colour
// will be added when the user clicks on the canvas to hide the palette
// In general, we want to be able to store recent color if the pop up palette
// is not visible
bool m_enablefGChange;
};
#endif
/* This file is part of the KDE project
Copyright 2009 Vera Lukman <shichan.karachu@gmail.com>
Copyright 2009 Vera Lukman <shicmap@gmail.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
......
/* This file is part of the KDE project
Copyright 2009 Vera Lukman <shichan.karachu@gmail.com>
Copyright 2009 Vera Lukman <shicmap@gmail.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
......
/* This file is part of the KDE project
Copyright 2009 Vera Lukman <shichan.karachu@gmail.com>
Copyright 2009 Vera Lukman <shicmap@gmail.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
......
/* This file is part of the KDE project
Copyright 2009 Vera Lukman <shichan.karachu@gmail.com>
Copyright 2009 Vera Lukman <shicmap@gmail.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
......
/* This file is part of the KDE project
Copyright 2009 Vera Lukman <shichan.karachu@gmail.com>
Copyright 2009 Vera Lukman <shicmap@gmail.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
......
/* This file is part of the KDE project
Copyright 2009 Vera Lukman <shichan.karachu@gmail.com>
Copyright 2009 Vera Lukman <shicmap@gmail.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
......@@ -15,9 +15,6 @@
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
Known issues:
1. calculateFavoriteBrush() sometimes does not return the right value. Find
a better formula!
*/
#include "kis_popup_palette.h"
......@@ -39,7 +36,8 @@ KisPopupPalette::KisPopupPalette(KoFavoriteResourceManager* manager, QWidget *pa
connect(this, SIGNAL(sigChangeActivePaintop(int)), m_resourceManager, SLOT(slotChangeActivePaintop(int)));
connect(this, SIGNAL(sigSelectNewColor()), this, SLOT(slotSelectNewColor()));
connect(this, SIGNAL(sigUpdateRecentColor(int)), m_resourceManager, SLOT(slotUpdateRecentColor(int)));
connect(this, SIGNAL(sigAddRecentColor(KoColor)), m_resourceManager, SLOT(slotAddRecentColor(KoColor)));
connect(this, SIGNAL(sigAddRecentColor(KoColor)), m_resourceManager, SLOT(slotAddRecentColorNotify(KoColor)));
connect(this, SIGNAL(sigEnableChangeColor(bool)), m_resourceManager, SIGNAL(sigEnableChangeColor(bool)));
colorFoo=0;
setMouseTracking(true);
......@@ -151,7 +149,16 @@ void KisPopupPalette::showPopupPalette (const QPoint &p)
move(pointPalette);
}
setVisible(!isVisible());
showPopupPalette(!isVisible());
}
void KisPopupPalette::showPopupPalette(bool b)
{
// we want to enable change color when the widget is not visible
if (b)
emit sigEnableChangeColor(!b);
setVisible(b);
}
QSize KisPopupPalette::sizeHint() const
......@@ -200,7 +207,7 @@ void KisPopupPalette::paintEvent(QPaintEvent*)
QPixmap pixmap(pixmaps.at(pos));
QPointF pixmapOffset(pixmap.width()/2, pixmap.height()/2);
float angle = pos*PI()*2.0/pixmaps.size();
float angle = pos*M_PI*2.0/pixmaps.size();
QPointF pointTemp(brushRadius()*sin(angle),brushRadius()*cos(angle));
painter.drawPixmap(QPoint(pointTemp.x()-pixmapOffset.x(), pointTemp.y()-pixmapOffset.y()), pixmap);
}
......@@ -292,8 +299,8 @@ QPainterPath KisPopupPalette::drawDonutPathFull(int x, int y, int inner_radius,
QPainterPath KisPopupPalette::drawDonutPathAngle(int inner_radius, int outer_radius, int limit)
{
QPainterPath path;
path.moveTo(-1*outer_radius * sin(PI()/limit),
outer_radius * cos(PI()/limit));
path.moveTo(-1*outer_radius * sin(M_PI/limit),
outer_radius * cos(M_PI/limit));
path.arcTo(-1*outer_radius, -1*outer_radius, 2*outer_radius,2*outer_radius,-90.0 - 180.0/limit,
360.0/limit);
path.arcTo(-1*inner_radius, -1*inner_radius, 2*inner_radius,2*inner_radius,-90.0 + 180.0/limit,
......@@ -396,7 +403,8 @@ void KisPopupPalette::mouseReleaseEvent ( QMouseEvent * event )
}
else if (event->button() == Qt::MidButton)
{
setVisible(false);
showPopupPalette(false);
emit sigEnableChangeColor(true);
}
}
......@@ -407,13 +415,13 @@ int KisPopupPalette::calculateIndex(QPointF point, int n)
point.setY(point.y() - height()/2);
//rotate
float smallerAngle = PI()/2 + PI()/n - atan2 ( point.y(), point.x() );
float smallerAngle = M_PI/2 + M_PI/n - atan2 ( point.y(), point.x() );
float radius = sqrt ( point.x()*point.x() + point.y()*point.y() );
point.setX( radius * cos(smallerAngle) );
point.setY( radius * sin(smallerAngle) );
//calculate brush index
int pos = floor (acos(point.x()/radius) * n/ (2 * PI()));
int pos = floor (acos(point.x()/radius) * n/ (2 * M_PI));
if (point.y() < 0) pos = n - pos - 1;
return pos;
......@@ -424,7 +432,7 @@ bool KisPopupPalette::isPointInPixmap(QPointF& point, int pos)
QPixmap pixmap(m_resourceManager->favoriteBrushPixmap(pos));
//calculating if the point is inside the pixmap
float angle = pos*PI()*2.0/m_resourceManager->favoriteBrushesTotal();
float angle = pos*M_PI*2.0/m_resourceManager->favoriteBrushesTotal();
QPainterPath path;
path.addRect(brushRadius()*sin(angle)-pixmap.width()/2+width()/2,
brushRadius()*cos(angle)-pixmap.height()/2+height()/2,
......
/* This file is part of the KDE project
Copyright 2009 Vera Lukman <shichan.karachu@gmail.com>
Copyright 2009 Vera Lukman <shicmap@gmail.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
......@@ -43,6 +43,7 @@ public:
QSize sizeHint() const;
void showPopupPalette (const QPoint&);
void showPopupPalette (bool b);
//functions to set up selectedBrush
void setSelectedBrush( int x );
......@@ -71,13 +72,14 @@ protected:
private:
// void setVisible(bool b);
QPainterPath drawDonutPathFull(int, int, int, int);
QPainterPath drawDonutPathAngle(int, int, int);
bool isPointInPixmap(QPointF&, int pos);
//inline functions
inline int brushRadius(){ return 50; }
inline float PI(){ return 3.14159265; }
inline float brushInnerRadius(){ return width()/2 - 60; }
inline float brushOuterRadius(){ return width()/2 - 40; }
inline float colorInnerRadius(){ return width()/2 - 30; }
......@@ -96,6 +98,7 @@ signals:
void sigChangeActivePaintop(int);
void sigUpdateRecentColor(int);
void sigAddRecentColor(KoColor);
void sigEnableChangeColor(bool);
private slots:
void slotSelectNewColor();
......
......@@ -771,6 +771,7 @@ void KisView2::setFavoriteResourceManager(KisPaintopBox* paintopBox)
connect(this, SIGNAL(favoritePaletteCalled(const QPoint&)), favoriteResourceManager(), SLOT(slotShowPopupPalette(const QPoint&)));
connect(resourceProvider(), SIGNAL(sigFGColorUsed(KoColor)), favoriteResourceManager(), SLOT(slotAddRecentColor(KoColor)));
connect(favoriteResourceManager(), SIGNAL(sigSetFGColor(KoColor)), resourceProvider(), SLOT(slotSetFGColor(KoColor)));
connect(favoriteResourceManager(), SIGNAL(sigEnableChangeColor(bool)), resourceProvider(), SLOT(slotEnableChangeColor(bool)));
}
......
/* This file is part of the KDE project
Copyright 2009 Vera Lukman <shichan.karachu@gmail.com>
Copyright 2009 Vera Lukman <shicmap@gmail.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
......@@ -62,7 +62,7 @@ KoFavoriteResourceManager::KoFavoriteResourceManager(KisPaintopBox *paintopBox,
}
m_popupPalette = new KisPopupPalette(this, popupParent);
m_popupPalette->setVisible(false);
m_popupPalette->showPopupPalette(false);
m_colorList = new KisColorDataList();
}
......@@ -139,7 +139,7 @@ void KoFavoriteResourceManager::slotChangeActivePaintop(int pos)
m_paintopBox->setCurrentPaintop(m_favoriteBrushesList.at(pos)->paintOp());
if (m_popupPalette)
m_popupPalette->setVisible(false); //automatically close the palette after a button is clicked.
m_popupPalette->showPopupPalette(false); //automatically close the palette after a button is clicked.
}
bool KoFavoriteResourceManager::isPopupPaletteVisible()
......@@ -260,7 +260,7 @@ void KoFavoriteResourceManager::slotUpdateRecentColor(int pos)
addRecentColorUpdate(pos);
if (m_popupPalette)
m_popupPalette->setVisible(false); //automatically close the palette after a button is clicked.
m_popupPalette->showPopupPalette(false); //automatically close the palette after a button is clicked.
}
void KoFavoriteResourceManager::slotAddRecentColor(KoColor color)
......@@ -268,6 +268,14 @@ void KoFavoriteResourceManager::slotAddRecentColor(KoColor color)
addRecentColor(color);
}
void KoFavoriteResourceManager::slotAddRecentColorNotify(KoColor color)
{
addRecentColor(color);
//user can select color from the pop up palette, so it is necessary to send a signal
emit sigSetFGColor(color);
}
void KoFavoriteResourceManager::addRecentColorNew(const KoColor& color)
{
m_colorList->appendNew(color);
......@@ -303,8 +311,6 @@ void KoFavoriteResourceManager::addRecentColor(const KoColor& color)
m_popupPalette->update();
}
//later user can select color from the pop up palette, so it is necessary to send a signal
emit sigSetFGColor(color);
printColors();
}
......
/* This file is part of the KDE project
Copyright 2009 Vera Lukman <shichan.karachu@gmail.com>
Copyright 2009 Vera Lukman <shicmap@gmail.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
......@@ -78,6 +78,13 @@ public:
signals:
void sigSetFGColor(const KoColor& c);
// This is a flag to handle a bug:
// If pop up palette is visible and a new colour is selected, the new colour
// will be added when the user clicks on the canvas to hide the palette
// In general, we want to be able to store recent color if the pop up palette
// is not visible
void sigEnableChangeColor(bool b);
public slots:
void slotChangePaintopLabel(KisPaintOpPresetSP paintop);
......@@ -87,9 +94,12 @@ public slots:
/*update the priority of a colour in m_colorList, used only by m_popupPalette*/
void slotUpdateRecentColor(int);
/*add a colour to m_colorList, used by KisCanvasResourceProvider and m_popupPalette (later)*/
/*add a colour to m_colorList, used by KisCanvasResourceProvider*/
void slotAddRecentColor(KoColor);
/*add a colour to m_colorList, used by m_popupPalette. It notifies the system to change FGColor*/
void slotAddRecentColorNotify(KoColor);
private:
KisPaletteManager *m_favoriteBrushManager;
KisPopupPalette* m_popupPalette;
......@@ -108,6 +118,7 @@ private:
void addRecentColorNew(const KoColor& color);
void addRecentColorUpdate(int guipos);
void addRecentColor(const KoColor& color);
};
#endif // KIS_FAVORITE_BRUSH_DATA_H
......@@ -151,6 +151,7 @@ void KisToolPaint::mouseReleaseEvent(KoPointerEvent *e)
// }
} else if (e->button() == Qt::LeftButton) {
// if (canvas2->view()->favoriteResourceManager()->isPopupPaletteVisible()) return;
//TODO: There is a bug here. If pop up palette is visible and a new colour is selected,
//the new colour will be added when the user clicks on the canvas to hide the palette
emit sigPainting();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment