Ejemplo n.º 1
0
void RemoteTransform::set_remote_node(const NodePath& p_remote_node) {

	remote_node=p_remote_node;
	if (is_inside_tree())
		_update_cache();

	update_configuration_warning();
}
Ejemplo n.º 2
0
void Tabs::set_tab_right_button(int p_tab, const Ref<Texture> &p_right_button) {

	ERR_FAIL_INDEX(p_tab, tabs.size());
	tabs[p_tab].right_button = p_right_button;
	_update_cache();
	update();
	minimum_size_changed();
}
Ejemplo n.º 3
0
void Tabs::set_current_tab(int p_current) {

	if (current == p_current) return;
	ERR_FAIL_INDEX(p_current, get_tab_count());

	current = p_current;

	_change_notify("current_tab");
	_update_cache();
	update();

	emit_signal("tab_changed", p_current);
}
Ejemplo n.º 4
0
void AnimationCache::set_track_value(int p_idx,const Variant& p_value) {

	if (cache_dirty)
		_update_cache();

	ERR_FAIL_COND(!cache_valid);
	ERR_FAIL_INDEX(p_idx,path_cache.size());
	Path &p = path_cache[p_idx];
	if (!p.valid)
		return;

	ERR_FAIL_COND(!p.object);
	p.object->set(p.property,p_value);
}
Ejemplo n.º 5
0
void AnimationCache::call_track(int p_idx, const StringName &p_method, const Variant **p_args, int p_argcount, Variant::CallError &r_error) {

	if (cache_dirty)
		_update_cache();

	ERR_FAIL_COND(!cache_valid);
	ERR_FAIL_INDEX(p_idx, path_cache.size());
	Path &p = path_cache.write[p_idx];
	if (!p.valid)
		return;

	ERR_FAIL_COND(!p.object);
	p.object->call(p_method, p_args, p_argcount, r_error);
}
Ejemplo n.º 6
0
void Tabs::add_tab(const String &p_str, const Ref<Texture> &p_icon) {

	Tab t;
	t.text = p_str;
	t.icon = p_icon;
	t.disabled = false;
	t.ofs_cache = 0;
	t.size_cache = 0;

	tabs.push_back(t);
	_update_cache();
	update();
	minimum_size_changed();
}
Ejemplo n.º 7
0
void Tabs::move_tab(int from, int to) {

	if (from == to)
		return;

	ERR_FAIL_INDEX(from, tabs.size());
	ERR_FAIL_INDEX(to, tabs.size());

	Tab tab_from = tabs[from];
	tabs.remove(from);
	tabs.insert(to, tab_from);

	_update_cache();
	update();
}
Ejemplo n.º 8
0
void Tabs::remove_tab(int p_idx) {

	ERR_FAIL_INDEX(p_idx, tabs.size());
	tabs.remove(p_idx);
	if (current >= p_idx)
		current--;
	_update_cache();
	update();
	minimum_size_changed();

	if (current < 0)
		current = 0;
	if (current >= tabs.size())
		current = tabs.size() - 1;

	_ensure_no_over_offset();
}
Ejemplo n.º 9
0
void AnimationCache::set_track_transform(int p_idx, const Transform &p_transform) {

	if (cache_dirty)
		_update_cache();

	ERR_FAIL_COND(!cache_valid);
	ERR_FAIL_INDEX(p_idx, path_cache.size());
	Path &p = path_cache.write[p_idx];
	if (!p.valid)
		return;

	ERR_FAIL_COND(!p.node);
	ERR_FAIL_COND(!p.spatial);

	if (p.skeleton) {
		p.skeleton->set_bone_pose(p.bone_idx, p_transform);
	} else {
		p.spatial->set_transform(p_transform);
	}
}
Ejemplo n.º 10
0
void RemoteTransform2D::_notification(int p_what) {

	switch (p_what) {

		case NOTIFICATION_READY: {

			_update_cache();

		} break;
		case NOTIFICATION_TRANSFORM_CHANGED: {
			if (!is_inside_tree())
				break;

			if (cache) {

				_update_remote();
			}

		} break;
	}
}
Ejemplo n.º 11
0
void AnimationCache::set_all(float p_time, float p_delta) {

	if (cache_dirty)
		_update_cache();

	ERR_FAIL_COND(!cache_valid);

	int tc = animation->get_track_count();
	for(int i=0;i<tc;i++) {

		switch(animation->track_get_type(i)) {

			case Animation::TYPE_TRANSFORM: {

				Vector3 loc,scale;
				Quat rot;
				animation->transform_track_interpolate(i,p_time,&loc,&rot,&scale);
				Transform tr( Matrix3(rot), loc );
				tr.basis.scale(scale);

				set_track_transform(i,tr);


			} break;
			case Animation::TYPE_VALUE: {

				if (animation->value_track_is_continuous(i)) {
					Variant v = animation->value_track_interpolate(i,p_time);
					set_track_value(i,v);
				} else {

					List<int> indices;
					animation->value_track_get_key_indices(i,p_time,p_delta,&indices);

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

						Variant v = animation->track_get_key_value(i,E->get());
						set_track_value(i,v);
					}

				}

			} break;
			case Animation::TYPE_METHOD: {

				List<int> indices;
				animation->method_track_get_key_indices(i,p_time,p_delta,&indices);

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

					Vector<Variant> args = animation->method_track_get_params(i,E->get());
					StringName name = animation->method_track_get_name(i,E->get());
					Variant::CallError err;

					if (!args.size()) {

						call_track(i,name,NULL,0,err);
					} else {

						Vector<Variant*> argptrs;
						argptrs.resize(args.size());
						for(int j=0;j<args.size();j++) {

							argptrs[j]=&args[j];
						}

						call_track(i,name,(const Variant**)&argptrs[0],args.size(),err);
					}

				}

			} break;
			default: {}
		}
	}

}
Ejemplo n.º 12
0
void Tabs::_notification(int p_what) {

	switch (p_what) {

		case NOTIFICATION_MOUSE_EXIT: {
			rb_hover = -1;
			cb_hover = -1;
			hover = -1;
			update();
		} break;
		case NOTIFICATION_RESIZED: {
			_update_cache();
			_ensure_no_over_offset();
			ensure_tab_visible(current);

		} break;
		case NOTIFICATION_DRAW: {
			_update_cache();
			RID ci = get_canvas_item();

			Ref<StyleBox> tab_bg = get_stylebox("tab_bg");
			Ref<StyleBox> tab_fg = get_stylebox("tab_fg");
			Ref<StyleBox> tab_disabled = get_stylebox("tab_disabled");
			Ref<Font> font = get_font("font");
			Color color_fg = get_color("font_color_fg");
			Color color_bg = get_color("font_color_bg");
			Color color_disabled = get_color("font_color_disabled");
			Ref<Texture> close = get_icon("close");

			int h = get_size().height;
			int w = 0;
			int mw = 0;

			for (int i = 0; i < tabs.size(); i++) {

				tabs[i].ofs_cache = mw;
				mw += get_tab_width(i);
			}

			if (tab_align == ALIGN_CENTER) {
				w = (get_size().width - mw) / 2;
			} else if (tab_align == ALIGN_RIGHT) {
				w = get_size().width - mw;
			}

			if (w < 0) {
				w = 0;
			}

			Ref<Texture> incr = get_icon("increment");
			Ref<Texture> decr = get_icon("decrement");
			Ref<Texture> incr_hl = get_icon("increment_highlight");
			Ref<Texture> decr_hl = get_icon("decrement_highlight");

			int limit = get_size().width - incr->get_size().width - decr->get_size().width;

			missing_right = false;

			for (int i = 0; i < tabs.size(); i++) {

				if (i < offset)
					continue;

				tabs[i].ofs_cache = w;

				int lsize = tabs[i].size_cache;

				Ref<StyleBox> sb;
				Color col;

				if (tabs[i].disabled) {
					sb = tab_disabled;
					col = color_disabled;
				} else if (i == current) {
					sb = tab_fg;
					col = color_fg;
				} else {
					sb = tab_bg;
					col = color_bg;
				}

				if (w + lsize > limit) {
					max_drawn_tab = i - 1;
					missing_right = true;
					break;
				} else {
					max_drawn_tab = i;
				}

				Rect2 sb_rect = Rect2(w, 0, tabs[i].size_cache, h);
				sb->draw(ci, sb_rect);

				w += sb->get_margin(MARGIN_LEFT);

				Size2i sb_ms = sb->get_minimum_size();
				Ref<Texture> icon = tabs[i].icon;
				if (icon.is_valid()) {

					icon->draw(ci, Point2i(w, sb->get_margin(MARGIN_TOP) + ((sb_rect.size.y - sb_ms.y) - icon->get_height()) / 2));
					if (tabs[i].text != "")
						w += icon->get_width() + get_constant("hseparation");
				}

				font->draw(ci, Point2i(w, sb->get_margin(MARGIN_TOP) + ((sb_rect.size.y - sb_ms.y) - font->get_height()) / 2 + font->get_ascent()), tabs[i].text, col, tabs[i].size_text);

				w += tabs[i].size_text;

				if (tabs[i].right_button.is_valid()) {

					Ref<StyleBox> style = get_stylebox("button");
					Ref<Texture> rb = tabs[i].right_button;

					w += get_constant("hseparation");

					Rect2 rb_rect;
					rb_rect.size = style->get_minimum_size() + rb->get_size();
					rb_rect.position.x = w;
					rb_rect.position.y = sb->get_margin(MARGIN_TOP) + ((sb_rect.size.y - sb_ms.y) - (rb_rect.size.y)) / 2;

					if (rb_hover == i) {
						if (rb_pressing)
							get_stylebox("button_pressed")->draw(ci, rb_rect);
						else
							style->draw(ci, rb_rect);
					}

					rb->draw(ci, Point2i(w + style->get_margin(MARGIN_LEFT), rb_rect.position.y + style->get_margin(MARGIN_TOP)));
					w += rb->get_width();
					tabs[i].rb_rect = rb_rect;
				}

				if (cb_displaypolicy == CLOSE_BUTTON_SHOW_ALWAYS || (cb_displaypolicy == CLOSE_BUTTON_SHOW_ACTIVE_ONLY && i == current)) {

					Ref<StyleBox> style = get_stylebox("button");
					Ref<Texture> cb = close;

					w += get_constant("hseparation");

					Rect2 cb_rect;
					cb_rect.size = style->get_minimum_size() + cb->get_size();
					cb_rect.position.x = w;
					cb_rect.position.y = sb->get_margin(MARGIN_TOP) + ((sb_rect.size.y - sb_ms.y) - (cb_rect.size.y)) / 2;

					if (!tabs[i].disabled && cb_hover == i) {
						if (cb_pressing)
							get_stylebox("button_pressed")->draw(ci, cb_rect);
						else
							style->draw(ci, cb_rect);
					}

					cb->draw(ci, Point2i(w + style->get_margin(MARGIN_LEFT), cb_rect.position.y + style->get_margin(MARGIN_TOP)));
					w += cb->get_width();
					tabs[i].cb_rect = cb_rect;
				}

				w += sb->get_margin(MARGIN_RIGHT);
			}

			if (offset > 0 || missing_right) {

				int vofs = (get_size().height - incr->get_size().height) / 2;

				if (offset > 0)
					draw_texture(highlight_arrow == 0 ? decr_hl : decr, Point2(limit, vofs));
				else
					draw_texture(decr, Point2(limit, vofs), Color(1, 1, 1, 0.5));

				if (missing_right)
					draw_texture(highlight_arrow == 1 ? incr_hl : incr, Point2(limit + decr->get_size().width, vofs));
				else
					draw_texture(incr, Point2(limit + decr->get_size().width, vofs), Color(1, 1, 1, 0.5));

				buttons_visible = true;
			} else {
				buttons_visible = false;
			}

		} break;
	}
}