Esempio n. 1
0
void Popup::_fix_size() {

#if 0
	Point2 pos = get_position();
	Size2 size = get_size();
	Point2 window_size = window==this ? get_parent_area_size()  :window->get_size();
#else

	Point2 pos = get_global_position();
	Size2 size = get_size();
	Point2 window_size = get_viewport_rect().size;

#endif
	if (pos.x + size.width > window_size.width)
		pos.x = window_size.width - size.width;
	if (pos.x < 0)
		pos.x = 0;

	if (pos.y + size.height > window_size.height)
		pos.y = window_size.height - size.height;
	if (pos.y < 0)
		pos.y = 0;
#if 0
	if (pos!=get_pos())
		set_position(pos);
#else
	if (pos != get_position())
		set_global_position(pos);

#endif
}
Esempio n. 2
0
void Popup::popup_centered_ratio(float p_screen_ratio) {
	
	
	Control *window = get_window();
	ERR_FAIL_COND(!window);
	
	emit_signal("about_to_show");

	Rect2 rect;
	Point2 window_size = window==this ? get_parent_area_size()  :window->get_size();
	rect.size = (window_size * p_screen_ratio).floor();
	rect.pos = ((window_size-rect.size)/2.0).floor();
	set_pos( rect.pos );
	set_size( rect.size );
	
	show_modal(exclusive);
	_fix_size();

	Control *focusable = find_next_valid_focus();
	if (focusable)
		focusable->grab_focus();

	_post_popup();
	notification(NOTIFICATION_POST_POPUP);

}
Esempio n. 3
0
void Popup::_fix_size() {
	
	Control *window = get_window();
	ERR_FAIL_COND(!window);
	
	Point2 pos = get_pos();
	Size2 size = get_size();		
	Point2 window_size = window==this ? get_parent_area_size()  :window->get_size();

	if (pos.x+size.width > window_size.width)
		pos.x=window_size.width-size.width;
	if (pos.x<0)
		pos.x=0;
	
	if (pos.y+size.height > window_size.height)
		pos.y=window_size.height-size.height;
	if (pos.y<0)
		pos.y=0;
	if (pos!=get_pos())
		set_pos(pos);

}