Beispiel #1
0
void Horizontal_paned_view::Render(const Widget& widget) const
{
	const Horizontal_paned& horizontal_paned = dynamic_cast<const Horizontal_paned&>(widget);
	Widget* left = horizontal_paned.Get_left();
	Widget* right = horizontal_paned.Get_right();
	Widget_view* view;
	int clip_x, clip_y, clip_w, clip_h;
	al_get_clipping_rectangle(&clip_x, &clip_y, &clip_w, &clip_h);
	if(left)
	{
		Vector2 p = left->Get_position();
		Vector2 s = left->Get_size();
		al_set_clipping_rectangle(p.x, p.y, s.x, s.y);
		left->Render();
	}
	if(right)
	{
		Vector2 p = right->Get_position();
		Vector2 s = right->Get_size();
		al_set_clipping_rectangle(p.x, p.y, s.x, s.y);
		right->Render();
	}
	al_set_clipping_rectangle(clip_x, clip_y, clip_w, clip_h);

	Vector2 p = widget.Get_position();
	Vector2 s = widget.Get_size();
	float pane = p.x+horizontal_paned.Get_pane_position();
	ALLEGRO_COLOR bg_color = al_map_rgb_f(0.7, 0.7, 0.7);
	ALLEGRO_COLOR edge_color = al_map_rgb_f(0.3, 0.3, 0.3);
	al_draw_filled_rectangle(pane, p.y+1, pane+6, p.y+s.y, bg_color);
	al_draw_rectangle(pane, p.y+1, pane+6, p.y+s.y, edge_color, 0);
	al_draw_line(pane+2, p.y+s.y/2-10, pane+2, p.y+s.y/2+10, edge_color, 0);
	al_draw_line(pane+4, p.y+s.y/2-10, pane+4, p.y+s.y/2+10, edge_color, 0);
}
Beispiel #2
0
void Vertical_paned_view::Render(const Widget& widget) const
{
	const Vertical_paned& vertical_paned = dynamic_cast<const Vertical_paned&>(widget);
	Widget* top = vertical_paned.Get_top();
	Widget* bottom = vertical_paned.Get_bottom();
	Widget_view* view;
	int clip_x, clip_y, clip_w, clip_h;
	al_get_clipping_rectangle(&clip_x, &clip_y, &clip_w, &clip_h);
	if(top)
	{
		Vector2 p = top->Get_position();
		Vector2 s = top->Get_size();
		al_set_clipping_rectangle(p.x, p.y, s.x, s.y);
		top->Render();
	}
	if(bottom)
	{
		Vector2 p = bottom->Get_position();
		Vector2 s = bottom->Get_size();
		al_set_clipping_rectangle(p.x, p.y, s.x, s.y);
		bottom->Render();
	}
	al_set_clipping_rectangle(clip_x, clip_y, clip_w, clip_h);

	Vector2 p = widget.Get_position();
	Vector2 s = widget.Get_size();
	float pane = p.y+vertical_paned.Get_pane_position()+1;
	ALLEGRO_COLOR bg_color = al_map_rgb_f(0.7, 0.7, 0.7);
	ALLEGRO_COLOR edge_color = al_map_rgb_f(0.3, 0.3, 0.3);
	al_draw_filled_rectangle(p.x, pane, p.x+s.x-1, pane+6, bg_color);
	al_draw_rectangle(p.x, pane, p.x+s.x-1, pane+6, edge_color, 0);
	al_draw_line(p.x+s.x/2-10, pane+2, p.x+s.x/2+10, pane+2, edge_color, 0);
	al_draw_line(p.x+s.x/2-10, pane+4, p.x+s.x/2+10, pane+4, edge_color, 0);
}
Beispiel #3
0
void Inputbox_view::Render(const Widget& widget) const
{
	const Inputbox& inputbox = dynamic_cast<const Inputbox&>(widget);

	Vector2 p = widget.Get_position();
	Vector2 s = widget.Get_size();
	ALLEGRO_COLOR text_color = al_map_rgb_f(0, 0, 0);
	ALLEGRO_COLOR bg_color = al_map_rgb_f(1, 1, 1);
	ALLEGRO_COLOR edge_color = al_map_rgb_f(0.5, 0.5, 0.5);

	al_draw_filled_rectangle(p.x, p.y+1, p.x+s.x-1, p.y+s.y, bg_color);
	al_draw_rectangle(p.x, p.y+1, p.x+s.x-1, p.y+s.y, edge_color, 0);

	int y = p.y + 3;
	int x = p.x + 3;
	const Ustring& text = inputbox.Get_text();
	
	if(inputbox.Has_focus())
	{
		int sel_s = inputbox.Get_selection_start();
		int sel_e = inputbox.Get_selection_end();

		int cp_s = font->Get_ustr_width(text.Substring(0, sel_s).Astring());
		int cp_e = font->Get_ustr_width(text.Substring(0, sel_e).Astring());
		int h = al_get_font_line_height(font->Afont());
		if(sel_s != sel_e)
			al_draw_filled_rectangle(x+cp_s-1, y, x+cp_e, y+h, al_map_rgb_f(0.5, 0.5, 1));
		else if(cursor_flash>0)
			al_draw_line(x+cp_e-1, y, x+cp_e, y+h, al_map_rgb_f(0, 0, 0), 0);
	}

	al_draw_ustr(font->Afont(), text_color, x, y, 0, text.Astring());
}
void Horizontal_slider_view::Render(const Widget& widget) const
{
	const Horizontal_slider& horizontal_slider = dynamic_cast<const Horizontal_slider&>(widget);

	Vector2 p = widget.Get_position();
	Vector2 s = widget.Get_size();
	float pane = p.x+horizontal_slider.Get_pane_position();
	int pane_size = horizontal_slider.Get_pane_size();

	ALLEGRO_COLOR bg_color = al_map_rgb_f(0.7, 0.7, 0.7);
	ALLEGRO_COLOR edge_color = al_map_rgb_f(0.3, 0.3, 0.3);

	al_draw_filled_rectangle(pane, p.y+1, pane+pane_size-1, p.y+s.y, bg_color);
	al_draw_rectangle(pane, p.y+1, pane+pane_size-1, p.y+s.y, edge_color, 0);
}
Beispiel #5
0
void Dropdown_menu_view::Render(const Widget& widget) const
{
    const Dropdown_menu& dropdown_menu = dynamic_cast<const Dropdown_menu&>(widget);

    Vector2 p = widget.Get_position();
    Vector2 s = widget.Get_size();
    ALLEGRO_COLOR text_color = al_map_rgb_f(1, 1, 1);
    ALLEGRO_COLOR tri_color = al_map_rgb_f(1, 1, 1);
    ALLEGRO_COLOR edge_color = al_map_rgb_f(0.5, 0.5, 0.5);
    ALLEGRO_COLOR select_color = al_map_rgb_f(0.0, 0, 0.8);

    //const Ustring& text = dropdown_menu.Get_text();
    float h = al_get_font_line_height(font->Afont());

    Menu *child = dynamic_cast<Menu*>(dropdown_menu.Get_child());
    if(child) {
        const Ustring& text = child->Get_option(child->Get_selected_option());
        float text_width = font->Get_ustr_width(text.Astring());
        al_draw_ustr(font->Afont(), text_color, p.x+6+h/2, p.y+3, 0, text.Astring());
    }


    float top = h*0.25;
    float middle = h*0.5;
    float bottom = h*0.75;

    if(dropdown_menu.Is_open())
    {
        al_draw_filled_triangle(p.x+3, p.y+3+middle, p.x+3+middle, p.y+3+middle, p.x+3+top, p.y+3+bottom, tri_color);
        al_draw_triangle       (p.x+3, p.y+3+middle, p.x+3+middle, p.y+3+middle, p.x+3+top, p.y+3+bottom, edge_color, 0);
    }
    else
    {
        al_draw_filled_triangle(p.x+3, p.y+3+top, p.x+3+top, p.y+3+middle, p.x+3, p.y+3+bottom, tri_color);
        al_draw_triangle       (p.x+3, p.y+3+top, p.x+3+top, p.y+3+middle, p.x+3, p.y+3+bottom, edge_color, 0);
    }
}
Beispiel #6
0
void Size_mode_view::Render(const Widget& widget) const
{
	Vector2 p = widget.Get_position();
	Vector2 s = widget.Get_size();
	bool fw = widget.Has_fixed_width();
	bool fh = widget.Has_fixed_height();
	ALLEGRO_COLOR bg_color = al_map_rgb_f(0.5, 0.5, 0.5);
	ALLEGRO_COLOR edge_color = al_map_rgb_f(0.9, 0.0, 0.0);
	ALLEGRO_COLOR text_color = al_map_rgb_f(1, 1, 1);
	al_draw_filled_rectangle(p.x, p.y+1, p.x+s.x-1, p.y+s.y, bg_color);
	al_draw_rectangle(p.x, p.y+1, p.x+s.x-1, p.y+s.y, edge_color, 0);

	int font_h = al_get_font_line_height(font->Afont());
	int y = p.y + (s.y - font_h)/2;
	int x = p.x + s.x/2;
	if(fw && fh)
		al_draw_text(font->Afont(), text_color, x, y, ALLEGRO_ALIGN_CENTRE, "Fixed");
	else if(fh)
		al_draw_text(font->Afont(), text_color, x, y, ALLEGRO_ALIGN_CENTRE, "Dynamic width");
	else if(fw)
		al_draw_text(font->Afont(), text_color, x, y, ALLEGRO_ALIGN_CENTRE, "Dynamic height");
	else
		al_draw_text(font->Afont(), text_color, x, y, ALLEGRO_ALIGN_CENTRE, "Fully dynamic");
}