Merge
[yamf.git] / examples / tools / mainwindow.cpp
blob0ce2984efa589a6272d8ed259f3aa41c21f88849
1 /***************************************************************************
2 * Copyright (C) 2007 David Cuadrado *
3 * krawek@gmail.com *
4 * *
5 * This library is free software; you can redistribute it and/or *
6 * modify it under the terms of the GNU Lesser General Public *
7 * License as published by the Free Software Foundation; either *
8 * version 2.1 of the License, or (at your option) any later version. *
9 * *
10 * This library is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
13 * Lesser General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU Lesser General Public *
16 * License along with this library; if not, write to the Free Software *
17 * Foundation, Inc., *
18 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
19 ***************************************************************************/
21 #include "mainwindow.h"
23 #include <common/yamf.h>
25 #include <drawing/paintarea.h>
26 #include <drawing/photogram.h>
27 #include <drawing/brushmanager.h>
29 #include <dcore/algorithm.h>
30 #include <dcore/debug.h>
32 #include <dgui/iconloader.h>
34 #include <model/project.h>
35 #include <model/scene.h>
36 #include <model/layer.h>
37 #include <model/audiolayer.h>
38 #include <model/frame.h>
39 #include <model/object.h>
41 #include <tools/brush/brush.h>
42 #include <tools/selection/select.h>
43 #include <tools/polyline/polyline.h>
46 #include <model/command/manager.h>
47 #include <model/command/insertscene.h>
48 #include <model/command/removescene.h>
50 #include <item/proxy.h>
51 #include <item/rect.h>
53 #include <gui/pen.h>
54 #include <gui/tools.h>
56 #include <QDockWidget>
57 #include <QGridLayout>
58 #include <QDir>
59 #include <QListWidgetItem>
61 MainWindow::MainWindow(QWidget *parent)
62 : QMainWindow(parent)
64 YAMF::initialize();
66 YAMF::Model::Project *project = new YAMF::Model::Project(this);
67 YAMF::Model::Scene *scn = project->createScene();
68 YAMF::Model::Layer *lyr = scn->createLayer();
69 YAMF::Model::Frame *frm = lyr->createFrame();
71 YAMF::Item::Proxy *proxy = new YAMF::Item::Proxy;
72 YAMF::Item::Rect *rect = new YAMF::Item::Rect;
73 proxy->setItem( rect );
75 rect->setFlags(QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemIsMovable);
76 rect->setRect(QRect(10,10, 100,100));
77 rect->setBrush(Qt::red);
79 frm->addItem(proxy);
81 m_view = new YAMF::Drawing::View(project);
82 YAMF::Drawing::PaintArea *paintarea = m_view->paintArea();
83 paintarea->brushManager()->setPen(QPen(Qt::red));
85 paintarea->setCurrentFrame(0, 0, 0);
87 setCentralWidget(m_view);
89 addToolBar(Qt::TopToolBarArea, paintarea->toolsConfigBar());
90 addToolBar(Qt::TopToolBarArea, paintarea->effectsConfigBar());
92 addToolBar(Qt::LeftToolBarArea, new YAMF::Gui::Tools(paintarea, this));
93 addToolBar(Qt::BottomToolBarArea, new YAMF::Gui::ToolsWidget(paintarea, this));
96 QDockWidget *dock = new QDockWidget;
97 YAMF::Gui::Pen *setupPenWidget = new YAMF::Gui::Pen;
98 connect(setupPenWidget, SIGNAL(penChanged(const QPen&)), m_view->paintArea()->brushManager(), SLOT(setPen(const QPen &)));
100 dock->setWidget(setupPenWidget);
102 addDockWidget(Qt::LeftDockWidgetArea, dock);
107 MainWindow::~MainWindow()