void DocumentProperties::onNewExtraField () { Gtk::Dialog dialog ("New Field", *dialog_, true, false); Gtk::VBox *vbox = dialog.get_vbox (); Gtk::HBox hbox; hbox.set_spacing (12); vbox->pack_start (hbox, true, true, 0); Gtk::Label label ("Field name:", false); hbox.pack_start (label, false, false, 0); Gtk::Entry entry; entry.set_activates_default (true); hbox.pack_start (entry, true, true, 0); dialog.add_button (Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); dialog.add_button (Gtk::Stock::OK, Gtk::RESPONSE_ACCEPT); dialog.set_default_response (Gtk::RESPONSE_ACCEPT); dialog.show_all (); vbox->set_border_width (12); if (dialog.run () == Gtk::RESPONSE_ACCEPT) { Gtk::ListStore::iterator it = extrafieldsstore_->children().begin (); Gtk::ListStore::iterator const end = extrafieldsstore_->children().end (); bool key_isnew = true; for (; it != end; ++it) if (Utility::firstCap ((*it)[extrakeycol_]) == Utility::firstCap (entry.get_text ())) { key_isnew = false; } if ( key_isnew ) { Gtk::ListStore::iterator row = extrafieldsstore_->append (); (*row)[extrakeycol_] = Utility::firstCap (entry.get_text ()); (*row)[extravalcol_] = ""; } else { Glib::ustring message; message = String::ucompose ( "<b><big>%1</big></b>", _("This key already exists.\n")); Gtk::MessageDialog dialog ( message, true, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_CLOSE, true); dialog.run (); } } }
void MenuWidget::OnConstantItemActivated(const Gtk::TreeModel::Path& path, Gtk::TreeViewColumn* /* column */) { Gtk::TreeModel::iterator iter = m_ConstantTableTreeModel->get_iter(path); if (iter) { Gtk::TreeModel::Row row = *iter; if (!iter->parent()->get_stamp() || !iter->parent()->parent()->get_stamp()) return; // Not good; std::cout << "Row activated: Name=" << row->get_value(m_TableColumn) << std::endl; for (unsigned int p = 0; p < m_arrShaderPassDesc.size(); p++) { if (m_arrShaderPassDesc[p].name == row->parent()->parent()->get_value(m_TableColumn)) { for (unsigned int i = 0; i < m_arrShaderPassDesc[p].constants.size(); i++) { if (m_arrShaderPassDesc[p].constants[i].name == row->get_value(m_TableColumn)) { switch (m_arrShaderPassDesc[p].constants[i].inputType) { case IT_BOOL: case IT_FLOAT: case IT_INT: { Gtk::Dialog matrixDialog; Gtk::VBox rowBox; Gtk::HBox colBox[4]; Gtk::Entry entry[16]; for (unsigned int j = 0; j < 16; j++) { char temp[32]; sprintf_s(temp, "%f", m_arrShaderPassDesc[p].constants[i].valueFloat[j]); entry[j].set_text(temp); } unsigned int rows = m_arrShaderPassDesc[p].constants[i].rows; unsigned int cols = m_arrShaderPassDesc[p].constants[i].cols; unsigned int sizeOfArray = m_arrShaderPassDesc[p].constants[i].sizeOfArray; matrixDialog.get_vbox()->pack_start(rowBox); for (unsigned int r = 0; r < rows; r++) { rowBox.pack_start(colBox[r]); for (unsigned int c = 0; c < cols; c++) { colBox[r].pack_start(entry[r*cols + c]); } } matrixDialog.add_button(GTK_STOCK_OK, Gtk::RESPONSE_OK); matrixDialog.set_modal(); matrixDialog.show_all(); int ret = matrixDialog.run(); if (ret == Gtk::RESPONSE_OK) for (unsigned int r = 0; r < rows; r++) for (unsigned int c = 0; c < cols; c++) { m_arrShaderPassDesc[p].constants[i].valueFloat[r*cols + c] = (float)atof(entry[r*cols + c].get_text().c_str()); } break; } case IT_SAMPLER: case IT_SAMPLER1D: case IT_SAMPLER2D: case IT_SAMPLER3D: case IT_SAMPLERCUBE: { Gtk::FileChooserDialog textureDialog("Choose texture file"); textureDialog.add_button("Select", Gtk::RESPONSE_OK); int ret = textureDialog.run(); if (ret == Gtk::RESPONSE_OK) { Renderer* render = Renderer::GetInstance(); ResourceManager* resMan = render->GetResourceManager(); const unsigned int texIdx = resMan->CreateTexture(textureDialog.get_filename().c_str()); m_arrShaderPassDesc[p].constants[i].sampler.boundTexture = resMan->GetTexture(texIdx); } break; } default: return; } return; } } return; } } } }