Exemplo n.º 1
0
void level_editor::npc_list::on_edit_clicked() {
  Glib::RefPtr<Gtk::TreeView::Selection> selection = m_tree_view.get_selection();
  Gtk::TreeModel::iterator iter = selection->get_selected();
  if (iter) {
    Gtk::TreeRow row = *iter;
    
    // get selected npc
    npc& current_npc = *row.get_value(columns.iter);
    edit_npc dialog;
    dialog.set(current_npc);
    if (dialog.run() == Gtk::RESPONSE_OK) {
      Graal::npc new_npc = dialog.get_npc();
      level_display* display = m_window.get_current_level_display();
      // TODO: urgh -- move this into level_display (edit_npc() or something)
      /*if (new_npc != current_npc) {
        display->add_undo_diff(new npc_diff(current_npc));
      }*/
      // save npc
      current_npc = new_npc;
      // TODO: this should probably not be here
      display->clear_selection();
      display->queue_draw();
    }

    get();
  }
}
Exemplo n.º 2
0
//------------------------------------------------------------------------------
std::string mforms::gtk::ToolBarImpl::get_item_text(mforms::ToolBarItem *item) {
  std::string text;

  switch (item->get_type()) {
    case mforms::FlatSelectorItem:
    case mforms::SelectorItem: {
      Gtk::ComboBoxText *ct = cast<Gtk::ComboBoxText *>(item->get_data_ptr());
      if (ct)
        text = ct->get_active_text();
      break;
    }
    case mforms::ColorSelectorItem: {
      const Gtk::ComboBox *combo = cast<Gtk::ComboBox *>(item->get_data_ptr());
      if (combo) {
        const Gtk::TreeIter iter = combo->get_active();
        const Gtk::TreeRow row = *iter;
        text = row.get_value(color_combo_columns->color);
      }
      break;
    }
    case mforms::SearchFieldItem: {
      Gtk::Entry *e = cast<Gtk::Entry *>(item->get_data_ptr());
      if (e)
        text = e->get_text();
      break;
    }
    default: {
      Gtk::Widget *btn = cast<Gtk::Widget *>(item->get_data_ptr());
      if (btn)
        text = btn->get_name();
    }
  }

  return text;
}
Exemplo n.º 3
0
void level_editor::sign_list::on_delete_clicked() {
  Glib::RefPtr<Gtk::TreeView::Selection> selection = m_tree_view.get_selection();
  Gtk::TreeModel::iterator iter = selection->get_selected();
  if (iter) {
    Gtk::TreeRow row = *iter;
    m_window.get_current_level()->signs.erase(row.get_value(columns.iter));
    get();
    m_window.get_current_level_display()->queue_draw();
  }
}
Exemplo n.º 4
0
void level_editor::tileset_list::on_active_toggled(const Glib::ustring& path) {
  Gtk::TreeModel::iterator iter = m_list_store->get_iter(path);
  
  if (iter) {
    // Toggle the active state of the currently selected tileset
    Gtk::TreeRow row = *iter;
    tileset_list_type::iterator tileset_iter = row.get_value(columns.iter);

    bool active = !tileset_iter->active;
    tileset_iter->active = active;
    row.set_value(columns.active, active);
    m_window.update_matching_level_displays(tileset_iter->prefix);
  }
}
Exemplo n.º 5
0
void level_editor::tileset_list::on_delete_clicked() {
  Glib::RefPtr<Gtk::TreeView::Selection> selection = m_tree_view.get_selection();
  Gtk::TreeModel::iterator iter = selection->get_selected();
  if (iter) {
    Gtk::TreeRow row = *iter;
    tileset_list_type::iterator tileset_iter = row.get_value(columns.iter);
    // Cache prefix to update tileset after
    std::string prefix = tileset_iter->prefix;
    m_preferences.tilesets.erase(tileset_iter);

    m_window.update_matching_level_displays(prefix);
    get();
  }
}
Exemplo n.º 6
0
    void DrawableTreeView::add_group ( const ::Gtk::TreeRow & row, Group::pointer group )
    {
      ::Gtk::TreeModel::iterator iter, liter;
      Group::Layers::const_iterator layers_iter;
      Group::Layer::const_iterator layer_iter;
      Group::pointer subgroup;

      for ( layers_iter = group->layers().begin(); layers_iter != group->layers().end(); layers_iter++ )
      {
        if ( m_show_layers )
        {
          std::ostringstream sout;
          sout.str("");
          sout << "Layer " << layers_iter->first;
          liter = m_store->append(row.children());
          liter->set_value( m_column_record.type, Glib::ustring(sout.str()) );
        }

        for ( layer_iter = layers_iter->second.begin(); layer_iter != layers_iter->second.end(); layer_iter++ )
        {
          if ( m_show_layers )
          {
            this->add_drawable( *liter, *layer_iter );
          }
          else
          {
            this->add_drawable( row, *layer_iter );
          }
        }
      }

    }
Exemplo n.º 7
0
void
HistoryTreeStore::insert_action(Gtk::TreeRow row,etl::handle<synfigapp::Action::Undoable> action, bool /*is_active*/, bool is_undo, bool is_redo)
{
	assert(action);

	row[model.action] = action;
	row[model.name] = static_cast<Glib::ustring>(action->get_local_name());
	row[model.is_active] = action->is_active();
	row[model.is_undo] = is_undo;
	row[model.is_redo] = is_redo;

	synfigapp::Action::CanvasSpecific *specific_action;
	specific_action=dynamic_cast<synfigapp::Action::CanvasSpecific*>(action.get());
	if(specific_action)
	{
		row[model.canvas] = specific_action->get_canvas();
		row[model.canvas_id] = specific_action->get_canvas()->get_id();
	}

	etl::handle<synfigapp::Action::Group> group;
	group=etl::handle<synfigapp::Action::Group>::cast_dynamic(action);
	if(group)
	{
		synfigapp::Action::ActionList::const_iterator iter;
		for(iter=group->action_list().begin();iter!=group->action_list().end();++iter)
		{
			Gtk::TreeRow child_row = *(append(row.children()));
			insert_action(child_row,*iter,true,is_undo,is_redo);
		}
	}

	//row[model.icon] = Gtk::Button().render_icon_pixbuf(Gtk::StockID("synfig-canvas"),Gtk::ICON_SIZE_SMALL_TOOLBAR);
}
Exemplo n.º 8
0
void level_editor::npc_list::on_delete_clicked() {
  Glib::RefPtr<Gtk::TreeView::Selection> selection = m_tree_view.get_selection();
  Gtk::TreeModel::iterator iter = selection->get_selected();
  if (iter) {
    Gtk::TreeRow row = *iter;
    level_display* display = m_window.get_current_level_display();
    Graal::level::npc_list_type::iterator npc_iter = row.get_value(columns.iter);
    // TODO: move this into level_display, too
    /*display->add_undo_diff(new delete_npc_diff(*npc_iter));
    display->get_current_level()->npcs.erase(npc_iter);*/
    get();

    display->clear_selection();
    display->queue_draw();
  }
}
void DomainEventsAdapterModelImpl::setUnitsColl(
    openfluid::core::UnitsCollection* UnitsColl)
{
  mref_TreeModel->clear();

  if (!UnitsColl)
    return;

  EngineHelper::sortUnitsCollectionById(*UnitsColl);

  openfluid::core::UnitsList_t::iterator it;
  for (it = UnitsColl->getList()->begin(); it != UnitsColl->getList()->end(); ++it)
  {
    openfluid::core::Unit* TheUnit =
        const_cast<openfluid::core::Unit*> (&(*it));

    if (TheUnit->getEvents()->getCount())
    {
      Gtk::TreeRow UnitRow = *mref_TreeModel->append();
      UnitRow[m_Columns.m_Id_Date_Info] = Glib::ustring::compose("%1", TheUnit->getID());

      openfluid::core::EventsList_t* Events =
          TheUnit->getEvents()->getEventsList();

      EngineHelper::sortEventsListByDateTime(*Events);

      openfluid::core::EventsList_t::iterator itEvents;
      for (itEvents = Events->begin(); itEvents != Events->end(); ++itEvents)
      {
        Gtk::TreeRow EventRow = *mref_TreeModel->append(UnitRow->children());
        EventRow[m_Columns.m_Id_Date_Info] = (*itEvents).getDateTime().getAsISOString();

        openfluid::core::Event::EventInfosMap_t Infos = (*itEvents).getInfos();
        openfluid::core::Event::EventInfosMap_t::iterator itInfos;

        for (itInfos = Infos.begin(); itInfos != Infos.end(); ++itInfos)
        {
          Gtk::TreeRow InfoRow = *mref_TreeModel->append(EventRow->children());
          InfoRow[m_Columns.m_Id_Date_Info] = Glib::ustring::compose("%1 : %2",
              itInfos->first, itInfos->second.get());
        }
      }
    }
  }
}
Exemplo n.º 10
0
void ModelAvailFctAdapterModelImpl::setSelectedRow(Gtk::TreeRow Row)
{
  if (Row)
  {
    std::string SelectedId = Row.get_value(m_Columns.m_Id);
    if (Row && m_SignaturesById.find(SelectedId) != m_SignaturesById.end())
      mp_SelectedSignature = m_SignaturesById[SelectedId];
    else
      mp_SelectedSignature = 0;
  }
}
Exemplo n.º 11
0
void level_editor::tileset_list::on_edit_clicked() {
  Glib::RefPtr<Gtk::TreeView::Selection> selection = m_tree_view.get_selection();
  Gtk::TreeModel::iterator iter = selection->get_selected();
  if (iter) {
    Gtk::TreeRow row = *iter;
    
    // get selected tileset
    tileset& _tileset = *row.get_value(columns.iter);
    edit_tileset dialog;
    dialog.get(_tileset);
    if (dialog.run() == Gtk::RESPONSE_OK) {
      std::string old_prefix = _tileset.prefix;
      std::string old_name = _tileset.name;
      // save tileset
      dialog.set(_tileset);
      // update levels with the previous prefix and new levels
      if (old_prefix != _tileset.prefix)
        m_window.update_matching_level_displays(old_prefix);
      m_window.update_matching_level_displays(_tileset.prefix);
    }

    get();
  }
}
void DomainUnitRelationAddDialog::update(std::set<std::string> ClassNames)
{
  mref_TreeModel->clear();

  for (std::set<std::string>::iterator itClass = ClassNames.begin(); itClass
      != ClassNames.end(); ++itClass)
  {
    Gtk::TreeRow ClassRow = *mref_TreeModel->append();
    ClassRow[m_Columns.m_Class] = *itClass;
    ClassRow[m_Columns.m_Text] = *itClass;

    std::set<int> Ids = EngineHelper::getIDs(mp_CoreRepos, *itClass);

    for (std::set<int>::iterator itId = Ids.begin(); itId != Ids.end(); ++itId)
    {
      Gtk::TreeRow Row = *mref_TreeModel->append(ClassRow->children());
      Row[m_Columns.m_Class] = *itClass;
      Row[m_Columns.m_Id] = *itId;
      Row[m_Columns.m_Text] = Glib::ustring::compose("%1", *itId);
    }
  }

  mp_TreeView->expand_all();
}
Exemplo n.º 13
0
    void DrawableTreeView::add_drawable ( const ::Gtk::TreeRow & row, Drawable::pointer d )
    {
        ::Gtk::TreeModel::iterator iter;
        Group::pointer group;

        if ( not d ) return;

        iter = m_store->append(row.children());
        iter->set_value ( m_column_record.type, Glib::ustring ( d->class_name() ) );
        iter->set_value ( m_column_record.id, Glib::ustring ( d->id() ) );

        if ( d->is_group() )
        {
          Group::pointer group = papyrus_dynamic_pointer_cast<Group> ( d );
          this->add_group( *iter, group );
        }
        else if ( d->class_name() == "Reference" )
        {
          Reference::pointer ref = papyrus_dynamic_pointer_cast<Reference>(d);
          this->add_drawable( *iter, ref->referenced() );
        }
  
    }
Exemplo n.º 14
0
//------------------------------------------------------------------------------
void mforms::gtk::ToolBarImpl::set_item_text(mforms::ToolBarItem *item, const std::string &label) {
  const mforms::ToolBarItemType type = item->get_type();

  switch (type) {
    case mforms::TextActionItem:
    case mforms::ActionItem:
    case mforms::SegmentedToggleItem:
    case mforms::ToggleItem:
    case mforms::SwitcherItem: {
      Gtk::Button *btn = cast<Gtk::Button *>(item->get_data_ptr());
      if (type == mforms::SwitcherItem) {
        btn->set_label(label);
        btn->get_style_context()->add_class("SwitcherItem");
      } else
        btn->add_label(label);
      btn->set_name(label);
      break;
    }
    case mforms::TitleItem:
    case mforms::LabelItem: {
      Gtk::Label *lbl = cast<Gtk::Label *>(item->get_data_ptr());
      if (lbl) {
        lbl->set_markup("<small>" + label + "</small>");
        lbl->set_name(label);
      }
      break;
    }
    case mforms::FlatSelectorItem:
    case mforms::SelectorItem: {
      Gtk::ComboBoxText *ct = cast<Gtk::ComboBoxText *>(item->get_data_ptr());
      if (ct)
        ct->set_active_text(label);
      break;
    }
    case mforms::ColorSelectorItem: {
      Gtk::ComboBox *combo = cast<Gtk::ComboBox *>(item->get_data_ptr());
      if (combo) {
        Glib::RefPtr<Gtk::TreeModel> model = combo->get_model();
        if (model) {
          const Gtk::TreeModel::Children children = model->children();
          const Gtk::TreeIter last = children.end();
          Gtk::TreeRow row;

          for (Gtk::TreeIter it = children.begin(); it != last; ++it) {
            row = *it;
            if (row.get_value(color_combo_columns->color) == label) {
              combo->set_active(it);
              break;
            }
          }
        }
      }
      break;
    }
    case mforms::SearchFieldItem:
    case mforms::TextEntryItem: {
      Gtk::Entry *e = cast<Gtk::Entry *>(item->get_data_ptr());
      if (e)
        e->set_text(label);
      break;
    }
    case mforms::SeparatorItem:
    case mforms::ExpanderItem:
    case mforms::ImageBoxItem:
      break;
  }
}
Exemplo n.º 15
0
void
CanvasTreeStore::set_row(Gtk::TreeRow row,synfigapp::ValueDesc value_desc, bool do_children)
{
	Gtk::TreeModel::Children children = row.children();
	while(!children.empty() && erase(children.begin()))
		;

	row[model.value_desc]=value_desc;
	try
	{
		//row[model.icon] = get_tree_pixbuf(value_desc.get_value_type());

		if(value_desc.is_value_node())
		{
			ValueNode::Handle value_node=value_desc.get_value_node();

			// todo: if the parent is animated and expanded, and we drag the time slider so that it changes,
			// it's not updated.  it still shows the previous bone valuenode.

			// maybe replace the ValueNode_Const or ValueNode_Animated with the contained ValueNode_Bone
			value_node = expandable_bone_parent(value_node);

			assert(value_node);

			row[model.value_node] = value_node;
			//row[model.is_canvas] = false;
			//row[model.is_value_node] = true;
			//row[model.is_editable] = synfigapp::is_editable(value_node);
			//row[model.id]=value_node->get_id();

			// Set the canvas
			if(value_desc.parent_is_canvas())
				row[model.canvas]=value_desc.get_canvas();
			else
				row[model.canvas]=canvas_interface()->get_canvas();

			LinkableValueNode::Handle linkable;
			// printf("%s:%d value_node = %s\n", __FILE__, __LINE__, value_node->get_description().c_str());
			linkable=LinkableValueNode::Handle::cast_dynamic(value_node);

			// printf("linkable: %d; do_children: %d\n", bool(linkable), bool(do_children));
			if(linkable && do_children)
			{
				row[model.link_count] = linkable->link_count();
				LinkableValueNode::Vocab vocab(linkable->get_children_vocab());
				LinkableValueNode::Vocab::iterator iter(vocab.begin());
				for(int i=0;i<linkable->link_count();i++, iter++)
				{
					if(iter->get_hidden())
						continue;
					Gtk::TreeRow child_row=*(append(row.children()));
					child_row[model.link_id] = i;
					child_row[model.canvas] = static_cast<Canvas::Handle>(row[model.canvas]);
					child_row[model.name] = linkable->link_local_name(i);
					child_row[model.tooltip] = iter->get_description();
					child_row[model.child_param_desc] = *iter;
					set_row(child_row,synfigapp::ValueDesc(linkable,i));
				}
			}
			return;
		}
		else
		{
			//row[model.is_value_node] = false;
			//row[model.is_editable] = true;
			//row[model.label] = Glib::ustring(row[model.name]);
			return;
		}
	}
	catch(synfig::Exception::IDNotFound x)
	{
		synfig::error(__FILE__":%d: IDNotFound thrown",__LINE__);
		erase(row);
		return;
	}

	// We should never get to this point
	assert(0);
}