Exemple #1
0
double ScrollBar::get_area_size() const {

    if (orientation==VERTICAL) {

        double area=get_size().height;
        area-=get_stylebox("scroll")->get_minimum_size().height;
        area-=get_icon("increment")->get_height();
        area-=get_icon("decrement")->get_height();
        area-=get_grabber_min_size();
        return area;

    } else if (orientation==HORIZONTAL) {

        double area=get_size().width;
        area-=get_stylebox("scroll")->get_minimum_size().width;
        area-=get_icon("increment")->get_width();
        area-=get_icon("decrement")->get_width();
        area-=get_grabber_min_size();
        return area;
    } else {

        return 0;
    }

}
Exemple #2
0
Size2 TabContainer::get_minimum_size() const {

	Size2 ms;

	Vector<Control *> tabs = _get_tabs();
	for (int i = 0; i < tabs.size(); i++) {

		Control *c = tabs[i];

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

		Size2 cms = c->get_combined_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<StyleBox> tab_disabled = get_stylebox("tab_disabled");
	Ref<Font> font = get_font("font");

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

	Ref<StyleBox> sb = get_stylebox("panel");
	ms += sb->get_minimum_size();

	return ms;
}
Exemple #3
0
void ProgressBar::_notification(int p_what) {


	if (p_what==NOTIFICATION_DRAW) {

		Ref<StyleBox> bg = get_stylebox("bg");
		Ref<StyleBox> fg = get_stylebox("fg");
		Ref<Font> font = get_font("font");
		Color font_color=get_color("font_color");
		Color font_color_shadow=get_color("font_color_shadow");

		draw_style_box(bg,Rect2(Point2(),get_size()));
		float r = get_unit_value();
		int mp = fg->get_minimum_size().width;
		int p = r*get_size().width-mp;
		if (p>0) {

			draw_style_box(fg,Rect2(Point2(),Size2(p+fg->get_minimum_size().width,get_size().height)));
		}

		int fh=font->get_height();
		String txt=itos(int(get_unit_value()*100))+"%";
		font->draw_halign(get_canvas_item(),Point2(0,font->get_ascent()+(get_size().height-font->get_height())/2),HALIGN_CENTER,get_size().width,txt,font_color);
	}
}
Exemple #4
0
void Slider::_notification(int p_what) {


	switch(p_what) {

		case NOTIFICATION_MOUSE_ENTER: {

			mouse_inside=true;
			update();
		} break;
		case NOTIFICATION_MOUSE_EXIT: {

			mouse_inside=false;
			update();
		} break;
		case NOTIFICATION_DRAW: {
			RID ci = get_canvas_item();
			Size2i size = get_size();
			Ref<StyleBox> style = get_stylebox("slider");
			Ref<StyleBox> focus = get_stylebox("focus");
			Ref<Texture> grabber = get_icon(mouse_inside||has_focus()?"grabber_hilite":"grabber");
			Ref<Texture> tick = get_icon("tick");

			if (orientation==VERTICAL) {

				style->draw(ci,Rect2i(Point2i(),Size2i(style->get_minimum_size().width+style->get_center_size().width,size.height)));
				//if (mouse_inside||has_focus())
				//	focus->draw(ci,Rect2i(Point2i(),Size2i(style->get_minimum_size().width+style->get_center_size().width,size.height)));
				float areasize = size.height - grabber->get_size().height;
				if (ticks>1) {
					int tickarea = size.height - tick->get_height();
					for(int i=0;i<ticks;i++) {
					        if( ! ticks_on_borders && (i == 0 || i + 1 == ticks) ) continue;
						int ofs = i*tickarea/(ticks-1);
						tick->draw(ci,Point2(0,ofs));
					}

				}
				grabber->draw(ci,Point2i(size.width/2-grabber->get_size().width/2,size.height - get_unit_value()*areasize - grabber->get_size().height));
			} else {
				style->draw(ci,Rect2i(Point2i(),Size2i(size.width,style->get_minimum_size().height+style->get_center_size().height)));
				//if (mouse_inside||has_focus())
				//	focus->draw(ci,Rect2i(Point2i(),Size2i(size.width,style->get_minimum_size().height+style->get_center_size().height)));

				float areasize = size.width - grabber->get_size().width;
				if (ticks>1) {
					int tickarea = size.width - tick->get_width();
					for(int i=0;i<ticks;i++) {
					        if( (! ticks_on_borders) && ( (i == 0) || ((i + 1) == ticks)) ) continue;
						int ofs = i*tickarea/(ticks-1);
						tick->draw(ci,Point2(ofs,0));
					}

				}
				grabber->draw(ci,Point2i(get_unit_value()*areasize,size.height/2-grabber->get_size().height/2));
			}

		} break;
	}
}
Exemple #5
0
EditorLog::EditorLog() {

	VBoxContainer *vb = memnew( VBoxContainer);
	add_child(vb);
	vb->set_v_size_flags(SIZE_EXPAND_FILL);

	HBoxContainer *hb = memnew( HBoxContainer );
	vb->add_child(hb);
	title = memnew( Label );
	title->set_text(" Output:");
	title->set_h_size_flags(SIZE_EXPAND_FILL);
	hb->add_child(title);


	button = memnew( ToolButton );
	button->set_text_align(Button::ALIGN_LEFT);
	button->connect("pressed",this,"_flip_request");
	button->set_focus_mode(FOCUS_NONE);
	button->set_clip_text(true);
	button->set_tooltip("Open/Close output panel.");

	//pd = memnew( PaneDrag );
	//hb->add_child(pd);
	//pd->connect("dragged",this,"_dragged");
	//pd->set_default_cursor_shape(Control::CURSOR_MOVE);

	tb = memnew( TextureButton );
	hb->add_child(tb);
	tb->connect("pressed",this,"_close_request");


	ec = memnew( EmptyControl);
	vb->add_child(ec);
	ec->set_minsize(Size2(0,100));
	ec->set_v_size_flags(SIZE_EXPAND_FILL);


	PanelContainer *pc = memnew( PanelContainer );
	pc->add_style_override("panel",get_stylebox("normal","TextEdit"));
	ec->add_child(pc);
	pc->set_area_as_parent_rect();

	log = memnew( RichTextLabel );
	log->set_scroll_follow(true);
	pc->add_child(log);
	add_message(VERSION_FULL_NAME" (c) 2010-2014 www.fengei.com.");
	//log->add_text("Initialization Complete.\n"); //because it looks cool.
	add_style_override("panel",get_stylebox("panelf","Panel"));

	eh.errfunc=_error_handler;
	eh.userdata=this;
	add_error_handler(&eh);

	current=Thread::get_caller_ID();

	EditorNode::get_undo_redo()->set_commit_notify_callback(_undo_redo_cbk,this);

	hide();

}
Exemple #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->is_visible())
            continue;

        Size2 cms = c->get_combined_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();

    Ref<StyleBox> sb = get_stylebox("panel");
    ms+=sb->get_minimum_size();

    return ms;
}
Size2 PanelContainer::get_minimum_size() const {

	Ref<StyleBox> style;

	if (has_stylebox("panel"))
		style=get_stylebox("panel");
	else
		style=get_stylebox("panel","PanelContainer");


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

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

		Size2 minsize = c->get_combined_minimum_size();
		ms.width = MAX(ms.width , minsize.width);
		ms.height = MAX(ms.height , minsize.height);


	}

	if (style.is_valid())
		ms+=style->get_minimum_size();
	return ms;

}
Exemple #8
0
Size2 Tabs::get_minimum_size() const {


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

	Size2 ms(0, MAX( tab_bg->get_minimum_size().height,tab_fg->get_minimum_size().height)+font->get_height() );

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

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

		Ref<Texture> tex = tabs[i].icon;
		if (tex.is_valid()) {
			ms.height = MAX( ms.height, tex->get_size().height );
			if (tabs[i].text!="")
				ms.width+=get_constant("hseparation");

		}
		ms.width+=font->get_string_size(tabs[i].text).width;
		if (current==i)
			ms.width+=tab_fg->get_minimum_size().width;
		else
			ms.width+=tab_bg->get_minimum_size().width;


	}

	return ms;
}
Exemple #9
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);

    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;

}
Exemple #10
0
int TabContainer::_get_tab_width(int p_index) const {
	Control *control = _get_tabs()[p_index]->cast_to<Control>();
	if (!control || control->is_set_as_toplevel())
		return 0;

	// Get the width of the text displayed on the tab.
	Ref<Font> font = get_font("font");
	String text = control->has_meta("_tab_name") ? String(tr(String(control->get_meta("_tab_name")))) : String(control->get_name());
	int width = font->get_string_size(text).width;

	// Add space for a tab icon.
	if (control->has_meta("_tab_icon")) {
		Ref<Texture> icon = control->get_meta("_tab_icon");
		if (icon.is_valid()) {
			width += icon->get_width();
			if (text != "")
				width += get_constant("hseparation");
		}
	}

	// Respect a minimum size.
	Ref<StyleBox> tab_bg = get_stylebox("tab_bg");
	Ref<StyleBox> tab_fg = get_stylebox("tab_fg");
	Ref<StyleBox> tab_disabled = get_stylebox("tab_disabled");
	if (get_tab_disabled(p_index)) {
		width += tab_disabled->get_minimum_size().width;
	} else if (p_index == current) {
		width += tab_fg->get_minimum_size().width;
	} else {
		width += tab_bg->get_minimum_size().width;
	}

	return width;
}
Exemple #11
0
int TabContainer::_get_top_margin() const {

	if (!tabs_visible)
		return 0;

	// Respect the minimum tab height.
	Ref<StyleBox> tab_bg = get_stylebox("tab_bg");
	Ref<StyleBox> tab_fg = get_stylebox("tab_fg");
	Ref<StyleBox> tab_disabled = get_stylebox("tab_disabled");

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

	// Font height or higher icon wins.
	Ref<Font> font = get_font("font");
	int content_height = font->get_height();

	Vector<Control *> tabs = _get_tabs();
	for (int i = 0; i < tabs.size(); i++) {

		Control *c = tabs[i];
		if (!c->has_meta("_tab_icon"))
			continue;

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

	return tab_height + content_height;
}
void EditorAssetLibraryItemDescription::_notification(int p_what) {
	switch (p_what) {
		case NOTIFICATION_ENTER_TREE: {
			previews_bg->add_style_override("panel", get_stylebox("normal", "TextEdit"));
			desc_bg->add_style_override("panel", get_stylebox("normal", "TextEdit"));
		} break;
	}
}
EditorAssetLibraryItemDescription::EditorAssetLibraryItemDescription() {

	VBoxContainer *vbox = memnew( VBoxContainer );
	add_child(vbox);
	set_child_rect(vbox);


	HBoxContainer *hbox = memnew( HBoxContainer);
	vbox->add_child(hbox);
	vbox->add_constant_override("separation",15);
	VBoxContainer *desc_vbox = memnew( VBoxContainer );
	hbox->add_child(desc_vbox);
	hbox->add_constant_override("separation",15);

	item = memnew( EditorAssetLibraryItem );

	desc_vbox->add_child(item);
	desc_vbox->set_custom_minimum_size(Size2(300,0));


	PanelContainer * desc_bg = memnew( PanelContainer );
	desc_vbox->add_child(desc_bg);
	desc_bg->set_v_size_flags(SIZE_EXPAND_FILL);

	description = memnew( RichTextLabel );
	description->connect("meta_clicked",this,"_link_click");
	//desc_vbox->add_child(description);
	desc_bg->add_child(description);
	desc_bg->add_style_override("panel",get_stylebox("normal","TextEdit"));

	preview = memnew( TextureFrame );
	preview->set_custom_minimum_size(Size2(640,345));
	hbox->add_child(preview);

	PanelContainer * previews_bg = memnew( PanelContainer );
	vbox->add_child(previews_bg);
	previews_bg->set_custom_minimum_size(Size2(0,85));
	previews_bg->add_style_override("panel",get_stylebox("normal","TextEdit"));

	previews = memnew( ScrollContainer );
	previews_bg->add_child(previews);
	previews->set_enable_v_scroll(false);
	previews->set_enable_h_scroll(true);
	preview_hb = memnew( HBoxContainer );
	preview_hb->set_v_size_flags(SIZE_EXPAND_FILL);

	previews->add_child(preview_hb);
	get_ok()->set_text("Install");
	get_cancel()->set_text("Close");



}
Exemple #14
0
Size2 ProgressBar::get_minimum_size() const {

	Ref<StyleBox> bg = get_stylebox("bg");
	Ref<StyleBox> fg = get_stylebox("fg");
	Ref<Font> font = get_font("font");

	Size2 minimum_size = bg->get_minimum_size();
	minimum_size.height = MAX(minimum_size.height, fg->get_minimum_size().height);
	minimum_size.width = MAX(minimum_size.width, fg->get_minimum_size().width);
	if (percent_visible) {
		minimum_size.height = MAX(minimum_size.height, bg->get_minimum_size().height + font->get_height());
	}
	return minimum_size;
}
Exemple #15
0
Size2 ProgressBar::get_minimum_size() const {

	Ref<StyleBox> bg = get_stylebox("bg");
	Ref<StyleBox> fg = get_stylebox("fg");
	Ref<Font> font = get_font("font");

	Size2 minimum_size = bg->get_minimum_size();
	minimum_size.height = MAX(minimum_size.height, fg->get_minimum_size().height);
	minimum_size.width = MAX(minimum_size.width, fg->get_minimum_size().width);
	//if (percent_visible) { this is needed, else the progressbar will collapse
	minimum_size.height = MAX(minimum_size.height, bg->get_minimum_size().height + font->get_height());
	//}
	return minimum_size;
}
Exemple #16
0
void TabContainer::set_current_tab(int p_current) {

    ERR_FAIL_INDEX( p_current, get_tab_count() );

    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();
}
Exemple #17
0
void TabContainer::add_child_notify(Node *p_child) {

    Control::add_child_notify(p_child);

    Control *c = p_child->cast_to<Control>();
    if (!c)
        return;
    if (c->is_set_as_toplevel())
        return;

    bool first=false;

    if (get_tab_count()!=1)
        c->hide();
    else {
        c->show();
        //call_deferred("set_current_tab",0);
        first=true;
        current=0;
    }
    c->set_area_as_parent_rect();
    if (tabs_visible)
        c->set_margin(MARGIN_TOP,_get_top_margin());
    Ref<StyleBox> sb = get_stylebox("panel");
    for(int i=0; i<4; i++)
        c->set_margin(Margin(i),c->get_margin(Margin(i))+sb->get_margin(Margin(i)));


    update();
    p_child->connect("renamed", this,"_child_renamed_callback");
    if(first)
        emit_signal("tab_changed",current);
}
Point2 ShaderEditor::_get_slot_pos(int p_node_id,bool p_input,int p_slot) {

	Ref<StyleBox> style = get_stylebox("panel","PopupMenu");
	float w = get_node_size(p_node_id).width;
	Ref<Font> font = get_font("font","PopupMenu");
	float h = font->get_height()+get_constant("vseparation","PopupMenu");
	Ref<Texture> vec_icon = get_icon("NodeVecSlot","EditorIcons");
	Point2 pos = Point2( shader_graph.node_get_pos_x(p_node_id), shader_graph.node_get_pos_y(p_node_id) )-offset;
	pos+=style->get_offset();
	pos.y+=h;

	if(p_input) {

		pos.y+=p_slot*h;
		pos+=Point2( -vec_icon->get_width()/2.0, h/2.0).floor();
		return pos;
	} else {

		pos.y+=VisualServer::shader_get_input_count( shader_graph.node_get_type(p_node_id ) )*h;
	}

	pos.y+=p_slot*h;
	pos+=Point2( w-style->get_minimum_size().width+vec_icon->get_width()/2.0, h/2.0).floor();

	return pos;

}
Exemple #19
0
Size2 ScrollBar::get_minimum_size() const {

	Ref<Texture> incr = get_icon("increment");
	Ref<Texture> decr = get_icon("decrement");
	Ref<StyleBox> bg = get_stylebox("scroll");
	Size2 minsize;

	if (orientation == VERTICAL) {

		minsize.width = MAX(incr->get_size().width, (bg->get_minimum_size() + bg->get_center_size()).width);
		minsize.height += incr->get_size().height;
		minsize.height += decr->get_size().height;
		minsize.height += bg->get_minimum_size().height;
		minsize.height += get_grabber_min_size();
	}

	if (orientation == HORIZONTAL) {

		minsize.height = MAX(incr->get_size().height, (bg->get_center_size() + bg->get_minimum_size()).height);
		minsize.width += incr->get_size().width;
		minsize.width += decr->get_size().width;
		minsize.width += bg->get_minimum_size().width;
		minsize.width += get_grabber_min_size();
	}

	return minsize;
}
Exemple #20
0
bool Theme::_get(const StringName& p_name,Variant &r_ret) const {

    String sname=p_name;

    if (sname.find("/")!=-1) {

        String type=sname.get_slicec('/',1);
        String node_type=sname.get_slicec('/',0);
        String name=sname.get_slicec('/',2);

        if (type=="icons") {

            r_ret= get_icon(name,node_type);
        } else if (type=="styles") {

            r_ret= get_stylebox(name,node_type);
        } else if (type=="fonts") {

            r_ret= get_font(name,node_type);
        } else if (type=="colors") {

            r_ret= get_color(name,node_type);
        } else if (type=="constants") {

            r_ret= get_constant(name,node_type);
        } else
            return false;

        return true;
    }

    return false;
}
Exemple #21
0
void OptionButton::_notification(int p_what) {

	if (p_what == NOTIFICATION_DRAW) {

		if (!has_icon("arrow"))
			return;

		RID ci = get_canvas_item();
		Ref<Texture> arrow = Control::get_icon("arrow");
		Ref<StyleBox> normal = get_stylebox("normal");
		Color clr = Color(1, 1, 1);
		if (get_constant("modulate_arrow")) {
			switch (get_draw_mode()) {
				case DRAW_PRESSED:
					clr = get_color("font_color_pressed");
					break;
				case DRAW_HOVER:
					clr = get_color("font_color_hover");
					break;
				case DRAW_DISABLED:
					clr = get_color("font_color_disabled");
					break;
				default:
					clr = get_color("font_color");
			}
		}

		Size2 size = get_size();

		Point2 ofs(size.width - arrow->get_width() - get_constant("arrow_margin"), int(Math::abs((size.height - arrow->get_height()) / 2)));
		arrow->draw(ci, ofs, clr);
	}
}
Exemple #22
0
void PopupPanel::_notification(int p_what) {

	if (p_what == NOTIFICATION_DRAW) {

		get_stylebox("panel")->draw(get_canvas_item(), Rect2(Point2(), get_size()));
	}
}
Exemple #23
0
void PopupMenu::_activate_submenu(int over) {

	Node* n = get_node(items[over].submenu);
	ERR_EXPLAIN("item subnode does not exist: "+items[over].submenu);
	ERR_FAIL_COND(!n);
	Popup *pm = n->cast_to<Popup>();
	ERR_EXPLAIN("item subnode is not a Popup: "+items[over].submenu);
	ERR_FAIL_COND(!pm);
	if (pm->is_visible())
		return; //already visible!


	Point2 p = get_global_pos();
	Rect2 pr(p,get_size());
	Ref<StyleBox> style = get_stylebox("panel");
	pm->set_pos(p+Point2(get_size().width,items[over]._ofs_cache-style->get_offset().y));
	pm->popup();

	PopupMenu *pum = pm->cast_to<PopupMenu>();
	if (pum) {

		pr.pos-=pum->get_global_pos();
		pum->clear_autohide_areas();
		pum->add_autohide_area(Rect2(pr.pos.x,pr.pos.y,pr.size.x,items[over]._ofs_cache));
		if (over<items.size()-1) {
			int from = items[over+1]._ofs_cache;
			pum->add_autohide_area(Rect2(pr.pos.x,pr.pos.y+from,pr.size.x,pr.size.y-from));
		}

	}

}
Exemple #24
0
void CallDialog::_notification(int p_what) {
	
	if (p_what==NOTIFICATION_READY) {
		
		call->connect("pressed", this,"_call");
		cancel->connect("pressed", this,"_cancel");
		//filter->get_path()->connect("text_changed", this,"_text_changed");
		_update_method_list();
	}

	if (p_what==NOTIFICATION_EXIT_TREE) {

		call->disconnect("pressed", this,"_call");
		cancel->disconnect("pressed", this,"_cancel");

		//filter->get_path()->connect("text_changed", this,"_text_changed");
		_update_method_list();
	}

	if (p_what==NOTIFICATION_DRAW) {
		
		RID ci = get_canvas_item();
		get_stylebox("panel","PopupMenu")->draw(ci,Rect2(Point2(),get_size()));		
	}	
}
Exemple #25
0
void WindowDialog::_notification(int p_what) {

	switch(p_what) {

		case NOTIFICATION_DRAW: {

			RID ci = get_canvas_item();
			Size2 s = get_size();
			Ref<StyleBox> st = get_stylebox("panel","WindowDialog");
			st->draw(ci,Rect2(Point2(),s));
			int th = get_constant("title_height","WindowDialog");
			Color tc = get_color("title_color","WindowDialog");
			Ref<Font> font = get_font("title_font","WindowDialog");
			int ofs = (s.width-font->get_string_size(title).width)/2;
			//int ofs = st->get_margin(MARGIN_LEFT);
			draw_string(font,Point2(ofs,-th+font->get_ascent()),title,tc,s.width - st->get_minimum_size().width);


		} break;
		case NOTIFICATION_THEME_CHANGED:
		case NOTIFICATION_ENTER_TREE: {

			close_button->set_normal_texture( get_icon("close","WindowDialog"));
			close_button->set_pressed_texture( get_icon("close","WindowDialog"));
			close_button->set_hover_texture( get_icon("close_hilite","WindowDialog"));
			close_button->set_anchor(MARGIN_LEFT,ANCHOR_END);
			close_button->set_begin( Point2( get_constant("close_h_ofs","WindowDialog"), -get_constant("close_v_ofs","WindowDialog") ));

		} break;
	}

}
void EditorAssetLibrary::_notification(int p_what) {

	switch (p_what) {
		case NOTIFICATION_READY: {

			error_tr->set_texture(get_icon("Error", "EditorIcons"));
			reverse->set_icon(get_icon("Sort", "EditorIcons"));

			error_label->raise();
		} break;

		case NOTIFICATION_VISIBILITY_CHANGED: {

			if (is_visible()) {
				_repository_changed(0); // Update when shown for the first time
			}
		} break;

		case NOTIFICATION_PROCESS: {

			HTTPClient::Status s = request->get_http_client_status();
			bool visible = s != HTTPClient::STATUS_DISCONNECTED;

			if (visible != load_status->is_visible()) {
				load_status->set_visible(visible);
			}

			if (visible) {
				switch (s) {

					case HTTPClient::STATUS_RESOLVING: {
						load_status->set_value(0.1);
					} break;
					case HTTPClient::STATUS_CONNECTING: {
						load_status->set_value(0.2);
					} break;
					case HTTPClient::STATUS_REQUESTING: {
						load_status->set_value(0.3);
					} break;
					case HTTPClient::STATUS_BODY: {
						load_status->set_value(0.4);
					} break;
					default: {}
				}
			}

			bool no_downloads = downloads_hb->get_child_count() == 0;
			if (no_downloads == downloads_scroll->is_visible()) {
				downloads_scroll->set_visible(!no_downloads);
			}

		} break;
		case NOTIFICATION_THEME_CHANGED: {

			library_scroll_bg->add_style_override("panel", get_stylebox("bg", "Tree"));
			error_tr->set_texture(get_icon("Error", "EditorIcons"));
			reverse->set_icon(get_icon("Sort", "EditorIcons"));
		} break;
	}
}
Exemple #27
0
void OutputStrings::update_scrollbars() {

	Size2 size = get_size();
	Size2 hmin = h_scroll->get_combined_minimum_size();
	Size2 vmin = v_scroll->get_combined_minimum_size();

	v_scroll->set_anchor( MARGIN_LEFT, ANCHOR_END );
	v_scroll->set_anchor( MARGIN_RIGHT, ANCHOR_END );
	v_scroll->set_anchor( MARGIN_BOTTOM, ANCHOR_END );

	v_scroll->set_begin( Point2(vmin.width, 0) );
	v_scroll->set_end( Point2(0,0 ) );

	h_scroll->set_anchor( MARGIN_RIGHT, ANCHOR_END );
	h_scroll->set_anchor( MARGIN_TOP, ANCHOR_END );
	h_scroll->set_anchor( MARGIN_BOTTOM, ANCHOR_END );

	h_scroll->set_begin( Point2( 0, hmin.y) );
	h_scroll->set_end( Point2(vmin.x,  0) );

	margin.y=hmin.y;
	margin.x=vmin.x;

	Ref<StyleBox> tree_st = get_stylebox("bg","Tree");
	int page = ((size_height-(int)margin.y-tree_st->get_margin(MARGIN_TOP)) / font_height);
	v_scroll->set_page(page);

}
Exemple #28
0
int ItemList::get_item_at_pos(const Point2& p_pos) const {

	Vector2 pos=p_pos;
	Ref<StyleBox> bg = get_stylebox("bg");
	pos-=bg->get_offset();
	pos.y+=scroll_bar->get_val();

	int closest = -1;
	int closest_dist=0x7FFFFFFF;

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

		Rect2 rc = items[i].rect_cache;
		if (i%current_columns==current_columns-1) {
			rc.size.width=get_size().width; //not right but works
		}

		if (rc.has_point(pos)) {
			closest=i;
			break;
		}

		float dist = rc.distance_to(pos);
		if (dist<closest_dist) {
			closest=i;
			closest_dist=dist;
		}
	}

	return closest;
}
Exemple #29
0
void CheckButton::_notification(int p_what) {

	if (p_what == NOTIFICATION_THEME_CHANGED) {

		_set_internal_margin(MARGIN_RIGHT, get_icon_size().width);
	} else if (p_what == NOTIFICATION_DRAW) {

		RID ci = get_canvas_item();

		Ref<Texture> on = Control::get_icon("on");
		Ref<Texture> off = Control::get_icon("off");

		Ref<StyleBox> sb = get_stylebox("normal");
		Vector2 ofs;
		Size2 tex_size = get_icon_size();

		ofs.x = get_size().width - (tex_size.width + sb->get_margin(MARGIN_RIGHT));
		ofs.y = (get_size().height - tex_size.height) / 2;

		if (is_pressed())
			on->draw(ci, ofs);
		else
			off->draw(ci, ofs);
	}
}
void PanelContainer::_notification(int p_what) {

	if (p_what==NOTIFICATION_DRAW) {

		RID ci = get_canvas_item();
		Ref<StyleBox> style;

		if (has_stylebox("panel"))
			style=get_stylebox("panel");
		else
			style=get_stylebox("panel","PanelContainer");

		style->draw( ci, Rect2( Point2(), get_size() ) );

	}

	if (p_what==NOTIFICATION_SORT_CHILDREN) {

		Ref<StyleBox> style;

		if (has_stylebox("panel"))
			style=get_stylebox("panel");
		else
			style=get_stylebox("panel","PanelContainer");

		Size2 size = get_size();
		Point2 ofs;
		if (style.is_valid()) {
			size-=style->get_minimum_size();
			ofs+=style->get_offset();
		}



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

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

			fit_child_in_rect(c,Rect2(ofs,size));

		}
	}
}