void SelectionSetToolmenu::onSelectionChanged(GtkComboBox* comboBox, SelectionSetToolmenu* self) { GtkTreeIter iter; if (gtk_combo_box_get_active_iter(comboBox, &iter)) { std::string name = gtkutil::ComboBox::getActiveText(comboBox); if (name.empty()) return; ISelectionSetPtr set = GlobalSelectionSetManager().findSelectionSet(name); if (set == NULL) return; // The user can choose to DESELECT the set nodes when holding down shift if ((GlobalEventManager().getModifierState() & GDK_SHIFT_MASK) != 0) { set->deselect(); } else { set->select(); } GtkWidget* childEntry = gtk_bin_get_child(GTK_BIN(self->_entry)); gtk_entry_set_text(GTK_ENTRY(childEntry), ""); } }
void SelectionSetToolmenu::onEntryActivated() { // Create new selection set if possible std::string name = _entry->get_entry()->get_text(); if (name.empty()) return; // don't create empty sets if (GlobalSelectionSystem().countSelected() == 0) { ui::IDialogPtr dialog = GlobalDialogManager().createMessageBox( _("Cannot create selection set"), _("Cannot create a selection set, there is nothing selected in the current scene."), ui::IDialog::MESSAGE_CONFIRM); dialog->run(); return; } ISelectionSetPtr set = GlobalSelectionSetManager().createSelectionSet(name); assert(set != NULL); set->assignFromCurrentScene(); // Clear the entry again _entry->get_entry()->set_text(""); }
void SelectionSetToolmenu::onDeleteAllSetsClicked(GtkToolButton* toolbutton, SelectionSetToolmenu* self) { EMessageBoxReturn result = gtk_MessageBox(NULL, _("This will delete all set definitions. The actual map objects will not be affected by this step.\n\nContinue with that operation?"), _("Delete all selection sets?"), eMB_YESNO); if (result == eIDYES) { GlobalSelectionSetManager().deleteAllSelectionSets(); } }
void Map::onResourceUnrealise() { if(m_resource != 0) { setValid(false); setWorldspawn(scene::INodePtr()); GlobalUndoSystem().clear(); GlobalSelectionSetManager().deleteAllSelectionSets(); GlobalSceneGraph().setRoot(scene::INodePtr()); } }
SelectionSetToolmenu::SelectionSetToolmenu() : Gtk::ToolItem(), _listStore(Gtk::ListStore::create(_columns)), _clearSetsButton(NULL), _entry(Gtk::manage(new Gtk::ComboBoxEntry(_listStore, _columns.name))) { // Hbox containing all our items Gtk::HBox* hbox = Gtk::manage(new Gtk::HBox(false, 3)); add(*hbox); // Pack Label hbox->pack_start( *Gtk::manage(new gtkutil::LeftAlignedLabel(_("Selection Set: "))), false, false, 0); // Pack Combo Box hbox->pack_start(*_entry, true, true, 0); // Add tooltip _entry->set_tooltip_markup(_(ENTRY_TOOLTIP)); // Add clear button { Gtk::Image* image = Gtk::manage(new Gtk::Image(GlobalUIManager().getLocalPixbufWithMask("delete.png"))); image->show(); _clearSetsButton = Gtk::manage(new Gtk::ToolButton(*image, _("Clear Selection Sets"))); // Set tooltip _clearSetsButton->set_tooltip_text(_("Clear Selection Sets")); // Connect event _clearSetsButton->signal_clicked().connect(sigc::mem_fun(*this, &SelectionSetToolmenu::onDeleteAllSetsClicked)); hbox->pack_start(*_clearSetsButton, false, false, 0); } // Connect the signals Gtk::Entry* childEntry = _entry->get_entry(); childEntry->signal_activate().connect(sigc::mem_fun(*this, &SelectionSetToolmenu::onEntryActivated)); _entry->signal_changed().connect(sigc::mem_fun(*this, &SelectionSetToolmenu::onSelectionChanged)); // Populate the list update(); // Add self as observer GlobalSelectionSetManager().addObserver(*this); show_all(); }
void SelectionSetToolmenu::onDeleteAllSetsClicked() { ui::IDialogPtr dialog = GlobalDialogManager().createMessageBox( _("Delete all selection sets?"), _("This will delete all set definitions. The actual map objects will not be affected by this step.\n\nContinue with that operation?"), ui::IDialog::MESSAGE_ASK); ui::IDialog::Result result = dialog->run(); if (result == ui::IDialog::RESULT_YES) { GlobalSelectionSetManager().deleteAllSelectionSets(); } }
SelectionSetToolmenu::SelectionSetToolmenu() : _toolItem(gtk_tool_item_new()), _listStore(gtk_list_store_new(1, G_TYPE_STRING)), _clearSetsButton(NULL), _entry(gtk_combo_box_entry_new_with_model(GTK_TREE_MODEL(_listStore), 0)) { // Hbox containing all our items GtkWidget* hbox = gtk_hbox_new(FALSE, 3); gtk_container_add(GTK_CONTAINER(_toolItem), hbox); // Pack Label gtk_box_pack_start(GTK_BOX(hbox), gtkutil::LeftAlignedLabel(_("Selection Set: ")), FALSE, FALSE, 0); // Pack Combo Box gtk_box_pack_start(GTK_BOX(hbox), _entry, TRUE, TRUE, 0); // Add tooltip gtk_widget_set_tooltip_markup(_entry, _(ENTRY_TOOLTIP)); // Add clear button { GtkWidget* image = gtk_image_new_from_pixbuf(GlobalUIManager().getLocalPixbufWithMask("delete.png")); gtk_widget_show(image); _clearSetsButton = gtk_tool_button_new(image, _("Clear Selection Sets")); // Set tooltip gtk_tool_item_set_tooltip_text(_clearSetsButton, _("Clear Selection Sets")); // Connect event g_signal_connect(G_OBJECT(_clearSetsButton), "clicked", G_CALLBACK(onDeleteAllSetsClicked), this); gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(_clearSetsButton), FALSE, FALSE, 0); } // Connect the signals GtkWidget* childEntry = gtk_bin_get_child(GTK_BIN(_entry)); g_signal_connect(G_OBJECT(childEntry), "activate", G_CALLBACK(onEntryActivated), this); g_signal_connect(G_OBJECT(_entry), "changed", G_CALLBACK(onSelectionChanged), this); // Populate the list update(); // Add self as observer GlobalSelectionSetManager().addObserver(*this); }
void SelectionSetToolmenu::update() { // Clear all items from the treemodel first _listStore->clear(); bool hasItems = false; GlobalSelectionSetManager().foreachSelectionSet([&] (const ISelectionSetPtr& set) { hasItems = true; Gtk::TreeModel::Row row = *_listStore->append(); row[_columns.name] = set->getName(); }); // Tool button is sensitive if we have items in the list _clearSetsButton->set_sensitive(hasItems); }
void SelectionSetToolmenu::update() { // Clear all items from the treemodel first gtk_list_store_clear(_listStore); // Populate the list store with all available selection sets class Visitor : public ISelectionSetManager::Visitor { private: GtkListStore* _store; bool _hasItems; public: Visitor(GtkListStore* store) : _store(store), _hasItems(false) {} void visit(const ISelectionSetPtr& set) { _hasItems = true; GtkTreeIter iter; gtk_list_store_append(_store, &iter); gtk_list_store_set(_store, &iter, 0, set->getName().c_str(), -1); } bool foundItems() const { return _hasItems; } } visitor(_listStore); GlobalSelectionSetManager().foreachSelectionSet(visitor); // Tool button is sensitive if we have items in the list gtk_widget_set_sensitive(GTK_WIDGET(_clearSetsButton), visitor.foundItems() ? TRUE : FALSE); }
void SelectionSetToolmenu::onSelectionChanged() { std::string name = _entry->get_active_text(); if (name.empty()) return; ISelectionSetPtr set = GlobalSelectionSetManager().findSelectionSet(name); if (set == NULL) return; // The user can choose to DESELECT the set nodes when holding down shift if ((GlobalEventManager().getModifierState() & GDK_SHIFT_MASK) != 0) { set->deselect(); } else { set->select(); } _entry->get_entry()->set_text(""); }
void SelectionSetToolmenu::onEntryActivated(GtkEntry* entry, SelectionSetToolmenu* self) { // Create new selection set if possible std::string name = gtk_entry_get_text(entry); if (name.empty()) return; // don't create empty sets if (GlobalSelectionSystem().countSelected() == 0) { gtkutil::errorDialog(_("Cannot create selection set, there is nothing selected in the current scene.")); return; } ISelectionSetPtr set = GlobalSelectionSetManager().createSelectionSet(name); set->assignFromCurrentScene(); // Clear the entry again gtk_entry_set_text(GTK_ENTRY(entry), ""); }
SelectionSetToolmenu::~SelectionSetToolmenu() { GlobalSelectionSetManager().removeObserver(*this); }
/** * @brief Create the user settable window layout */ void MainFrame::Create (void) { GtkWindow* window = GTK_WINDOW(gtk_window_new(GTK_WINDOW_TOPLEVEL)); // do this here, because the commands are needed _sidebar = new ui::Sidebar(); GtkWidget *sidebar = _sidebar->getWidget(); // Tell the XYManager which window the xyviews should be transient for GlobalXYWnd().setGlobalParentWindow(window); GlobalWindowObservers_connectTopLevel(window); gtk_window_set_transient_for(ui::Splash::Instance().getWindow(), window); #ifndef _WIN32 { GdkPixbuf* pixbuf = gtkutil::getLocalPixbuf(ui::icons::ICON); if (pixbuf != 0) { gtk_window_set_icon(window, pixbuf); g_object_unref(pixbuf); } } #endif gtk_widget_add_events(GTK_WIDGET(window), GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_FOCUS_CHANGE_MASK); g_signal_connect(G_OBJECT(window), "delete_event", G_CALLBACK(mainframe_delete), this); m_position_tracker.connect(window); g_MainWindowActive.connect(window); GtkWidget* vbox = gtk_vbox_new(FALSE, 0); gtk_container_add(GTK_CONTAINER(window), vbox); gtk_widget_show(vbox); GlobalEventManager().connect(GTK_OBJECT(window)); GlobalEventManager().connectAccelGroup(GTK_WINDOW(window)); m_nCurrentStyle = eSplit; // Create the Filter menu entries ui::FiltersMenu::addItemsToMainMenu(); // Retrieve the "main" menubar from the UIManager GtkMenuBar* mainMenu = GTK_MENU_BAR(GlobalUIManager().getMenuManager()->get("main")); gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(mainMenu), false, false, 0); // Instantiate the ToolbarCreator and retrieve the standard toolbar widget ui::ToolbarCreator toolbarCreator; GtkToolbar* generalToolbar = toolbarCreator.getToolbar("view"); gtk_widget_show(GTK_WIDGET(generalToolbar)); GlobalSelectionSetManager().init(generalToolbar); // Pack it into the main window gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(generalToolbar), FALSE, FALSE, 0); GtkWidget* main_statusbar = create_main_statusbar(m_pStatusLabel); gtk_box_pack_end(GTK_BOX(vbox), main_statusbar, FALSE, TRUE, 2); GtkWidget* hbox = gtk_hbox_new(FALSE, 0); gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(hbox), TRUE, TRUE, 0); gtk_widget_show(hbox); GtkToolbar* main_toolbar_v = toolbarCreator.getToolbar("edit"); gtk_widget_show(GTK_WIDGET(main_toolbar_v)); gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(main_toolbar_v), FALSE, FALSE, 0); // Connect the window position tracker _windowPosition.loadFromPath(RKEY_WINDOW_STATE); // Yes, connect the position tracker, this overrides the existing setting. _windowPosition.connect(window); int startMonitor = GlobalRegistry().getInt(RKEY_MULTIMON_START_MONITOR); if (startMonitor < gtkutil::MultiMonitor::getNumMonitors()) { // Load the correct coordinates into the position tracker _windowPosition.fitToScreen(gtkutil::MultiMonitor::getMonitor(startMonitor), 0.8f, 0.8f); } // Apply the position _windowPosition.applyPosition(); int windowState = string::toInt(GlobalRegistry().getAttribute(RKEY_WINDOW_STATE, "state"), GDK_WINDOW_STATE_MAXIMIZED); if (windowState & GDK_WINDOW_STATE_MAXIMIZED) gtk_window_maximize(window); m_window = window; gtk_widget_show(GTK_WIDGET(window)); // The default XYView pointer XYWnd* xyWnd; GtkWidget* mainHBox = gtk_hbox_new(0, 0); gtk_box_pack_start(GTK_BOX(hbox), mainHBox, TRUE, TRUE, 0); gtk_widget_show(mainHBox); int w, h; gtk_window_get_size(window, &w, &h); // camera m_pCamWnd = GlobalCamera().newCamWnd(); GlobalCamera().setCamWnd(m_pCamWnd); GlobalCamera().setParent(m_pCamWnd, window); GtkWidget* camera = m_pCamWnd->getWidget(); // Allocate the three ortho views xyWnd = GlobalXYWnd().createXY(); xyWnd->setViewType(XY); GtkWidget* xy = xyWnd->getWidget(); XYWnd* yzWnd = GlobalXYWnd().createXY(); yzWnd->setViewType(YZ); GtkWidget* yz = yzWnd->getWidget(); XYWnd* xzWnd = GlobalXYWnd().createXY(); xzWnd->setViewType(XZ); GtkWidget* xz = xzWnd->getWidget(); // split view (4 views) GtkHPaned* split = create_split_views(camera, yz, xy, xz); gtk_box_pack_start(GTK_BOX(mainHBox), GTK_WIDGET(split), TRUE, TRUE, 0); // greebo: In any layout, there is at least the XY view present, make it active GlobalXYWnd().setActiveXY(xyWnd); PreferencesDialog_constructWindow(window); GlobalGrid().addGridChangeCallback(FreeCaller<XY_UpdateAllWindows> ()); /* enable button state tracker, set default states for begin */ GlobalUndoSystem().trackerAttach(m_saveStateTracker); gtk_box_pack_start(GTK_BOX(mainHBox), GTK_WIDGET(sidebar), FALSE, FALSE, 0); // Start the autosave timer so that it can periodically check the map for changes map::AutoSaver().startTimer(); }