Commit 1cba3bdb authored by Boudewijn Rempt's avatar Boudewijn Rempt

Fix the issues with toolbox and paintstuff bar and duplicating views.

svn path=/trunk/koffice/; revision=461198
parent 26843687
......@@ -59,7 +59,7 @@ Core
* Histogram computations. Make histogram widget zoomable for 16-bit channel/images
* Adjustment layers (Layers that dynamically apply a filter to
the layer they are linked to, these do not store actual
image date, except for an occasional mask) These should work on object
image data, except for an occasional mask) These should work on object
layers (embedded KOFfice objects), too. (BSAR)
* Mask layers (mask layers created from selection -- vv) (BSAR)
* Layer groups or even better: a hierachy of collapsable folders with layers (with d&d)
......
......@@ -310,7 +310,6 @@ bool KisDoc::loadXML(QIODevice *, const QDomDocument& doc)
}
}
}
return true;
}
......@@ -654,6 +653,7 @@ bool KisDoc::completeSaving(KoStore *store)
store -> close();
}
}
// Composite rendition of the entire image for easier kimgio loading
// and to speed up loading the image into Krita: show the composite png first,
// then load the layers.
......@@ -661,6 +661,7 @@ bool KisDoc::completeSaving(KoStore *store)
QPixmap * pix = new QPixmap(m_currentImage -> width(), m_currentImage -> height());
QPainter gc(pix);
//m_currentImage->notify();
m_currentImage -> renderToPainter(0, 0, m_currentImage -> width(), m_currentImage -> height(), gc, m_currentImage -> profile());
gc.end();
QImage composite = pix -> convertToImage();
......@@ -782,12 +783,13 @@ KisImageSP KisDoc::newImage(const QString& name, Q_INT32 width, Q_INT32 height,
KisFillPainter painter;
painter.begin(layer.data());
painter.fillRect(0, 0, width, height, Qt::white, OPACITY_OPAQUE);
painter.end();
painter.begin(layer.data());
painter.fillRect(0, 0, width, height, Qt::white, OPACITY_OPAQUE);
painter.end();
img -> add(layer, -1);
img->notify();
m_currentImage = img;
return img;
}
......@@ -827,13 +829,13 @@ bool KisDoc::slotNewImage()
Q_CHECK_PTR(layer);
KisFillPainter painter;
painter.begin(layer.data());
painter.fillRect(0, 0, dlg.imgWidth(), dlg.imgHeight(), KisColor(c, opacity, cs), opacity);
painter.end();
painter.begin(layer.data());
painter.fillRect(0, 0, dlg.imgWidth(), dlg.imgHeight(), KisColor(c, opacity, cs), opacity);
painter.end();
img -> add(layer, -1);
img -> notify();
m_currentImage = img;
cfg.defImgWidth(dlg.imgWidth());
......
This diff is collapsed.
......@@ -275,10 +275,8 @@ private:
KisImageIface *m_dcop;
QPixmap m_pixmap;
vKisAnnotationSP m_annotations;
bool m_paintInit;
#ifdef __BIG_ENDIAN__
cmsHTRANSFORM m_bigEndianTransform;
#endif
......
......@@ -37,6 +37,7 @@ KisToolManager::KisToolManager(KisCanvasSubject * parent, KisCanvasControllerInt
m_paletteManager = 0;
m_actionCollection = 0;
m_tools_disabled = false;
setup = false;
}
KisToolManager::~KisToolManager()
......@@ -46,6 +47,11 @@ KisToolManager::~KisToolManager()
void KisToolManager::setUp(KisToolBox * toolbox, KoPaletteManager * paletteManager, KActionCollection * actionCollection)
{
if (setup) {
resetToolBox( toolbox );
return;
}
m_toolBox = toolbox;
m_paletteManager = paletteManager;
m_actionCollection = actionCollection;
......@@ -59,8 +65,8 @@ void KisToolManager::setUp(KisToolBox * toolbox, KoPaletteManager * paletteManag
m_inputDeviceToolSetMap[INPUT_DEVICE_ERASER] = KisToolRegistry::instance() -> createTools(actionCollection, m_subject);
m_inputDeviceToolSetMap[INPUT_DEVICE_PUCK] = KisToolRegistry::instance() -> createTools(actionCollection, m_subject);
vKisTool tools = m_inputDeviceToolSetMap[INPUT_DEVICE_MOUSE];
for (vKisTool_it it = tools.begin(); it != tools.end(); ++it) {
m_tools = m_inputDeviceToolSetMap[INPUT_DEVICE_MOUSE];
for (vKisTool_it it = m_tools.begin(); it != m_tools.end(); ++it) {
KisTool * t = *it;
if (!t) continue;
toolbox->registerTool( t->action(), t->toolType(), t->priority() );
......@@ -68,7 +74,40 @@ void KisToolManager::setUp(KisToolBox * toolbox, KoPaletteManager * paletteManag
toolbox->setupTools();
setCurrentTool(findTool("tool_brush"));
KisTool * t = findTool("tool_brush");
kdDebug() << "found " << t << " when looking for brush tool.\n";
setCurrentTool(t);
setup = true;
}
void KisToolManager::youAintGotNoToolBox()
{
m_toolBox = 0;
m_oldTool = currentTool();
}
void KisToolManager::resetToolBox(KisToolBox * toolbox)
{
m_toolBox = toolbox;
m_tools = m_inputDeviceToolSetMap[INPUT_DEVICE_MOUSE];
for (vKisTool_it it = m_tools.begin(); it != m_tools.end(); ++it) {
KisTool * t = *it;
if (!t) continue;
m_toolBox->registerTool( t->action(), t->toolType(), t->priority() );
}
toolbox->setupTools();
if (m_oldTool) {
// restore the old current tool
setCurrentTool(m_oldTool);
m_oldTool = 0;
}
}
void KisToolManager::updateGUI()
......@@ -116,7 +155,9 @@ void KisToolManager::updateGUI()
}
else {
m_oldTool = 0;
setCurrentTool(findTool("tool_brush"));
KisTool * t = findTool("tool_brush");
kdDebug() << "found " << t << " when looking for brush tool.\n";
setCurrentTool(t);
}
}
}
......@@ -151,6 +192,7 @@ void KisToolManager::setCurrentTool(KisTool *tool)
m_subject->notify();
tool->action()->setChecked( true );
tool->action()->activate();
} else {
m_inputDeviceToolMap[m_controller->currentInputDevice()] = 0;
......
......@@ -26,6 +26,7 @@
#include "kis_global.h"
#include "kis_types.h"
class KoView;
class KisCanvasSubject;
class KisView;
class KisTool;
......@@ -50,6 +51,10 @@ public:
public:
void setUp(KisToolBox * toolbox, KoPaletteManager * paletteManager, KActionCollection * collection);
// Called when the toolbox is deleted because the view was made inactive in favour of another view
void youAintGotNoToolBox();
void updateGUI();
virtual void setCurrentTool(KisTool *tool);
......@@ -62,6 +67,10 @@ public:
KisTool *findTool(const QString &toolName, enumInputDevice inputDevice = INPUT_DEVICE_UNKNOWN) const;
void activateCurrentTool();
private:
void resetToolBox(KisToolBox * toolbox);
private:
......@@ -81,8 +90,11 @@ private:
KisTool * m_oldTool;
KisTool * m_dummyTool;
vKisTool m_tools;
bool m_tools_disabled;
bool setup;
};
......
......@@ -60,6 +60,7 @@
#include <kpopupmenu.h>
#include <kdebug.h>
#include <ksharedptr.h>
#include <ktoolbar.h>
// KOffice
#include <koPartSelectAction.h>
......@@ -76,13 +77,13 @@
#include "kis_color.h"
#include "kis_colorspace_registry.h"
#include "kis_config.h"
#include "kis_controlframe.h"
#include "kis_cursor.h"
#include "kis_doc.h"
#include "kis_double_click_event.h"
#include "kis_factory.h"
#include "kis_gradient.h"
#include "kis_guide.h"
#include "kis_imagepipe_brush.h"
#include "kis_layerbox.h"
#include "kis_layer.h"
#include "kis_move_event.h"
......@@ -91,12 +92,14 @@
#include "kis_painter.h"
#include "kis_paintop_registry.h"
#include "kis_part_layer.h"
#include "kis_pattern.h"
#include "kis_profile.h"
#include "kis_rect.h"
#include "kis_resource.h"
#include "kis_ruler.h"
#include "kis_selection.h"
#include "kis_tool.h"
#include "kis_toolbox.h"
#include "kis_tool.h"
#include "kis_tool_manager.h"
#include "kis_transaction.h"
#include "kis_types.h"
......@@ -106,8 +109,19 @@
#include "labels/kis_label_cursor_pos.h"
#include "labels/kis_label_progress.h"
#include "strategy/kis_strategy_move.h"
#include "kis_resource.h"
#include "kis_pattern.h"
#include <kis_resourceserver.h>
#include <kis_resource_mediator.h>
#include "kis_gray_widget.h"
#include "kis_hsv_widget.h"
#include "kis_icon_item.h"
#include "kis_palette_widget.h"
#include "kis_rgb_widget.h"
#include "kis_birdeye_box.h"
#include "kis_color.h"
#include "kis_factory.h"
// Dialog boxes
#include "kis_dlg_progress.h"
......@@ -132,6 +146,7 @@
KisView::KisView(KisDoc *doc, KisUndoAdapter *adapter, QWidget *parent, const char *name)
: super(doc, parent, name)
, KXMLGUIBuilder( shell() )
, m_doc( doc )
, m_canvas( 0 )
, m_selectionManager( 0 )
......@@ -187,16 +202,19 @@ KisView::KisView(KisDoc *doc, KisUndoAdapter *adapter, QWidget *parent, const ch
, m_inputDevice ( INPUT_DEVICE_MOUSE )
{
kdDebug() << "Creating the view\n";
setFocusPolicy( QWidget::StrongFocus );
setClientBuilder( this );
if (!doc -> isReadWrite())
setXMLFile("krita_readonly.rc");
else
setXMLFile("krita.rc");
m_paletteManager = new KoPaletteManager(this, actionCollection(), "Krita palette manager");
m_paletteManager->createPalette( krita::PAINTBOX, i18n("Brushes and stuff"));
m_paletteManager->createPalette( krita::CONTROL_PALETTE , i18n("Control box"));
m_paletteManager->createPalette( krita::CONTROL_PALETTE, i18n("Control box"));
m_paletteManager->createPalette( krita::COLORBOX, i18n("Colors"));
m_paletteManager->createPalette( krita::LAYERBOX, i18n("Layers"));
......@@ -204,10 +222,11 @@ KisView::KisView(KisDoc *doc, KisUndoAdapter *adapter, QWidget *parent, const ch
m_filterManager = new KisFilterManager(this, doc);
m_toolManager = new KisToolManager(getCanvasSubject(), getCanvasController());
createDockers();
m_fg = KisColor(Qt::black);
m_bg = KisColor(Qt::white);
createToolBox();
createLayerBox();
// Now the view plugins will be loaded.
......@@ -229,14 +248,11 @@ KisView::KisView(KisDoc *doc, KisUndoAdapter *adapter, QWidget *parent, const ch
qApp -> installEventFilter(this);
m_tabletEventTimer.start();
// XXX: Remember this
m_toolBox->setBarPos(KToolBar::Left);
m_toolManager->setUp(m_toolBox, m_paletteManager, actionCollection());
m_brushesAndStuffToolBar = new KisControlFrame(mainWindow(), this);
}
KisView::~KisView()
{
KisConfig cfg;
......@@ -247,6 +263,32 @@ KisView::~KisView()
delete m_selectionManager;
delete m_filterManager;
delete m_toolManager;
}
QWidget * KisView::createContainer( QWidget *parent, int index, const QDomElement &element, int &id )
{
if( element.attribute( "name" ) == "ToolBox" )
{
m_toolBox = new KisToolBox(mainWindow(), "toolbox");
m_toolManager->setUp(m_toolBox, m_paletteManager, actionCollection());
return m_toolBox;
}
return KXMLGUIBuilder::createContainer( parent, index, element, id );
}
void KisView::removeContainer( QWidget *container, QWidget *parent, QDomElement &element, int id )
{
if( shell() && container == m_toolBox )
{
delete m_toolBox;
m_toolManager->youAintGotNoToolBox();
}
else {
KXMLGUIBuilder::removeContainer( container, parent, element, id );
}
}
KoPaletteManager * KisView::paletteManager()
......@@ -284,11 +326,6 @@ void KisView::createLayerBox()
}
void KisView::createToolBox()
{
m_toolBox = new KisToolBox(mainWindow(), "toolbox");
m_toolBox->setBarPos(KToolBar::Left);
}
DCOPObject* KisView::dcopObject()
{
......@@ -2730,5 +2767,48 @@ void KisView::setHDRExposure(float exposure)
}
}
void KisView::createDockers()
{
m_birdEyeBox = new KisBirdEyeBox(this);
m_birdEyeBox -> setCaption(i18n("Overview"));
m_paletteManager->addWidget( m_birdEyeBox, "birdeyebox", krita::CONTROL_PALETTE);
connect(m_birdEyeBox, SIGNAL(exposureChanged(float)), this, SLOT(setHDRExposure(float)));
m_hsvwidget = new KisHSVWidget(this, "hsv");
m_hsvwidget -> setCaption(i18n("HSV"));
m_paletteManager->addWidget( m_hsvwidget, "hsvwidget", krita::COLORBOX);
attach(m_hsvwidget);
m_rgbwidget = new KisRGBWidget(this, "rgb");
m_rgbwidget -> setCaption(i18n("RGB"));
m_paletteManager->addWidget( m_rgbwidget, "rgbwidget", krita::COLORBOX);
attach(m_rgbwidget);
m_graywidget = new KisGrayWidget(this, "gray");
m_graywidget -> setCaption(i18n("Gray"));
m_paletteManager->addWidget( m_graywidget, "graywidget", krita::COLORBOX);
attach(m_graywidget);
m_palettewidget = new KisPaletteWidget(this);
m_palettewidget -> setCaption(i18n("Palettes"));
KisResourceServerBase* rServer;
rServer = KisFactory::rServerRegistry() -> get("PaletteServer");
QValueList<KisResource*> resources = rServer->resources();
QValueList<KisResource*>::iterator it;
for ( it = resources.begin(); it != resources.end(); ++it ) {
m_palettewidget -> slotAddPalette( *it );
}
connect(m_palettewidget, SIGNAL(colorSelected(const KisColor &)), this, SLOT(slotSetFGColor(const KisColor &)));
m_paletteManager->addWidget( m_palettewidget, "palettewidget", krita::COLORBOX);
m_paletteManager->showWidget("hsvwidget");
m_paletteManager->showWidget("layerbox");
m_paletteManager->showWidget(krita::TOOL_OPTION_WIDGET);
}
#include "kis_view.moc"
......@@ -28,8 +28,10 @@
#include <qstringlist.h>
#include <list>
#include <koView.h>
#include <kdebug.h>
#include <kxmlguibuilder.h>
#include <koView.h>
#include "kis_canvas_controller.h"
#include "kis_canvas_subject.h"
......@@ -53,40 +55,50 @@ class KAction;
class KActionMenu;
class KPrinter;
class KToggleAction;
class KToolBar;
class KoPartSelectAction;
class KoIconItem;
class KoTabBar;
class KoPaletteManager;
class KisBirdEyeBox;
class KisBrush;
class KisButtonPressEvent;
class KisButtonReleaseEvent;
class KisCanvas;
class KisCanvasObserver;
class KisCompositeOp;
class KisControlFrame;
class KisDoc;
class KisDoubleClickEvent;
class KisFilterManager;
class KisFilterStrategy;
class KisGradient;
class KisGrayWidget;
class KisHSVWidget;
class KisLabelProgress;
class KisLayerBox;
class KisMoveEvent;
class KisPaletteWidget;
class KisPattern;
class KisPoint;
class KisRect;
class KisResource;
class KisResourceMediator;
class KisRGBWidget;
class KisRuler;
class KisSelectionManager;
class KisToolBox;
class KisToolControllerInterface;
class KisToolManager;
class KisUndoAdapter;
class KoPaletteManager;
class KRITA_EXPORT KisView
: public KoView,
public KisCanvasSubject,
public KXMLGUIBuilder,
private KisCanvasControllerInterface
{
......@@ -102,6 +114,11 @@ public:
KisView(KisDoc *doc, KisUndoAdapter *adapter, QWidget *parent = 0, const char *name = 0);
virtual ~KisView();
public: // KXMLGUIBuilder implementation
virtual QWidget *createContainer( QWidget *parent, int index, const QDomElement &element, int &id );
virtual void removeContainer( QWidget *container, QWidget *parent, QDomElement &element, int id );
public: // KoView implementation
virtual bool eventFilter(QObject *o, QEvent *e);
......@@ -179,11 +196,11 @@ public slots:
// image action slots
// XXX: Rename to make all names consistent with slotDoX() pattern
void slotImageProperties();
void imgResizeToActiveLayer();
void imgResizeToActiveLayer();
void resizeCurrentImage(Q_INT32 w, Q_INT32 h, bool cropLayers = false);
void scaleCurrentImage(double sx, double sy, KisFilterStrategy *filterStrategy);
void rotateCurrentImage(double angle);
void shearCurrentImage(double angleX, double angleY);
void rotateCurrentImage(double angle);
void shearCurrentImage(double angleX, double angleY);
// Layer action slots
void rotateLayer180();
......@@ -238,8 +255,6 @@ private:
virtual KoDocument *document() const;
public:
KisCanvasControllerInterface * getCanvasController() { return this; };
......@@ -284,8 +299,8 @@ private:
void layerUpdateGUI(bool enable);
void createLayerBox();
void createToolBox();
void createDockers();
void paintView(const KisRect& rc);
/**
......@@ -437,8 +452,9 @@ private:
KisLabelProgress *m_progress;
KisLayerBox *m_layerBox;
KisToolBox *m_toolBox;
KisToolBox * m_toolBox;
KisControlFrame * m_brushesAndStuffToolBar;
// Current colours, brushes, patterns etc.
KisColor m_fg;
......@@ -462,6 +478,12 @@ private:
// Currently active input device (mouse, stylus, eraser...)
enumInputDevice m_inputDevice;
KisBirdEyeBox * m_birdEyeBox;
KisHSVWidget *m_hsvwidget;
KisRGBWidget *m_rgbwidget;
KisGrayWidget *m_graywidget;
KisPaletteWidget *m_palettewidget;
private:
mutable KisImageSP m_current;
......
......@@ -149,7 +149,17 @@
<Action name="mirrorLayerY"/>
</ToolBar>
<ToolBar name="krita" position="left"><Text>Krita</Text>
<ToolBar name="ToolBox" position="left">
<Text>Toolbox</Text>
</ToolBar>
<ToolBar name="BrushesAndStuff" position="top">
<Text>Brushes and stuff</Text>
<Action name="brushes"/>
<Action name="gradients"/>
<Action name="patterns"/>
<Separator/>
<Action name="paintops"/>
</ToolBar>
</kpartgui>
......@@ -27,7 +27,6 @@ SUBDIRS = cimg \
variations \
performancetest \
$(kjsembed_plugin) \
defaultdockers \
pixelizefilter \
cubismfilter \
filtersgallery \
......
kritarcdir = $(kde_datadir)/krita/kpartplugins
kritarc_DATA = kritadefaultdockers.rc
EXTRA_DIST = $(kritarc_DATA)
INCLUDES = -I$(srcdir)/../../sdk \
-I$(srcdir)/../../core \
-I$(srcdir)/../../core/compositeop \
-I$(srcdir)/../../core/color_strategy \
-I$(srcdir)/../../core/tiles \
-I$(srcdir)/../../core/tool \
-I$(srcdir)/../../core/resources \
-I$(srcdir)/../../ui \
-I$(srcdir)/../../kopalette \
-I$(srcdir)/../../ui/widgets \
$(KOFFICE_INCLUDES) \
-I$(interfacedir) $(KOPAINTER_INCLUDES) $(all_includes)
kritadefaultdockers_la_SOURCES = defaultdockers.cc \
kis_autobrush.cc \
kis_autogradient.cc \
kis_birdeye_box.cc \
kis_brush_chooser.cc \
kis_gradient_chooser.cc \
kis_palette_widget.cc \
kis_pattern_chooser.cc \
kis_resource_mediator.cc \
kis_controlframe.cc \
kobirdeyepanel.cpp \
wdgautobrush.ui \
wdgautogradient.ui \
wdgbirdeye.ui
kde_module_LTLIBRARIES = kritadefaultdockers.la
noinst_HEADERS = defaultdockers.h \
kis_autobrush.h \
kis_autogradient.h \
kis_birdeye_box.h \
kis_brush_chooser.h \
kis_gradient_chooser.h \
kis_palette_widget.h \
kis_pattern_chooser.h \
kis_controlframe.h \
kis_resource_mediator.h
kritadefaultdockers_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN)
kritadefaultdockers_la_LIBADD = ../../libkritacommon.la $(LIB_KOPAINTER) $(LIB_KOFFICECORE)
kritadefaultdockers_la_METASOURCES = AUTO
<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
<kpartgui library="kritadefaultdockers" version="1">
</kpartgui>
......@@ -3,6 +3,8 @@ KDE_OPTIONS = nofinal
INCLUDES = -I$(srcdir)/../core/filters \
-I$(srcdir)/../sdk \
-I$(srcdir)/../core \
-I$(srcdir)/widgets \
-I./widgets \
-I$(srcdir)/../core/resources/ -I$(srcdir)/../core/color_strategy -I$(srcdir)/../core/tiles \
-I$(srcdir)/../core/tool -I$(srcdir)/../core/paintop $(KOFFICE_INCLUDES) $(KOPAINTER_INCLUDES) \
$(all_includes)
......@@ -40,6 +42,19 @@ libkisui_la_SOURCES = \
kis_paintop_box.cc \
kis_toolbox.cc \
kis_color_cup.cc \
kis_autogradient.cc \
kis_gradient_chooser.cc \
kobirdeyepanel.cpp \
kis_birdeye_box.cc \
kis_pattern_chooser.cc \
kis_palette_widget.cc \
kis_brush_chooser.cc \
kis_resource_mediator.cc \
kis_autobrush.cc \
kis_controlframe.cc \
wdgbirdeye.ui \
wdgautogradient.ui \
wdgautobrush.ui \
wdgmatrix.ui \
kis_previewwidgetbase.ui \
wdglayerproperties.ui \
......@@ -80,13 +95,25 @@ noinst_HEADERS = kis_dlg_preferences.h \
kis_previewwidgetbase.h \
kis_previewdialog.h \
kis_color_cup.h \
kis_autogradient.h \
kobirdeyepanel.h \
kis_birdeye_box.h \
kis_pattern_chooser.h \
kis_palette_widget.h \
kis_brush_chooser.h \
kis_resource_mediator.h \
kis_autobrush.h \
kis_gradient_chooser.h \
wdgnewimage.h \
wdgcolorsettings.h \
wdgapplyprofile.h \
wdglayerbox.h \
wdglayerproperties.h \
wdgperformancesettings.h \
wdgpressuresettings.h
wdgpressuresettings.h \
wdgbirdeye.h \
wdgautogradient.h \