Ejemplo n.º 1
0
void grid::remove_child(const unsigned row, const unsigned col)
{
	assert(row < rows_ && col < cols_);

	child& cell = get_child(row, col);
	cell.set_widget(nullptr);
}
Ejemplo n.º 2
0
BehaviorNode::Status StatusBNode::_step(const Variant &target, Dictionary &env) {
    if (!get_behavior_enable() || get_child_count() == 0)
        return STATUS_FAILURE;
    if ((bool)call(StringName("pre_behavior"),target, Variant(env)) && get_child_count() > 0) {
        if (_selected < 0) {
            _selected = 0;
        }else if (_selected >= get_child_count()) {
            _selected = get_child_count() - 1;
        }
        BehaviorNode *b_node = get_child(_selected)->cast_to<BehaviorNode>();
        Status childrenStatus = STATUS_FAILURE;
        if (b_node) {
            if (_selected != _old_selected)
                b_node->reset(target);
            childrenStatus =   b_node->step(target, env);
        }
        _old_selected = _selected;
        Status status = (Status)((int)call(StringName("behavior"),target, Variant(env)));
        if (status == STATUS_DEPEND_ON_CHILDREN)
            return childrenStatus;
        else
            return status;
    }else {
        return STATUS_FAILURE;
    }
}
Ejemplo n.º 3
0
      void strided(char *dst, intptr_t dst_stride, char *const *DYND_UNUSED(src),
                   const intptr_t *DYND_UNUSED(src_stride), size_t count)
      {
        static std::intptr_t data_stride[1] = {0};

        get_child()->strided(dst, dst_stride, &data, data_stride, count);
      }
Ejemplo n.º 4
0
static void
gtk_layout_move_internal (GtkLayout       *layout,
                          GtkWidget       *widget,
                          gboolean         change_x,
                          gint             x,
                          gboolean         change_y,
                          gint             y)
{
  GtkLayoutChild *child;

  child = get_child (layout, widget);

  g_assert (child);

  gtk_widget_freeze_child_notify (widget);
  
  if (change_x)
    {
      child->x = x;
      gtk_widget_child_notify (widget, "x");
    }

  if (change_y)
    {
      child->y = y;
      gtk_widget_child_notify (widget, "y");
    }

  gtk_widget_thaw_child_notify (widget);
  
  if (gtk_widget_get_visible (widget) &&
      gtk_widget_get_visible (GTK_WIDGET (layout)))
    gtk_widget_queue_resize (widget);
}
Ejemplo n.º 5
0
bool GraphEdit::_filter_input(const Point2 &p_point) {

	Ref<Texture> port = get_icon("port", "GraphNode");

	float grab_r_extend = 2.0;
	float grab_r = port->get_width() * 0.5 * grab_r_extend;
	for (int i = get_child_count() - 1; i >= 0; i--) {

		GraphNode *gn = get_child(i)->cast_to<GraphNode>();
		if (!gn)
			continue;

		for (int j = 0; j < gn->get_connection_output_count(); j++) {

			Vector2 pos = gn->get_connection_output_pos(j) + gn->get_pos();
			if (pos.distance_to(p_point) < grab_r)
				return true;
		}

		for (int j = 0; j < gn->get_connection_input_count(); j++) {

			Vector2 pos = gn->get_connection_input_pos(j) + gn->get_pos();
			if (pos.distance_to(p_point) < grab_r) {
				return true;
			}
		}
	}

	return false;
}
Ejemplo n.º 6
0
Size2 TabContainer::get_minimum_size() const {

	Size2 ms;

	for(int i=0;i<get_child_count();i++) {

		Control *c = get_child(i)->cast_to<Control>();
		if (!c)
			continue;
		if (c->is_set_as_toplevel())
			continue;

		if (!c->has_meta("_tab_name"))
			continue;

		if (!c->is_visible())
			continue;

		Size2 cms = c->get_minimum_size();
		ms.x=MAX(ms.x,cms.x);
		ms.y=MAX(ms.y,cms.y);
	}

	Ref<StyleBox> tab_bg = get_stylebox("tab_bg");
	Ref<StyleBox> tab_fg = get_stylebox("tab_fg");
	Ref<Font> font = get_font("font");

	ms.y+=MAX(tab_bg->get_minimum_size().y,tab_fg->get_minimum_size().y);
	ms.y+=font->get_height();

	return ms;
}
Ejemplo n.º 7
0
void TabContainer::set_current_tab(int p_current) {

	ERR_FAIL_INDEX( p_current, get_tab_count() );

    //printf("DEBUG %p: set_current_tab to %i\n", this, p_current);
	current=p_current;

	int idx=0;

	Ref<StyleBox> sb=get_stylebox("panel");
	for(int i=0;i<get_child_count();i++) {

		Control *c = get_child(i)->cast_to<Control>();
		if (!c)
			continue;
		if (c->is_set_as_toplevel())
			continue;
		if (idx==current) {
			c->show();
			c->set_area_as_parent_rect();
			if (tabs_visible)
				c->set_margin(MARGIN_TOP,_get_top_margin());
			for(int i=0;i<4;i++)
				c->set_margin(Margin(i),c->get_margin(Margin(i))+sb->get_margin(Margin(i)));


		} else
			c->hide();
		idx++;
	}

	_change_notify("current_tab");
	emit_signal("tab_changed",current);
	update();
}
Ejemplo n.º 8
0
int TabContainer::_get_top_margin() const {

	Ref<StyleBox> tab_bg = get_stylebox("tab_bg");
	Ref<StyleBox> tab_fg = get_stylebox("tab_fg");
	Ref<Font> font = get_font("font");

	int h = MAX( tab_bg->get_minimum_size().height,tab_fg->get_minimum_size().height);

//	h+=MIN( get_constant("label_valign_fg"), get_constant("label_valign_bg") );

	int ch = font->get_height();;
	for(int i=0;i<get_child_count();i++) {

		Control *c = get_child(i)->cast_to<Control>();
		if (!c)
			continue;
		if (c->is_set_as_toplevel())
			continue;
		if (!c->has_meta("_tab_icon"))
			continue;

		Ref<Texture> tex = c->get_meta("_tab_icon");
		if (!tex.is_valid())
			continue;
		ch = MAX( ch, tex->get_size().height );
	}

	h+=ch;

	return h;

}
Ejemplo n.º 9
0
Size2 ScrollContainer::get_minimum_size() const {

	Size2 min_size;

	for (int i = 0; i < get_child_count(); i++) {

		Control *c = Object::cast_to<Control>(get_child(i));
		if (!c)
			continue;
		if (c->is_set_as_toplevel())
			continue;
		if (c == h_scroll || c == v_scroll)
			continue;
		Size2 minsize = c->get_combined_minimum_size();

		if (!scroll_h) {
			min_size.x = MAX(min_size.x, minsize.x);
		}
		if (!scroll_v) {
			min_size.y = MAX(min_size.y, minsize.y);
		}
	}

	if (h_scroll->is_visible_in_tree()) {
		min_size.y += h_scroll->get_minimum_size().y;
	}
	if (v_scroll->is_visible_in_tree()) {
		min_size.x += v_scroll->get_minimum_size().x;
	}
	return min_size;
};
Ejemplo n.º 10
0
void grid::set_child(widget* widget,
					  const unsigned row,
					  const unsigned col,
					  const unsigned flags,
					  const unsigned border_size)
{
	assert(row < rows_ && col < cols_);
	assert(flags & VERTICAL_MASK);
	assert(flags & HORIZONTAL_MASK);

	child& cell = get_child(row, col);

	// clear old child if any
	if(cell.get_widget()) {
		// free a child when overwriting it
		WRN_GUI_G << LOG_HEADER << " child '" << cell.id() << "' at cell '"
				  << row << ',' << col << "' will be replaced.\n";
	}

	// copy data
	cell.set_flags(flags);
	cell.set_border_size(border_size);
	cell.set_widget(widget);
	if(cell.get_widget()) {
		// make sure the new child is valid before deferring
		cell.get_widget()->set_parent(this);
	}
}
Ejemplo n.º 11
0
Node *Node::duplicate_and_reown(const Map<Node*,Node*>& p_reown_map) const {


	ERR_FAIL_COND_V(get_filename()!="",NULL);

	Node *node=NULL;

	Object *obj = ObjectTypeDB::instance(get_type());
	if (!obj) {
		print_line("could not duplicate: "+String(get_type()));
	}
	ERR_FAIL_COND_V(!obj,NULL);
	node = obj->cast_to<Node>();
	if (!node)
		memdelete(obj);
	ERR_FAIL_COND_V(!node,NULL);

	node->set_name(get_name());

	for(int i=0;i<get_child_count();i++) {

		get_child(i)->_duplicate_and_reown(node,p_reown_map);
	}

	return node;

}
Ejemplo n.º 12
0
void TableofcontentsNoteAddin::get_toc_popover_items(std::vector<Gtk::Widget*> & items) const
{
  std::vector<TocItem> toc_items;

  get_toc_items(toc_items);
  if(toc_items.size()) {
    auto item = dynamic_cast<Gtk::ModelButton*>(gnote::utils::create_popover_button("win.tableofcontents-goto-heading", ""));
    Gtk::Label *label = (Gtk::Label*)item->get_child();
    label->set_markup("<b>" + get_note()->get_title() + "</b>");
    gtk_actionable_set_action_target_value(GTK_ACTIONABLE(item->gobj()), g_variant_new_int32(0));
    item->property_role() = Gtk::BUTTON_ROLE_NORMAL;
    item->property_inverted() = true;
    item->property_centered() = false;
    items.push_back(item);
  }

  for(auto & toc_item : toc_items) {
    if(toc_item.heading_level == Heading::Level_2) {
      toc_item.heading = "→  " + toc_item.heading;
    }
    auto item = dynamic_cast<Gtk::ModelButton*>(gnote::utils::create_popover_button("win.tableofcontents-goto-heading", toc_item.heading));
    if(toc_item.heading_level == Heading::Level_1) {
      item->set_image(*manage(new Gtk::Image(Gtk::Stock::GO_FORWARD, Gtk::ICON_SIZE_MENU)));
    }
    gtk_actionable_set_action_target_value(GTK_ACTIONABLE(item->gobj()), g_variant_new_int32(toc_item.heading_position));
    item->property_role() = Gtk::BUTTON_ROLE_NORMAL;
    item->property_inverted() = true;
    item->property_centered() = false;
    items.push_back(item);
  }
}
Ejemplo n.º 13
0
void Node::_duplicate_signals(const Node* p_original,Node* p_copy) const {

	if (this!=p_original && get_owner()!=p_original)
		return;

	List<Connection> conns;
	get_all_signal_connections(&conns);

	for (List<Connection>::Element *E=conns.front();E;E=E->next()) {

		if (E->get().flags&CONNECT_PERSIST) {
			//user connected
			NodePath p = p_original->get_path_to(this);
			Node *copy = p_copy->get_node(p);

			Node *target = E->get().target->cast_to<Node>();
			if (!target)
				continue;
			NodePath ptarget = p_original->get_path_to(target);
			Node *copytarget = p_copy->get_node(ptarget);

			if (copy && copytarget) {
				copy->connect(E->get().signal,copytarget,E->get().method,E->get().binds,CONNECT_PERSIST);
			}
		}
	}

	for(int i=0;i<get_child_count();i++) {
		get_child(i)->_duplicate_signals(p_original,p_copy);
	}

}
Ejemplo n.º 14
0
Lpatch* 
Lpatch::sub_patch(int k)
{
   // Returns the child patch at the given subdivision level
   // relative to this patch. E.g.:
   //
   //     k | returned Patch
   // ---------------------
   //    -1 | _parent
   //     0 | this
   //     1 | _child
   //     2 | _child->_child
   //      ...
   //

   // If there is no parent, returns this Patch for k < 0:
   if (k < 0)
      return _parent ? _parent->sub_patch(k+1) : this;
   if (k == 0)
      return this;

   // Ensure child is allocated:
   if (!_child)
      get_child();

   // if for some reason the child could not be allocated, 
   // return this:
   return _child ? _child->sub_patch(k-1) : this;
}
Ejemplo n.º 15
0
TEST_F(ConfigTests, test_parse) {
  Config c;
  auto tree = getExamplePacksConfig();
  auto packs = tree.get_child("packs");
  for (const auto& pack : packs) {
    c.addPack(pack.first, "", pack.second);
  }

  std::map<std::string, bool> results = {
      {"unrestricted_pack", true},
      {"discovery_pack", false},
      {"fake_version_pack", true},
      // Although this is a valid discovery query, there is no SQL plugin in
      // the core tests.
      {"valid_discovery_pack", false},
      {"restricted_pack", true},
  };

  c.packs(([&results](Pack& pack) {
    if (results[pack.getName()]) {
      EXPECT_TRUE(pack.shouldPackExecute());
    } else {
      EXPECT_FALSE(pack.shouldPackExecute());
    }
  }));
}
Ejemplo n.º 16
0
 void single(char *dst, char *const *src)
 {
   const dynd::ndt::callable_type *fpt = m_proto.extended<dynd::ndt::callable_type>();
   intptr_t nsrc = fpt->get_narg();
   const dynd::ndt::type &dst_tp = fpt->get_return_type();
   const std::vector<dynd::ndt::type> &src_tp = fpt->get_argument_types();
   // First set up the parameters in a tuple
   pydynd::pyobject_ownref args(PyTuple_New(nsrc));
   for (intptr_t i = 0; i != nsrc; ++i) {
     dynd::ndt::type tp = src_tp[i];
     dynd::nd::array n = dynd::nd::make_array(tp, const_cast<char *>(src[i]), dynd::nd::read_access_flag);
     if (src_tp[i].get_arrmeta_size() > 0) {
       src_tp[i].extended()->arrmeta_copy_construct(n.get()->metadata(), m_src_arrmeta[i], dynd::nd::memory_block());
     }
     PyTuple_SET_ITEM(args.get(), i, pydynd::array_from_cpp(std::move(n)));
   }
   // Now call the function
   pydynd::pyobject_ownref res(PyObject_Call(m_pyfunc, args.get(), NULL));
   // Copy the result into the destination memory
   PyObject *child_obj = res.get();
   char *child_src = reinterpret_cast<char *>(&child_obj);
   get_child()->single(dst, &child_src);
   res.clear();
   // Validate that the call didn't hang onto the ephemeral data
   // pointers we used. This is done after the dst assignment, because
   // the function result may have contained a reference to an argument.
   verify_postcall_consistency(args.get());
 }
Ejemplo n.º 17
0
void ViewportContainer::_notification(int p_what) {

	if (p_what == NOTIFICATION_RESIZED) {

		if (!stretch)
			return;

		for (int i = 0; i < get_child_count(); i++) {

			Viewport *c = Object::cast_to<Viewport>(get_child(i));
			if (!c)
				continue;

			c->set_size(get_size() / shrink);
		}
	}

	if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_VISIBILITY_CHANGED) {

		for (int i = 0; i < get_child_count(); i++) {

			Viewport *c = Object::cast_to<Viewport>(get_child(i));
			if (!c)
				continue;

			if (is_visible_in_tree())
				c->set_update_mode(Viewport::UPDATE_ALWAYS);
			else
				c->set_update_mode(Viewport::UPDATE_DISABLED);
		}
	}

	if (p_what == NOTIFICATION_DRAW) {

		for (int i = 0; i < get_child_count(); i++) {

			Viewport *c = Object::cast_to<Viewport>(get_child(i));
			if (!c)
				continue;

			if (stretch)
				draw_texture_rect(c->get_texture(), Rect2(Vector2(), get_size() * Size2(1, -1)));
			else
				draw_texture_rect(c->get_texture(), Rect2(Vector2(), c->get_size() * Size2(1, -1)));
		}
	}
}
Ejemplo n.º 18
0
pid_t exec (const char* cmd_line)
{
    //Attempt to create new process
    pid_t pid = (pid_t)process_execute(cmd_line);
    if (pid == TID_ERROR)
        return -1;

    //Busy wait until process is done loading
    struct process* process = get_child(pid);
    while ((get_child(pid)) && get_child(pid)->load_state == LOAD_PENDING);

    //Fail gracefully... unsuccessful load
    if (process->load_state != LOAD_SUCCESS)
        return -1;

    return pid;
}
Ejemplo n.º 19
0
 ~apply_pyobject_kernel()
 {
   if (m_pyfunc != NULL) {
     pydynd::PyGILState_RAII pgs;
     Py_DECREF(m_pyfunc);
     get_child()->destroy();
   }
 }
Ejemplo n.º 20
0
void init_directories(struct node *root){
  unsigned int i;
  struct cache *cache = get_cache(root);
  cache->dir = init_directory(root);
  for (i=0; i<root->nb_children; i++){
    init_directories(get_child(root, i));
  }
}
Ejemplo n.º 21
0
void BuildingUI::init_buildingUI(){
	name_str=dynamic_cast<UIString*>(get_child("name"));
	atk_str=dynamic_cast<UIString*>(get_child("atk"));
	armor_str=dynamic_cast<UIString*>(get_child("armor"));
	hp_str=dynamic_cast<UIString*>(get_child("hp"));
	upgrade_str[0]=dynamic_cast<UIString*>(get_child("upgrade1_amount"));
	upgrade_str[1]=dynamic_cast<UIString*>(get_child("upgrade2_amount"));
	upgrade_str[2]=dynamic_cast<UIString*>(get_child("upgrade3_amount"));
	upgrade_str[3]=dynamic_cast<UIString*>(get_child("upgrade4_amount"));
}
Ejemplo n.º 22
0
/* varlist semantic handle function */
int sem_varlist_handle(NodePtr node, symbol **vlist, int tail) {
    uint_32 rule = node->content.rule;
    symbol *var;
    if (VARLIST__PARAMDEC_COMMA_VARLIST == rule) {
        var = sem_paramdec_handle(get_child(node, 0));
        vlist[tail] = var;
        return sem_varlist_handle(get_child(node, 2), \
          vlist, tail + 1);
    }
    else if (VARLIST__PARAMDEC == rule) {
        var = sem_paramdec_handle(get_child(node, 0));
        vlist[tail] = var;
        return tail + 1;
    }
    else {
        printf("Test Error: unknown VarList rule\n");
    }
}
Ejemplo n.º 23
0
void delete_directories(struct node *root){
  unsigned int i;
  if (get_cache(root)->directory){
    delete_directory(get_cache(root)->dir);
  }
  for (i=0; i<root->nb_children; i++){
    delete_directories(get_child(root, i));
  }
}
Ejemplo n.º 24
0
void Node::get_owned_by(Node *p_by,List<Node*> *p_owned) {

	if (data.owner==p_by)
		p_owned->push_back(this);

	for (int i=0;i<get_child_count();i++)
		get_child(i)->get_owned_by(p_by,p_owned);

}
Ejemplo n.º 25
0
bool contains(trie root, char* word) {
  trie n = root;

  for(; n != NULL && *word != '\0'; word++) {
    n = get_child(n, *word);
  }

  return n != NULL && end_of_word(n);
}
Ejemplo n.º 26
0
const property_def *node::get_child_property(const char *childname,
					const char *name, bool strict) const {
	node *child = get_child(childname);

	if (child)
		return child->get_property(name, strict);

	return 0;
}
Ejemplo n.º 27
0
/* Get the number of all sons in hierarchy */
int get_nb_sons(struct node *node){
  unsigned int i;
  int res = 0;
  res = node->nb_children;
  for (i=0; i<node->nb_children; i++){
    res += get_nb_sons(get_child(node, i));
  }
  return res;
}
Ejemplo n.º 28
0
extern echld_reqh_id_t echld_reqh(
		echld_chld_id_t child_id,
		echld_msg_type_t t,
		int usecs_timeout _U_,
		enc_msg_t* ba,
		echld_msg_cb_t resp_cb,
		void* cb_data) {
	return reqh_snd(get_child(child_id),t,ba,resp_cb,cb_data);
}
Ejemplo n.º 29
0
extern echld_state_t echld_set_data(echld_chld_id_t chld_id, void* data) {
	echld_t* c = get_child(chld_id);
	if (c) {
		c->data = data;
		return TRUE;
	}

	return FALSE;
}
Ejemplo n.º 30
0
std::string login()
{
	const config& cfg = get_child("hero");

	if (cfg && !cfg["name"].empty()) {
		return cfg["name"].str();
	}
	return public_account;
}