goat3d

annotate goatview/src/goatview.cc @ 73:9862541fdcf5

- build qt goatview on linux - fixed line endings in a bunch of files
author John Tsiombikas <nuclear@member.fsf.org>
date Tue, 06 May 2014 03:57:11 +0300
parents 36e39632db75
children ab66cdabf6f2
rev   line source
nuclear@73 1 #include "goatview.h"
nuclear@73 2
nuclear@73 3 GoatView::GoatView()
nuclear@73 4 {
nuclear@73 5 make_menu();
nuclear@73 6 make_dock();
nuclear@73 7 make_center();
nuclear@73 8
nuclear@73 9 statusBar();
nuclear@73 10
nuclear@73 11 setWindowTitle("GoatView");
nuclear@73 12 }
nuclear@73 13
nuclear@73 14 GoatView::~GoatView()
nuclear@73 15 {
nuclear@73 16 }
nuclear@73 17
nuclear@73 18 bool GoatView::make_menu()
nuclear@73 19 {
nuclear@73 20 QMenu *menu_file = menuBar()->addMenu("&File");
nuclear@73 21
nuclear@73 22 QAction *act_open_sce = new QAction("&Open Scene", this);
nuclear@73 23 act_open_sce->setShortcuts(QKeySequence::Open);
nuclear@73 24 connect(act_open_sce, &QAction::triggered, this, &GoatView::open_scene);
nuclear@73 25 menu_file->addAction(act_open_sce);
nuclear@73 26
nuclear@73 27 QAction *act_open_anm = new QAction("Open &Animation", this);
nuclear@73 28 connect(act_open_anm, &QAction::triggered, this, &GoatView::open_anim);
nuclear@73 29 menu_file->addAction(act_open_anm);
nuclear@73 30
nuclear@73 31 QAction *act_quit = new QAction("&Quit", this);
nuclear@73 32 act_quit->setShortcuts(QKeySequence::Quit);
nuclear@73 33 connect(act_quit, &QAction::triggered, [&](){qApp->quit();});
nuclear@73 34 menu_file->addAction(act_quit);
nuclear@73 35 return true;
nuclear@73 36 }
nuclear@73 37
nuclear@73 38 bool GoatView::make_dock()
nuclear@73 39 {
nuclear@73 40 // ---- side-dock ----
nuclear@73 41 QWidget *dock_cont = new QWidget;
nuclear@73 42 QVBoxLayout *dock_vbox = new QVBoxLayout;
nuclear@73 43 dock_cont->setLayout(dock_vbox);
nuclear@73 44
nuclear@73 45 QPushButton *bn_quit = new QPushButton("quit");
nuclear@73 46 dock_vbox->addWidget(bn_quit);
nuclear@73 47 connect(bn_quit, &QPushButton::clicked, [&](){qApp->quit();});
nuclear@73 48
nuclear@73 49 QDockWidget *dock = new QDockWidget("Scene graph", this);
nuclear@73 50 dock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
nuclear@73 51 dock->setWidget(dock_cont);
nuclear@73 52 addDockWidget(Qt::LeftDockWidgetArea, dock);
nuclear@73 53
nuclear@73 54 // ---- bottom dock ----
nuclear@73 55 dock_cont = new QWidget;
nuclear@73 56 QHBoxLayout *dock_hbox = new QHBoxLayout;
nuclear@73 57 dock_cont->setLayout(dock_hbox);
nuclear@73 58
nuclear@73 59 QSlider *slider_time = new QSlider(Qt::Orientation::Horizontal);
nuclear@73 60 slider_time->setDisabled(true);
nuclear@73 61 dock_hbox->addWidget(slider_time);
nuclear@73 62
nuclear@73 63 dock = new QDockWidget("Animation", this);
nuclear@73 64 dock->setAllowedAreas(Qt::BottomDockWidgetArea);
nuclear@73 65 dock->setWidget(dock_cont);
nuclear@73 66 addDockWidget(Qt::BottomDockWidgetArea, dock);
nuclear@73 67
nuclear@73 68 return true;
nuclear@73 69 }
nuclear@73 70
nuclear@73 71 bool GoatView::make_center()
nuclear@73 72 {
nuclear@73 73 GoatViewport *vport = new GoatViewport;
nuclear@73 74 setCentralWidget(vport);
nuclear@73 75 return true;
nuclear@73 76 }
nuclear@73 77
nuclear@73 78 void GoatView::open_scene()
nuclear@73 79 {
nuclear@73 80 statusBar()->showMessage("opening scene...");
nuclear@73 81 }
nuclear@73 82
nuclear@73 83 void GoatView::open_anim()
nuclear@73 84 {
nuclear@73 85 statusBar()->showMessage("opening animation...");
nuclear@73 86 }
nuclear@73 87
nuclear@73 88
nuclear@73 89 // ---- OpenGL viewport ----
nuclear@73 90 GoatViewport::GoatViewport()
nuclear@73 91 : QGLWidget(QGLFormat(QGL::DepthBuffer))
nuclear@73 92 {
nuclear@73 93 }
nuclear@73 94
nuclear@73 95 GoatViewport::~GoatViewport()
nuclear@73 96 {
nuclear@73 97 }
nuclear@73 98
nuclear@73 99 QSize GoatViewport::sizeHint() const
nuclear@73 100 {
nuclear@73 101 return QSize(800, 600);
nuclear@73 102 }
nuclear@73 103
nuclear@73 104 void GoatViewport::initializeGL()
nuclear@73 105 {
nuclear@73 106 }
nuclear@73 107
nuclear@73 108 void GoatViewport::resizeGL(int xsz, int ysz)
nuclear@73 109 {
nuclear@73 110 glViewport(0, 0, xsz, ysz);
nuclear@73 111 }
nuclear@73 112
nuclear@73 113 void GoatViewport::paintGL()
nuclear@73 114 {
nuclear@73 115 glClearColor(1, 0, 0, 1);
nuclear@73 116 glClear(GL_COLOR_BUFFER_BIT);
nuclear@73 117 }