MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), m_logging(0), m_scene(new SceneModel), m_sceneTreeView(0) { m_logging=new LoggingWidget; QObject::connect(this, SIGNAL(logging(const QString &)), m_logging, SLOT(receive(const QString &))); QObject::connect(m_scene, SIGNAL(logging(const QString &)), m_logging, SLOT(receive(const QString &))); setupDock(m_logging, tr("Log"), Qt::BottomDockWidgetArea, Qt::BottomDockWidgetArea ); // tree view auto m_sceneTreeView=new SceneTreeWidget(m_scene); setupDock(m_sceneTreeView, tr("Scene"), Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea, Qt::LeftDockWidgetArea ); QObject::connect(m_sceneTreeView, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(onSceneItemActivated(const QModelIndex &))); // OpenGL view auto glv=new GLView(m_scene); setCentralWidget(glv); QObject::connect(glv, SIGNAL(logging(const QString &)), m_logging, SLOT(receive(const QString &))); QObject::connect(m_scene, SIGNAL(repaint()), glv, SLOT(update())); // file menu auto file=menuBar()->addMenu(tr("&File")); auto open=new QAction("&Open", this); file->addAction(open); auto quit=new QAction("&Quit", this); file->addAction(quit); connect(quit, SIGNAL(triggered()), qApp, SLOT(quit())); QObject::connect(open, SIGNAL(triggered()), this, SLOT(onOpen())); }
void MainWindow::onSceneItemActivated(const QModelIndex &index) { auto node=m_scene->itemForIndex(index); if(!node){ logging("no such node"); return; } auto w=new SceneNodeWidget(node); setupDock(w, node->name().c_str(), Qt::RightDockWidgetArea | Qt::RightDockWidgetArea, Qt::RightDockWidgetArea ); QObject::connect(m_scene, &SceneModel::sceneNodeUpdated, w, &SceneNodeWidget::onUpdate); }
Gtk::Widget * Ganash::ApplicationWindow::setupUi() { GtkWidget *vbox; GtkWidget *menubar; GtkWidget *toolbar; GtkWidget *dockbar; GtkWidget *statusbar; vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); menubar = setupMenu()->gobj();//gtk_menu_bar_new(); toolbar = setupTool()->gobj();//gtk_toolbar_new(); dockbar = setupDock()->gobj(); statusbar = gtk_statusbar_new(); gtk_widget_set_vexpand(vbox, TRUE); gtk_widget_set_vexpand(dockbar, TRUE); //gtk_widget_set_vexpand(toolbar, FALSE); // ---------------- Gtk::Toolbar *tools = new Gtk::Toolbar(); //tools->set_property("orientation", Gtk::ORIENTATION_VERTICAL); //tools->set_property("toolbar-style", Gtk::TOOLBAR_ICONS); //tools->set_property("icon-size", Gtk::ICON_SIZE_SMALL_TOOLBAR); //tools->set_property("icon-size", Gtk::ICON_SIZE_LARGE_TOOLBAR); Gtk::ToolButton *cursor5_tool = new Gtk::ToolButton(Gtk::StockID(Ganash::Ui::Stock::SELECT)); Gtk::ToolButton *cursor6_tool = new Gtk::ToolButton(Gtk::StockID(Ganash::Ui::Stock::TRANSFORM)); tools->insert(*cursor5_tool, 0); tools->insert(*cursor6_tool, 1); // ---- gtk_container_add(GTK_CONTAINER(vbox), menubar); gtk_container_add(GTK_CONTAINER(vbox), toolbar); gtk_container_add(GTK_CONTAINER(vbox), GTK_WIDGET(tools->gobj())); gtk_container_add(GTK_CONTAINER(vbox), dockbar); //gtk_container_add(GTK_CONTAINER(vbox), statusbar); _menubar = Glib::wrap(menubar); _toolbar = Glib::wrap(toolbar); _dockbar = Glib::wrap(dockbar); _statusbar = Glib::wrap(statusbar); return Glib::wrap(vbox); }