Example #1
0
/// @fn void LibraryView::loadImagesByDirectory()
/// @brief Method (signal handler) responsible for updating thumbnails in right panel.
///        Called when directory from directory view is clicked.
/// @param path Path to selected row, provided by signal system.
/// @param column Clicked column, provided by signal system, not used.
void LibraryView::loadImagesByDirectory(const Gtk::TreeModel::Path &path,
    Gtk::TreeViewColumn *column) {
  Gtk::TreeModel::iterator row = directory_tree->get_iter(path);
  std::stack<Glib::ustring> buffer;
  boost::filesystem::path dir_path;
  if(!row) return;

  //storing directory path
  while(row) {
    buffer.push((*row)[dir_columns.name]);
    row = row->parent();
  }

  //writing directory path in reverse order
  while(!buffer.empty()) {
    dir_path /= Glib::filename_from_utf8(buffer.top());
    buffer.pop();
  }

  //loading photos
  if(core->hasPhotos(dir_path)) {
    core->setCurrentDirectory(dir_path);
    window->showEditView();
  }
}
Example #2
0
void MenuWidget::OnPassItemActivated(const Gtk::TreeModel::Path& path, Gtk::TreeViewColumn* /* column */)
{
	Gtk::TreeModel::iterator iter = m_PassTableTreeModel->get_iter(path);
	if (iter)
	{
		Gtk::TreeModel::Row row = *iter;

		std::cout << "Row activated: Name=" << row->get_value(m_TableColumn) << std::endl;

		if (iter->parent()->get_stamp())
		{
			char str[10];
			strncpy_s(str, 10, row->get_value(m_TableColumn).c_str(), 9);
			if (strcmp(str, "Object - ") == 0)
			{
				Gtk::FileChooserDialog modelDialog("Choose model file");
				modelDialog.add_button("Select", Gtk::RESPONSE_OK);
				int ret = modelDialog.run();
				if (ret == Gtk::RESPONSE_OK)
				{
					Renderer* render = Renderer::GetInstance();
					ResourceManager* resMan = render->GetResourceManager();
					const unsigned int vbIdx = resMan->CreateVertexBuffer(modelDialog.get_filename().c_str());
					for (unsigned int p = 0; p < m_arrShaderPassDesc.size(); p++)
						if (m_arrShaderPassDesc[p].name == row->parent()->get_value(m_TableColumn))
						{
							m_arrShaderPassDesc[p].model = resMan->GetVertexBuffer(vbIdx);
							break;
						}
				}
			}
		}
		else
		{
			onMenuAccess(row->get_value(m_TableColumn), row->get_value(m_TableColumn));
		}
	}
}
Example #3
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;
			}
		}
	}
}