Esempio n. 1
0
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;
			}
		}
	}
}
Esempio n. 2
0
         aboutDialog::aboutDialog()
         {
            Gtk::Dialog *ad = this;

            Gtk::Button *okbutton    = Gtk::manage(new class Gtk::Button("ok"));
            Gtk::Label *aboutLabel   = Gtk::manage(new class Gtk::Label( "About " + GPD->sGUI_CLIENT() + " " + GPD->sVERSION() + ", build " + GPD->sBUILD() ));
            Gtk::TextView *textview  = Gtk::manage(new class Gtk::TextView());
            Gtk::ScrolledWindow *scrolledwindow = Gtk::manage(new class Gtk::ScrolledWindow());
            Gtk::VBox *vbox                     = Gtk::manage(new class Gtk::VBox(false, 0));

            okbutton->set_flags(Gtk::CAN_FOCUS);
            okbutton->set_relief(Gtk::RELIEF_NORMAL);

            ad->get_action_area()->property_layout_style().set_value(Gtk::BUTTONBOX_END);
            ad->set_default_size(300, 200);

            aboutLabel->set_alignment(0.5,0.5);
            aboutLabel->set_padding(0,0);
            aboutLabel->set_justify(Gtk::JUSTIFY_LEFT);
            aboutLabel->set_line_wrap(false);
            aboutLabel->set_use_markup(false);
            aboutLabel->set_selectable(false);

            textview->set_flags(Gtk::CAN_FOCUS);
            textview->set_editable(true);
            textview->set_cursor_visible(true);
            textview->set_pixels_above_lines(0);
            textview->set_pixels_below_lines(0);
            textview->set_pixels_inside_wrap(0);
            textview->set_left_margin(0);
            textview->set_right_margin(0);
            textview->set_indent(0);
            textview->set_wrap_mode(Gtk::WRAP_NONE);
            textview->set_justification(Gtk::JUSTIFY_LEFT);

            using namespace std;
            string text;
            text += "btg Copyright (C) 2005 Michael Wojciechowski.";
            text += GPD->sNEWLINE();
            text += "This program is free software; you can redistribute it and/or modify";
            text += GPD->sNEWLINE();
            text += "it under the terms of the GNU General Public License as published by ";
            text += GPD->sNEWLINE();
            text += "the Free Software Foundation; either version 2 of the License, or ";
            text += GPD->sNEWLINE();
            text += "(at your option) any later version.";
            text += GPD->sNEWLINE();
            text += "This program is distributed in the hope that it will be useful, ";
            text += GPD->sNEWLINE();
            text += "but WITHOUT ANY WARRANTY; without even the implied warranty of ";
            text += GPD->sNEWLINE();
            text += "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the ";
            text += GPD->sNEWLINE();
            text += "GNU General Public License for more details.";
            text += GPD->sNEWLINE();
            text += "You should have received a copy of the GNU General Public License ";
            text += GPD->sNEWLINE();
            text += "along with this program; if not, write to the Free Software ";
            text += GPD->sNEWLINE();
            text += "Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA";
            text += GPD->sNEWLINE();

            textview->get_buffer()->set_text(text);

            scrolledwindow->set_flags(Gtk::CAN_FOCUS);
            scrolledwindow->set_shadow_type(Gtk::SHADOW_IN);
            scrolledwindow->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
            scrolledwindow->property_window_placement().set_value(Gtk::CORNER_TOP_LEFT);
            scrolledwindow->add(*textview);
            vbox->pack_start(*aboutLabel, Gtk::PACK_SHRINK, 0);
            vbox->pack_start(*scrolledwindow);
            ad->get_vbox()->set_homogeneous(false);
            ad->get_vbox()->set_spacing(0);
            ad->get_vbox()->pack_start(*vbox);
            //ad->set_title( "About " + GPD->sGUI_CLIENT() + " " + GPD->sVERSION() );
            ad->set_title( GPD->sGUI_CLIENT() + " " + GPD->sVERSION() + " / About" );
            ad->set_modal(true);
            ad->property_window_position().set_value(Gtk::WIN_POS_CENTER);
            ad->set_resizable(true);
            ad->property_destroy_with_parent().set_value(false);
            ad->set_has_separator(true);
            ad->add_action_widget(*okbutton, -5);
            okbutton->show();
            aboutLabel->show();
            textview->show();
            scrolledwindow->show();
            vbox->show();

            okbutton->signal_clicked().connect(sigc::mem_fun(*this, &aboutDialog::on_ok_clicked));
            // ad->show();
         }