Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2012-02-18 18:12:31 +0000
committerStijn Buys <ingar@osirion.org>2012-02-18 18:12:31 +0000
commit89c0d325d049666a07994c1a53461b8d7bb0d887 (patch)
treef2dce5bd5ef81b3e4b6e6fc02ac29040931867d4 /src
parent141ad1e5ae7588906d8474dfdead5762370ce222 (diff)
Added editor window with side bar.
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am8
-rw-r--r--src/editorwindow.cc30
-rw-r--r--src/editorwindow.h39
-rw-r--r--src/mainwindow.cc10
-rw-r--r--src/mapwidget.cc14
-rw-r--r--src/mapwidget.h6
-rw-r--r--src/sidebar.cc41
-rw-r--r--src/sidebar.h31
8 files changed, 166 insertions, 13 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 7486902..e492b45 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -4,14 +4,18 @@ bin_PROGRAMS = editor
# Remember to include the name of the resource file with the .cpp extension.
editor_SOURCES = \
editor.cc \
+ editorwindow.cc \
mainwindow.cc \
- mapwidget.cc
+ mapwidget.cc \
+ sidebar.cc
# You have one .h file, it's called editor.h. Therefore, here I list
# its mocced name, moc_editor.cpp.
nodist_editor_SOURCES = \
+ moc_editorwindow.cc \
moc_mainwindow.cc \
- moc_mapwidget.cc
+ moc_mapwidget.cc \
+ moc_sidebar.cc
# This rule lets GNU make create any moc_*.cpp from the equivalent *.h
moc_%.cc: %.h
diff --git a/src/editorwindow.cc b/src/editorwindow.cc
new file mode 100644
index 0000000..6a72654
--- /dev/null
+++ b/src/editorwindow.cc
@@ -0,0 +1,30 @@
+/*
+ editorwindow.h
+ This file is part of the Project::OSiRiON zone editor
+ and is distributed under the terms and conditions of
+ the GNU General Public License version 2
+*/
+
+#include "editorwindow.h"
+#include "mapwidget.h"
+#include "sidebar.h"
+
+namespace editor
+{
+
+EditorWindow::EditorWindow(QWidget *parent) : QWidget(parent)
+{
+ editorwindow_mapwidget = new MapWidget(this);
+ editorwindow_sidebar = new SideBar(this);
+}
+
+void EditorWindow::resizeEvent (QResizeEvent *event)
+{
+ editorwindow_sidebar->resize(256, height());
+ editorwindow_mapwidget->setGeometry(
+ editorwindow_sidebar->width(), 0,
+ width() - editorwindow_sidebar->width(), height()
+ );
+}
+
+}
diff --git a/src/editorwindow.h b/src/editorwindow.h
new file mode 100644
index 0000000..3a9d704
--- /dev/null
+++ b/src/editorwindow.h
@@ -0,0 +1,39 @@
+/*
+ editorwindow.h
+ This file is part of the Project::OSiRiON zone editor
+ and is distributed under the terms and conditions of
+ the GNU General Public License version 2
+*/
+
+#ifndef __INCLUDED_EDITOR_EDITORWINDOW__
+#define __INCLUDED_EDITOR_EDITORWINDOW__
+
+#include <QWidget>
+
+namespace editor
+{
+
+class MapWidget;
+class SideBar;
+
+/**
+ * @brief EditorWindow is the main zone editor window
+ * */
+class EditorWindow : public QWidget
+{
+ Q_OBJECT
+
+public:
+ EditorWindow(QWidget *parent = 0);
+
+protected:
+ virtual void resizeEvent (QResizeEvent *event);
+
+private:
+ MapWidget *editorwindow_mapwidget;
+ SideBar *editorwindow_sidebar;
+};
+
+}
+
+#endif // __INCLUDED_EDITOR_EDITORWINDOW__ \ No newline at end of file
diff --git a/src/mainwindow.cc b/src/mainwindow.cc
index e0fe6b2..5dbc226 100644
--- a/src/mainwindow.cc
+++ b/src/mainwindow.cc
@@ -5,12 +5,16 @@
the GNU General Public License version 2
*/
-#include <mainwindow.h>
-#include <mapwidget.h>
+#include "mainwindow.h"
+#include "editorwindow.h"
namespace editor
{
+/**
+ * @brief MainWindow is the application's main window.
+ * The main window contains a QMdiArea that manages ZoneEditor children
+ * */
MainWindow::MainWindow()
{
// set window title
@@ -65,7 +69,7 @@ void MainWindow::init_menu()
void MainWindow::add_child()
{
// create a child widget
- MapWidget *child_widget = new MapWidget();
+ EditorWindow *child_widget = new EditorWindow();
// add the widget to the MDI area,
// this will wrap an QMdiSubWindow around it
diff --git a/src/mapwidget.cc b/src/mapwidget.cc
index 3c0d846..0eb745f 100644
--- a/src/mapwidget.cc
+++ b/src/mapwidget.cc
@@ -15,18 +15,18 @@ namespace editor
MapWidget::MapWidget(QWidget *parent) : QWidget(parent)
{
- setMinimumSize(128,128);
+ setMinimumSize(256,256);
// zoom sucks but it works
- mapwidget_zoom = 4;
+ mapwidget_zoom = 16;
}
void MapWidget::wheelEvent(QWheelEvent *event)
{
if (event->orientation() == Qt::Vertical) {
- mapwidget_zoom += event->delta() / 120;
- if (mapwidget_zoom < 1)
- mapwidget_zoom = 1;
+ mapwidget_zoom -= event->delta() / 120;
+ if (mapwidget_zoom < 4)
+ mapwidget_zoom = 4;
else if (mapwidget_zoom > 64) {
mapwidget_zoom = 64;
}
@@ -43,9 +43,9 @@ void MapWidget::paintEvent(QPaintEvent *event)
painter.setPen(pen);
// mapwidget_zoom is used to scale from game units to screen coorinates
- // 1 grid square is 128 game units
+ // 1 grid square is 256 game units
// gridsize is the size of one grid square in screen coordinates
- int gridsize = 128 / mapwidget_zoom;
+ int gridsize = width() / mapwidget_zoom;
int x = width() / 2;
while (x > 0) {
diff --git a/src/mapwidget.h b/src/mapwidget.h
index fcc8b28..532ddc0 100644
--- a/src/mapwidget.h
+++ b/src/mapwidget.h
@@ -12,7 +12,10 @@
namespace editor
{
-
+
+/**
+ * @brief MapWidget shows the zone map with the blue grid line
+ * */
class MapWidget : public QWidget
{
Q_OBJECT
@@ -24,6 +27,7 @@ protected:
virtual void paintEvent(QPaintEvent *event);
virtual void wheelEvent(QWheelEvent *event);
+
private:
int mapwidget_zoom;
};
diff --git a/src/sidebar.cc b/src/sidebar.cc
new file mode 100644
index 0000000..9dfa682
--- /dev/null
+++ b/src/sidebar.cc
@@ -0,0 +1,41 @@
+/*
+ sidebar.h
+ This file is part of the Project::OSiRiON zone editor
+ and is distributed under the terms and conditions of
+ the GNU General Public License version 2
+*/
+
+#include <QVBoxLayout>
+#include <QLabel>
+#include <QLineEdit>
+
+#include "sidebar.h"
+
+namespace editor
+{
+
+SideBar::SideBar(QWidget *parent) : QWidget(parent)
+{
+ // entity label
+ QHBoxLayout *box_entitylabel = new QHBoxLayout();
+ QLabel *label_entitylabel = new QLabel(tr("label"));
+ QLineEdit *edit_entitylabel = new QLineEdit(tr("entity_label"));
+ box_entitylabel->addWidget(label_entitylabel);
+ box_entitylabel->addWidget(edit_entitylabel);
+
+ // entity name
+ QHBoxLayout *box_entityname = new QHBoxLayout();
+ QLabel *label_entityname = new QLabel(tr("name"));
+ QLineEdit *edit_entityname = new QLineEdit(tr("Entity Name"));
+ box_entityname->addWidget(label_entityname);
+ box_entityname->addWidget(edit_entityname);
+
+ // global vertical layout
+ QVBoxLayout *box_global = new QVBoxLayout();
+ box_global->addLayout(box_entitylabel);
+ box_global->addLayout(box_entityname);
+
+ setLayout(box_global);
+}
+
+} \ No newline at end of file
diff --git a/src/sidebar.h b/src/sidebar.h
new file mode 100644
index 0000000..c7dbb5a
--- /dev/null
+++ b/src/sidebar.h
@@ -0,0 +1,31 @@
+/*
+ sidebar.h
+ This file is part of the Project::OSiRiON zone editor
+ and is distributed under the terms and conditions of
+ the GNU General Public License version 2
+*/
+
+#ifndef __INCLUDED_EDITOR_SIDEBAR__
+#define __INCLUDED_EDITOR_SIDEBAR__
+
+#include <QWidget>
+
+namespace editor
+{
+
+/**
+ * @brief Sidebar is the EditorWindow sidebar
+ * The sidebar show the properties of the currently
+ * selected entity
+ * */
+class SideBar : public QWidget
+{
+ Q_OBJECT
+
+public:
+ SideBar(QWidget *parent = 0);
+};
+
+}
+
+#endif // __INCLUDED_EDITOR_SIDEBAR__ \ No newline at end of file