Beispiel #1
0
Options::Options(clan::Canvas &canvas) : clan::TextureWindow(canvas)
{
	// Note, when changing these, remember to change the popup menu defaults
	num_particles = 64;
	point_size = 64;

	int slider_xpos = 450;
	int slider_label_xpos = slider_xpos + 200;
	int slider_ypos = 100;
	int slider_gap = 24;
	slider_num_particles = create_slider(slider_xpos, slider_ypos);
	slider_num_particles->set_max_position(1000);
	slider_num_particles->set_position(num_particles);
	slider_num_particles->func_value_changed() = bind_member(this, &Options::slider_num_particles_changed);
	label_num_particles = create_slider_label(slider_label_xpos, slider_ypos);
	slider_ypos += slider_gap;

	slider_point_size = create_slider(slider_xpos, slider_ypos);
	slider_point_size->set_min_position(1);
	slider_point_size->set_max_position(256);
	slider_point_size->set_position(point_size);
	slider_point_size->func_value_changed() = bind_member(this, &Options::slider_point_size_changed);
	label_point_size = create_slider_label(slider_label_xpos, slider_ypos);
	slider_ypos += slider_gap;

	update_all_slider_text();

}
Beispiel #2
0
Options::Options(clan::GUIManager &gui, clan::Rect gui_position) : clan::GUIComponent(&gui, clan::GUITopLevelDescription("Options", gui_position, false))
{
	// Note, when changing these, remember to change the popup menu defaults
	compare_function = clan::compare_greater;
	stencil_pass = clan::stencil_keep;
	stencil_fail = clan::stencil_incr;

	num_balls = 9;
	is_moveballs_set = true;
	is_circle_set = true;
	compare_reference = 1;

	int slider_xpos = 400;
	int slider_ypos = 250;
	int slider_gap = 24;
	slider_numballs = create_slider(slider_xpos, slider_ypos); slider_ypos += slider_gap;
	slider_ypos += 8;
	slider_numballs->set_max(9);
	slider_numballs->set_position(num_balls);
	slider_numballs->func_value_changed() = bind_member(this, &Options::slider_numballs_changed);
	slider_ypos += 8;
	label_numballs = create_slider_label(slider_numballs);

	slider_ypos += 8;
	slider_compare_reference = create_slider(slider_xpos, slider_ypos); slider_ypos += slider_gap;
	slider_ypos += 8;
	slider_compare_reference->set_max(16);
	slider_compare_reference->set_position(compare_reference);
	slider_compare_reference->func_value_changed() = bind_member(this, &Options::slider_compare_reference_changed);
	slider_ypos += 8;
	label_compare_reference = create_slider_label(slider_compare_reference);

	int checkbox_xpos = slider_xpos;
	int checkbox_ypos = slider_ypos;
	int checkbox_gap = 24;
	checkbox_moveballs = create_checkbox(checkbox_xpos, checkbox_ypos, "Moving Balls", is_moveballs_set);
	checkbox_moveballs->func_state_changed() = bind_member(this, &Options::checkbox_moveballs_changed);
	checkbox_ypos += checkbox_gap + 8;
	checkbox_circle = create_checkbox(checkbox_xpos, checkbox_ypos, "Draw Stencil Circle (Without selected stencil options)", is_circle_set);
	checkbox_circle->func_state_changed() = bind_member(this, &Options::checkbox_circle_changed);
	checkbox_ypos += checkbox_gap + 8;

	make_compare_menu(combo_compare_menu);
	combo_comparefunc = create_compare_combo_box(600, 40, combo_compare_menu, 3);
	label_comparefunc = create_combobox_label(combo_comparefunc, "Compare Function");

	make_passfail_menu(combo_pass_menu);
	combo_pass = create_passfail_combo_box(600, 80, combo_pass_menu, 0);
	label_pass = create_combobox_label(combo_pass, "Pass Operation");

	make_passfail_menu(combo_fail_menu);
	combo_fail = create_passfail_combo_box(600, 120, combo_fail_menu, 3);
	label_fail = create_combobox_label(combo_fail, "Fail Operation");

	update_all_slider_text();

	func_render() = bind_member(this, &Options::on_render);
}
Beispiel #3
0
void Window_Impl::init(Window *this_component)
{
	window = this_component;

	this_component->func_process_message() = bind_member(this, &Window_Impl::on_process_message);
	this_component->func_render() = bind_member(this, &Window_Impl::on_render);
	
	create_parts();
}
Beispiel #4
0
ToolTip::ToolTip(GUIManager manager)
: GUIComponent(&manager, ToolTip_Impl::create_description(), CssStr::ToolTip::type_name), impl(std::make_shared<ToolTip_Impl>())
{
	impl->tooltip = this;

	func_process_message() = bind_member(impl.get(), &ToolTip_Impl::on_process_message);
	func_render() = bind_member(impl.get(), &ToolTip_Impl::on_render);

	impl->timer_show_delayed.func_expired() = bind_member(impl.get(), &ToolTip_Impl::on_show_delayed);
	impl->sc.connect(get_gui_manager().sig_filter_message(), bind_member(impl.get(), &ToolTip_Impl::on_filter_message));
}
Beispiel #5
0
ProgressBar::ProgressBar(GUIComponent *parent)
: GUIComponent(parent, CssStr::ProgressBar::type_name), impl(std::make_shared<ProgressBar_Impl>())
{
	impl->progressbar = this;
	impl->part_progress = GUIThemePart(this, "progress");
	impl->part_chunk = GUIThemePart(this, "chunk");

	impl->progressbar->set_pseudo_class(CssStr::normal, true);

	func_process_message() = bind_member(impl.get(), &ProgressBar_Impl::on_process_message);
	func_render() = bind_member(impl.get(), &ProgressBar_Impl::on_render);
}
Beispiel #6
0
Options::Options(clan::Canvas &canvas) : clan::TextureWindow(canvas)
{
	// Note, when changing these, remember to change the popup menu defaults
	current_mapmode = clan::map_2d_upper_left;
	num_balls = 3;
	grid_angle = 0;
	is_moveballs_set = true;

	int slider_xpos = 450;
	int slider_label_xpos = slider_xpos + 200;
	int slider_ypos = 100;
	int slider_gap = 24;
	slider_numballs = create_slider(slider_xpos, slider_ypos);
	slider_numballs->set_max_position(9);
	slider_numballs->set_position(num_balls);
	slider_numballs->func_value_changed() = bind_member(this, &Options::slider_numballs_changed);
	label_numballs = create_slider_label(slider_label_xpos, slider_ypos);
	slider_ypos += slider_gap;

	slider_grid_angle = create_slider(slider_xpos, slider_ypos);
	slider_grid_angle->set_min_position(-45);
	slider_grid_angle->set_max_position(90);
	slider_grid_angle->set_position(grid_angle);
	slider_grid_angle->func_value_changed() = bind_member(this, &Options::slider_grid_angle_changed);
	label_grid_angle = create_slider_label(slider_label_xpos, slider_ypos);
	slider_ypos += slider_gap;

	int checkbox_xpos = slider_xpos;
	int checkbox_ypos = slider_ypos;
	int checkbox_gap = 24;
	checkbox_moveballs = create_checkbox(checkbox_xpos, checkbox_ypos, "Moving Balls", is_moveballs_set);
	checkbox_moveballs->func_state_changed() = bind_member(this, &Options::checkbox_moveballs_changed);

	listbox_mapmode = Theme::create_listbox();
	listbox_mapmode->style()->set("position: absolute; left:%1px; top:%2px; width:%3px; height:auto;", checkbox_xpos, 10, 180);

	listbox_mapmode->set_items<std::string>( { "2d Upper Left", "2d Lower Left", "User Projection" }, Theme::create_listbox_label);

	listbox_mapmode->func_selection_changed() = bind_member(this, &Options::on_mapmode_selected);
	listbox_mapmode->set_selected_item(0);
	add_subview(listbox_mapmode);

	label_mapmode = Theme::create_label(true);
	add_subview(label_mapmode);
	label_mapmode->style()->set("position: absolute; left:%1px; top:%2px", slider_label_xpos, 10);
	label_mapmode->set_text("Map Mode");

	update_all_slider_text();
}
	OpenGLWindowProvider::OpenGLWindowProvider(OpenGLContextDescription &opengl_desc)
		: win32_window(),
		opengl_context(0), device_context(0), shadow_hwnd(0), shadow_window(false), dwm_layered(false), site(0), fullscreen(false),
		wglSwapIntervalEXT(0), swap_interval(-1), opengl_desc(opengl_desc), using_gl3(true), double_buffered(true)
	{
		win32_window.func_on_resized() = bind_member(this, &OpenGLWindowProvider::on_window_resized);
	}
	Resource<Font> XMLDisplayCache::get_font(Canvas &canvas, const std::string &family_name, const FontDescription &desc)
	{
		auto it = fonts.find(family_name);
		if (it != fonts.end())
			return Font(it->second, desc);

		bool is_resource_font = false;

		if (doc.resource_exists(family_name))
		{
			XMLResourceNode resource = doc.get_resource(family_name);
			if (resource.get_element().get_tag_name() == "font")
			{
				is_resource_font = true;
			}
		}

		Font font;

		FontFamily font_family(family_name);
		fonts[family_name] = font_family;

		if (is_resource_font)
		{
			font = Font::load(canvas, family_name, desc, font_family, doc, bind_member(this, &XMLDisplayCache::get_sprite));
		}
		else
		{
			font = Font(font_family, desc);
		}

		return font;
	}
Beispiel #9
0
GUI_Layered::GUI_Layered(GUI *gui) : gui(gui), canvas(gui->get_app()->get_canvas()), wm(*gui->get_app()->get_window())
{
	gui_manager = clan::GUIManager(wm, gui->get_theme_location());

	wm.func_input_intercept() = bind_member(this, &GUI_Layered::wm_input_intercept);

	// Use a texture group to store all the gui textures
	clan::TextureGroup texture_group(clan::Size(1024, 1024));
	wm.set_texture_group(texture_group);	// Note: This line is optional

	setup_shader();

	wobble_offset = 0.0f;
	last_time = clan::System::get_time();
	lens_zoom = 3.2f;
	lens_near = 0.1f;
	lens_far = 10000.0f;
	lens_aspect = 1.0f;

	// Note, clan::GUIManager deletes these automatically, after GUI_Direct has gone out of scope in the clan::GUIManager destructor
	lineedit = new LineEdit(gui_manager);
	slider = new Slider(gui_manager);
	radiobutton = new RadioButton(gui_manager);
	scrollbar = new ScrollBar(gui_manager);
	menubar = new MenuBar(gui_manager, gui->get_resources_internal());
	spin = new Spin(gui_manager);
	combobox = new ComboBox(gui_manager);

	panel3d = new Panel3D(gui_manager);

}
Beispiel #10
0
Theme::Theme(clan::GUIManager &manager, gui_theme default_theme) : current_theme(default_theme),
	clan::Window(&manager, clan::GUITopLevelDescription("Window Theme", clan::Rect(256*3 + 32, 256 + 180 + 24, clan::Size(256, 180)), false))
{

	func_close() = bind_member(this, &Theme::on_close);

	clan::Rect client_area = get_client_area();

	groupbox = new clan::GroupBox(this);
	groupbox->set_geometry(clan::Rect(client_area.left + 5, client_area.top + 5, client_area.right - 5, client_area.bottom - 5));

	int xoffset = client_area.left + 100;
	int yoffset = client_area.top + 4;
	int ygap = 20;

	radiobutton_aero = new clan::RadioButton(this);
	radiobutton_aero->set_geometry(clan::Rect(xoffset, yoffset , clan::Size(96, 24)));
	radiobutton_aero->set_text("Aero");
	radiobutton_aero->set_selected(default_theme == theme_aero);
	radiobutton_aero->set_group_name("Theme");
	radiobutton_aero->func_selected() = [=](){on_theme_selected(radiobutton_aero);};
	yoffset += ygap;

	radiobutton_aero_packed = new clan::RadioButton(this);
	radiobutton_aero_packed->set_geometry(clan::Rect(xoffset, yoffset , clan::Size(96, 24)));
	radiobutton_aero_packed->set_text("Aero Packed");
	radiobutton_aero_packed->set_selected(default_theme == theme_aero_packed);
	radiobutton_aero_packed->set_group_name("Theme");
	radiobutton_aero_packed->func_selected() = [=](){on_theme_selected(radiobutton_aero_packed); };
	yoffset += ygap;

	radiobutton_basic = new clan::RadioButton(this);
	radiobutton_basic->set_geometry(clan::Rect(xoffset, yoffset , clan::Size(96, 24)));
	radiobutton_basic->set_text("Basic");
	radiobutton_basic->set_selected(default_theme == theme_basic);
	radiobutton_basic->set_group_name("Theme");
	radiobutton_basic->func_selected() = [=](){on_theme_selected(radiobutton_basic); };
	yoffset += ygap;

	radiobutton_basic_packed = new clan::RadioButton(this);
	radiobutton_basic_packed->set_geometry(clan::Rect(xoffset, yoffset , clan::Size(96, 24)));
	radiobutton_basic_packed->set_text("Basic Packed");
	radiobutton_basic_packed->set_selected(default_theme == theme_basic_packed);
	radiobutton_basic_packed->set_group_name("Theme");
	radiobutton_basic_packed->func_selected() = [=](){on_theme_selected(radiobutton_basic_packed); };
	yoffset += ygap;

	if (!clan::FileHelp::file_exists("../../../Resources/GUIThemeAero/theme.css"))
	{
		radiobutton_aero->set_enabled(false);
		radiobutton_aero_packed->set_enabled(false);
		radiobutton_basic->set_selected(true);

	}


}
Beispiel #11
0
ColorWheel::ColorWheel(clan::Canvas &canvas, clan::GUIManager &gui, clan::Rect gui_position) : clan::GUIComponent(&gui, clan::GUITopLevelDescription("ColorWheel", gui_position, false))
{
    clan::CSSValueBackgroundColor color;
    color.color = clan::Colorf::black;
    set_style(color, true);	// We want a black background

    saturation_outer = 1.0f;
    saturation_inner = 0.0f;
    value_outer = 1.0f;
    value_inner = 0.0f;
    is_hsl = false;

    slider_saturation_outer = create_slider(16, 16);
    slider_saturation_inner = create_slider(16, 48);
    slider_value_outer = create_slider(16, 80);
    slider_value_inner = create_slider(16, 112);

    slider_saturation_outer->set_position(slider_saturation_outer->get_max());
    slider_saturation_inner->set_position(0);
    slider_value_outer->set_position(slider_value_outer->get_max());
    slider_value_inner->set_position(0);

    radiobutton_HSV = new clan::RadioButton(this);
    radiobutton_HSV->set_geometry(clan::Rect(16, 0 , clan::Size(64, 16)));
    radiobutton_HSV->set_text("         ");		// ** I'm got lazy to set the text color to white, so I draw it elsewhere
    radiobutton_HSV->set_selected(true);
    radiobutton_HSV->set_group_name("Main Group");
    radiobutton_HSV->func_selected() = bind_member(this, &ColorWheel::on_selected, radiobutton_HSV);

    radiobutton_HSL = new clan::RadioButton(this);
    radiobutton_HSL->set_geometry(clan::Rect(100, 0, clan::Size(64, 16)));
    radiobutton_HSL->set_text("         ");
    radiobutton_HSL->set_group_name("Main Group");
    radiobutton_HSL->func_selected() = bind_member(this, &ColorWheel::on_selected, radiobutton_HSL);

    radiobutton_HSV->set_selected(true);

    func_render() = bind_member(this, &ColorWheel::on_render);

    font = clan::Font(canvas, "tahoma", 16);

}
DlgAddNewProject::DlgAddNewProject(GUIComponent *owner, SolutionModel &model)
: GUIComponent(owner, get_toplevel_description()), model(model)
{
	label_name = new Label(this);
	lineedit_name = new LineEdit(this);
	label_location = new Label(this);
	lineedit_location = new LineEdit(this);
	button_browse_location = new PushButton(this);
	label_solution_name = new Label(this);
	lineedit_solution_name = new LineEdit(this);
	check_create_solution_directory = new CheckBox(this);
	button_ok = new PushButton(this);
	button_cancel = new PushButton(this);

	label_name->set_text("Name:");
	label_location->set_text("Location:");
	button_browse_location->set_text("Browse...");
	label_solution_name->set_text("Solution name:");
	check_create_solution_directory->set_text("Create directory for solution");
	button_ok->set_text("OK");
	button_ok->set_default(true);
	button_cancel->set_text("Cancel");
	button_cancel->set_cancel(true);

	func_resized() = bind_member(this, &DlgAddNewProject::on_resized);
	func_close() = bind_member(this, &DlgAddNewProject::on_close);
	button_ok->func_clicked() = bind_member(this, &DlgAddNewProject::on_button_ok_clicked);
	button_cancel->func_clicked() = bind_member(this, &DlgAddNewProject::on_button_cancel_clicked);
	button_browse_location->func_clicked() = bind_member(this, &DlgAddNewProject::on_button_browse_location_clicked);
	check_create_solution_directory->func_state_changed() = bind_member(this, &DlgAddNewProject::on_check_create_solution_directory_state_changed);

	on_check_create_solution_directory_state_changed();
	on_resized();
	lineedit_name->set_focus();
}
Beispiel #13
0
Options::Options(clan::Canvas &canvas) : clan::TextureWindow(canvas)
{
	int slider_xpos = 400;
	int slider_label_xpos = slider_xpos + 200;
	int slider_ypos = 200;
	int slider_gap = 32;
	slider_outline_size = create_slider(slider_xpos, slider_ypos);
	slider_outline_size->set_max_position(32);
	slider_outline_size->set_position(outline_size);
	slider_outline_size->func_value_changed() = bind_member(this, &Options::slider_outline_size_changed);
	label_outline_size = create_slider_label(slider_label_xpos, slider_ypos);
	slider_ypos += slider_gap;

	slider_group_size = create_slider(slider_xpos, slider_ypos);
	slider_group_size->set_max_position(1024);
	slider_group_size->set_position(group_size);
	slider_group_size->func_value_changed() = bind_member(this, &Options::slider_group_size_changed);
	label_group_size = create_slider_label(slider_label_xpos, slider_ypos);
	slider_ypos += slider_gap;

	update_all_slider_text();

}
Beispiel #14
0
void Canvas_Impl::setup(GraphicContext &new_gc)
{
	gc = new_gc;

	if (!current_window.is_null())
	{
		sc.connect(current_window.sig_window_flip(), bind_member(this, &Canvas_Impl::on_window_flip));
	}

	gc_clip_z_range = gc.get_provider()->get_clip_z_range();
	canvas_transform = Mat4f::identity();

	if (gc.get_write_frame_buffer().is_null())	// No framebuffer attached to canvas
	{
		canvas_y_axis = y_axis_top_down;
		sc.connect(gc.get_provider()->sig_window_resized(), bind_member(this, &Canvas_Impl::on_window_resized));
	}
	else
	{
		if (gc.get_texture_image_y_axis() == y_axis_bottom_up)
		{
			canvas_y_axis = y_axis_bottom_up;
		}
		else
		{
			canvas_y_axis = y_axis_top_down;
		}
	}

	update_viewport_size();

	if (batcher.is_null())
	{
		batcher = CanvasBatcher(gc);
	}

}
Beispiel #15
0
void OptionRGB::setup(clan::GUIComponent *base_component, const std::string &name, int xpos, int ypos)
{

	checkbox = new clan::CheckBox(base_component);
	int width = 100;
	int height = 16;
	checkbox->set_geometry(clan::Rect(xpos, ypos , clan::Size(width, height)));
	xpos += width;
	checkbox->set_text(name);
	checkbox->set_checked(false);
	checkbox->func_state_changed() = bind_member(this, &OptionRGB::checkbox_changed);

	int slider_width = 64;
	slider_red = create_slider(base_component, clan::Rect(xpos, ypos, clan::Size(slider_width, 17)));
	xpos += slider_width + 4;
	slider_red->func_value_changed() = bind_member(this, &OptionRGB::slider_red_changed);

	int spin_width = 40;

	spin_red = new clan::Spin(base_component);
	spin_red->set_geometry(clan::Rect(xpos, ypos - 3, clan::Size(spin_width, 21)));
	xpos += spin_width + 4;
	spin_red->set_ranges(0, 255);
	spin_red->func_value_changed() = bind_member(this, &OptionRGB::spin_red_changed);

	slider_green = create_slider(base_component, clan::Rect(xpos, ypos, clan::Size(slider_width, 17)));
	xpos += slider_width + 4;
	slider_green->func_value_changed() = bind_member(this, &OptionRGB::slider_green_changed);

	spin_green = new clan::Spin(base_component);
	spin_green->set_geometry(clan::Rect(xpos, ypos - 3, clan::Size(spin_width, 21)));
	xpos += spin_width + 4;
	spin_green->set_ranges(0, 255);
	spin_green->func_value_changed() = bind_member(this, &OptionRGB::spin_green_changed);

	slider_blue = create_slider(base_component, clan::Rect(xpos, ypos, clan::Size(slider_width, 17)));
	xpos += slider_width + 4;
	slider_blue->func_value_changed() = bind_member(this, &OptionRGB::slider_blue_changed);

	spin_blue = new clan::Spin(base_component);
	spin_blue->set_geometry(clan::Rect(xpos, ypos - 3, clan::Size(spin_width, 21)));
	xpos += spin_width + 4;
	spin_blue->set_ranges(0, 255);
	spin_blue->func_value_changed() = bind_member(this, &OptionRGB::spin_blue_changed);

	slider_red_changed();
	slider_green_changed();
	slider_blue_changed();

	checkbox_changed();
}
Beispiel #16
0
clan::Slider *ColorWheel::create_slider(int xpos, int ypos)
{
    clan::Slider *component = new clan::Slider(this);
    component->set_geometry(clan::Rect(xpos, ypos, clan::Size(256, 17)));
    component->set_vertical(false);
    component->set_horizontal(true);
    component->set_min(0);
    component->set_max(1000);
    component->set_tick_count(100);
    component->set_page_step(100);
    component->set_position(0);
    component->set_lock_to_ticks(false);

    component->func_value_changed() = bind_member(this, &ColorWheel::option_changed);

    return component;

}
Beispiel #17
0
DlgAddNewItem::DlgAddNewItem(GUIComponent *owner, FileItemTypeFactory &factory, const std::string &default_location)
: GUIComponent(owner, get_toplevel_description())
{
	label_name = new Label(this);
	lineedit_name = new LineEdit(this);
	label_location = new Label(this);
	lineedit_location = new LineEdit(this);
	button_browse_location = new PushButton(this);
	button_ok = new PushButton(this);
	button_cancel = new PushButton(this);
	list_items = new ListView(this);
	label_description_header = new Label(this);
	label_description = new Label(this);

	label_name->set_text("Name:");
	label_location->set_text("Location:");
	button_browse_location->set_text("Browse...");
	button_ok->set_text("OK");
	button_ok->set_default(true);
	button_cancel->set_text("Cancel");
	button_cancel->set_cancel(true);
	lineedit_name->set_focus();

	lineedit_name->set_text("New item");
	lineedit_location->set_text(default_location);

	list_items->get_header()->append(list_items->get_header()->create_column("name", "Name")).set_width(110);
	list_items->show_detail_opener(false);
	//	list_items->get_header()->set_visible(false);
	list_items->get_header()->set_class("hidden", true);

	func_resized() = bind_member(this, &DlgAddNewItem::on_resized);
	func_close() = bind_member(this, &DlgAddNewItem::on_close);
	button_ok->func_clicked() = bind_member(this, &DlgAddNewItem::on_button_ok_clicked);
	button_cancel->func_clicked() = bind_member(this, &DlgAddNewItem::on_button_cancel_clicked);
	button_browse_location->func_clicked() = bind_member(this, &DlgAddNewItem::on_button_browse_location_clicked);

	list_items->func_selection_changed() = bind_member(this, &DlgAddNewItem::on_list_items_selection_changed);

	on_resized();

	populate(factory);
}
Beispiel #18
0
ColorWheel::ColorWheel()
{
	add_child(overlay);

	style()->set("position: absolute; left: 0; top: 0; width:400px; height:400px;");

	overlay->saturation_outer->slider->func_value_changed() = bind_member(this, &ColorWheel::option_changed);
	overlay->saturation_inner->slider->func_value_changed() = bind_member(this, &ColorWheel::option_changed);
	overlay->value_outer->slider->func_value_changed() = bind_member(this, &ColorWheel::option_changed);
	overlay->value_inner->slider->func_value_changed() = bind_member(this, &ColorWheel::option_changed);
	overlay->radio_row->radiobutton_HSV->func_selected() = bind_member(this, &ColorWheel::option_changed);
	overlay->radio_row->radiobutton_HSL->func_selected() = bind_member(this, &ColorWheel::option_changed);

	overlay->saturation_outer->slider->set_position(overlay->saturation_outer->slider->max_position());
	overlay->saturation_inner->slider->set_position(0);
	overlay->value_outer->slider->set_position(overlay->value_outer->slider->max_position());
	overlay->value_inner->slider->set_position(0);

	overlay->radio_row->radiobutton_HSV->set_selected(true);
	overlay->radio_row->radiobutton_HSV->set_selected(true);

	update_labels();
}
Beispiel #19
0
App::App()
{
#if defined(WIN32) && !defined(__MINGW32__)
	clan::D3DTarget::set_current();
#else
	clan::OpenGLTarget::set_current();
#endif

	DisplayWindowDescription win_desc;
	win_desc.set_allow_resize(true);
	win_desc.set_title("Font Example Application");
	win_desc.set_size(Size( 1000, 700 ), false);

	window = DisplayWindow(win_desc);
	slots.connect(window.sig_window_close(), this, &App::on_window_close);
	slots.connect(window.get_keyboard().sig_key_up(), this, &App::on_input_up);

	clan::XMLResourceFactory::set_display();
	resources = clan::XMLResourceManager::create(clan::XMLResourceDocument("Resources/resources.xml"));

	canvas = Canvas(window);

	clan::Texture2D gui_texture = clan::Texture2D(canvas, (int)std::round(250 * canvas.get_pixel_ratio()), (int)std::round(500 * canvas.get_pixel_ratio()));
	gui_texture.set_pixel_ratio(canvas.get_pixel_ratio());
	gui_image = clan::Image(gui_texture, gui_texture.get_size());
	clan::FrameBuffer gui_framebuffer = clan::FrameBuffer(canvas);
	gui_framebuffer.attach_color(0, gui_texture);
	gui_canvas = clan::Canvas(canvas, gui_framebuffer);

	clan::FileResourceDocument doc(clan::FileSystem("../../ThemeAero"));
	clan::ResourceManager resources = clan::FileResourceManager::create(doc);
	ui_thread = clan::UIThread(resources);

	root = std::make_shared<clan::TextureWindow>(gui_canvas);

	root->set_window(window);

	root->set_viewport(gui_image.get_size());

	int offset_x = 10;
	int offset_y = 8;
	int width = 220;
	int small_width = 70;
	int height = 20;
	const int gap = 38;

	auto button_class_system = Theme::create_button();
	button_class_system->style()->set("position: absolute; left:%1px; top:%2px; width:%3px; height:auto;", offset_x, offset_y, width);
	button_class_system->func_clicked() = clan::bind_member(this, &App::on_button_clicked_class_system);
	button_class_system->label()->set_text("Class: System");
	root->add_child(button_class_system);
	offset_y += gap;

	auto button_class_sprite = Theme::create_button();
	button_class_sprite->style()->set("position: absolute; left:%1px; top:%2px; width:%3px; height:auto;", offset_x, offset_y, width);
	button_class_sprite->func_clicked() = bind_member(this, &App::on_button_clicked_class_sprite);
	button_class_sprite->label()->set_text("Class: Sprite");
	root->add_child(button_class_sprite);
	offset_y += gap;

	button_typeface_tahoma = Theme::create_button();
	button_typeface_tahoma->style()->set("position: absolute; left:%1px; top:%2px; width:%3px; height:auto;", offset_x, offset_y, width);
	button_typeface_tahoma->func_clicked() = bind_member(this, &App::on_button_clicked_typeface_tahoma);
	button_typeface_tahoma->label()->set_text("Typeface: Tahoma");
	root->add_child(button_typeface_tahoma);
	offset_y += gap;

	button_typeface_sans = Theme::create_button();
	button_typeface_sans->style()->set("position: absolute; left:%1px; top:%2px; width:%3px; height:auto;", offset_x, offset_y, width);
	button_typeface_sans->func_clicked() = bind_member(this, &App::on_button_clicked_typeface_sans);
	button_typeface_sans->label()->set_text("Typeface: Microsoft Sans Serif");
	root->add_child(button_typeface_sans);
	offset_y += gap;

	button_typeface_bitstream = Theme::create_button();
	button_typeface_bitstream->style()->set("position: absolute; left:%1px; top:%2px; width:%3px; height:auto;", offset_x, offset_y, width);
	button_typeface_bitstream->func_clicked() = bind_member(this, &App::on_button_clicked_typeface_bitstream);
	button_typeface_bitstream->label()->set_text("Typeface: Bitstream Vera Sans");
	root->add_child(button_typeface_bitstream);
	offset_y += gap;

	checkbox_italic = Theme::create_checkbox();
	checkbox_italic->style()->set("position: absolute; left:%1px; top:%2px", offset_x, offset_y);
	checkbox_italic->func_state_changed() = bind_member(this, &App::on_checkbox_state_italic);
	root->add_child(checkbox_italic);
	auto label = Theme::create_label();
	label->set_text("Italic");
	label->style()->set("position: absolute; left:%1px; top:%2px", offset_x + 16, offset_y - 3);
	root->add_child(label);

	checkbox_antialias = Theme::create_checkbox();
	checkbox_antialias->set_check(true);
	checkbox_antialias->style()->set("position: absolute; left:%1px; top:%2px", offset_x + 100, offset_y);
	checkbox_antialias->func_state_changed() = bind_member(this, &App::on_checkbox_state_antialias);
	root->add_child(checkbox_antialias);
	label = Theme::create_label();
	label->set_text("Anti Alias");
	label->style()->set("position: absolute; left:%1px; top:%2px", offset_x + 100+ 16, offset_y - 3);
	root->add_child(label);
	offset_y += gap;

	checkbox_subpixel = Theme::create_checkbox();
	checkbox_subpixel->set_check(true);
	checkbox_subpixel->style()->set("position: absolute; left:%1px; top:%2px", offset_x, offset_y);
	checkbox_subpixel->func_state_changed() = bind_member(this, &App::on_checkbox_state_subpixel);
	root->add_child(checkbox_subpixel);
	label = Theme::create_label();
	label->set_text("SubPixel Rendering");
	label->style()->set("position: absolute; left:%1px; top:%2px", offset_x + 16, offset_y - 3);
	root->add_child(label);
	offset_y += gap;

	auto button_weight_light = Theme::create_button();
	button_weight_light->style()->set("position: absolute; left:%1px; top:%2px; width:%3px; height:auto;", offset_x, offset_y, small_width);
	button_weight_light->func_clicked() = bind_member(this, &App::on_button_clicked_weight_light);
	button_weight_light->label()->set_text("Light");
	root->add_child(button_weight_light);
	auto button_weight_normal = Theme::create_button();
	button_weight_normal->style()->set("position: absolute; left:%1px; top:%2px; width:%3px; height:auto;", offset_x + small_width + 5, offset_y, small_width);
	button_weight_normal->func_clicked() = bind_member(this, &App::on_button_clicked_weight_normal);
	button_weight_normal->label()->set_text("Normal");
	root->add_child(button_weight_normal);
	auto button_weight_bold = Theme::create_button();
	button_weight_bold->style()->set("position: absolute; left:%1px; top:%2px; width:%3px; height:auto;", offset_x + (small_width + 5) * 2, offset_y, small_width);
	button_weight_bold->func_clicked() = bind_member(this, &App::on_button_clicked_weight_bold);
	button_weight_bold->label()->set_text("Bold");
	root->add_child(button_weight_bold);
	offset_y += gap;

	auto button_size_16 = Theme::create_button();
	button_size_16->style()->set("position: absolute; left:%1px; top:%2px; width:%3px; height:auto;", offset_x, offset_y, small_width);
	button_size_16->func_clicked() = bind_member(this, &App::on_button_clicked_size_16);
	button_size_16->label()->set_text("Size 16");
	root->add_child(button_size_16);
	auto button_size_32 = Theme::create_button();
	button_size_32->style()->set("position: absolute; left:%1px; top:%2px; width:%3px; height:auto;", offset_x + small_width + 5, offset_y, small_width);
	button_size_32->func_clicked() = bind_member(this, &App::on_button_clicked_size_32);
	button_size_32->label()->set_text("Size 32");
	root->add_child(button_size_32);
	auto button_size_64 = Theme::create_button();
	button_size_64->style()->set("position: absolute; left:%1px; top:%2px; width:%3px; height:auto;", offset_x + (small_width + 5) * 2, offset_y, small_width);
	button_size_64->func_clicked() = bind_member(this, &App::on_button_clicked_size_64);
	button_size_64->label()->set_text("Size 64");
	root->add_child(button_size_64);
	offset_y += gap + 8;

	lineedit_text = std::make_shared<clan::TextFieldView>();
	lineedit_text->style()->set("font: 11px/20px 'Segoe UI'");
	lineedit_text->style()->set("margin: 5px");
	lineedit_text->style()->set("background: #efefef");
	lineedit_text->style()->set("border: 1px solid black");
	lineedit_text->style()->set("border-radius: 3px");
	lineedit_text->style()->set("padding: 2px 5px 2px 5px");
	lineedit_text->style()->set("width: 128px");
	lineedit_text->style()->set("box-shadow: 0 0 5px rgba(100,100,200,0.2)");
	lineedit_text->style()->set("position: absolute; left:%1px; top:%2px; width:%3px; height:auto;", offset_x, offset_y, width);
	font_text = "Ω(The quick brown fox 0123456789)";
	lineedit_text->set_text(font_text);
	slots.connect(lineedit_text->sig_selection_changed(), bind_member(this, &App::on_lineedit_changed));
	root->add_child(lineedit_text);

	last_fps = 0.0f;
	selected_fontclass = font_ttf;
	font_typeface = "Microsoft Sans Serif";
	font_filename = "";
	font_desc.set_height(32);
	font_desc.set_weight(clan::FontWeight::normal);
	select_font();

	small_font = clan::Font("Tahoma", 16);

	premultiply_src_blend = BlendState(canvas, BlendStateDescription::blend(true));

	game_time.reset();
}
Beispiel #20
0
ListView::ListView(clan::GUIManager &manager) :
	clan::Window(&manager, clan::GUITopLevelDescription("List View & Toolbar", clan::Rect(8, 256*1 + 180*1 + 24, clan::Size(256*2, 180*2)), false))
{

	func_close() = bind_member(this, &ListView::on_close);

	clan::Rect client_area = get_client_area();

	clan::Canvas canvas = get_canvas();
	if (clan::FileHelp::file_exists("../../../Resources/GUIThemeLuna/Images/icon_mycomputer.png"))
	{
		sprite_mycomputer = clan::Sprite(canvas, "../../../Resources/GUIThemeLuna/Images/icon_mycomputer.png");
		sprite_folder = clan::Sprite(canvas, "../../../Resources/GUIThemeLuna/Images/icon_folder_32x32.png");
		sprite_overlay = clan::Sprite(canvas, "../../../Resources/GUIThemeLuna/Images/overlay_96x96.png");
	}
	else
	{
		sprite_mycomputer = clan::Sprite(canvas, "../CommonCode/Resources/tux.png");
		sprite_folder = clan::Sprite(canvas, "../CommonCode/Resources/tux.png");
		sprite_overlay = clan::Sprite(canvas, "../CommonCode/Resources/tux.png");
	}

	toolbar = new clan::ToolBar(this);
	toolbar->set_geometry(clan::Rect(client_area.left, client_area.top, clan::Size(32, 180)));
	toolbar->add_item(clan::Sprite(canvas, "../CommonCode/Resources/tux.png"), 0, "Tux1", 0);
	toolbar->add_item(clan::Sprite(canvas, "../CommonCode/Resources/tux.png"), 0, "Tux2", 0);

	listview1 = new clan::ListView(this);
	listview1->set_geometry(clan::Rect(client_area.left + 100, client_area.top + 10, clan::Size(360, 180)));
	listview1->set_display_mode(clan::listview_mode_details);

	listview1->func_selection_changed() = bind_member(this, &ListView::on_selection_changed);
	listview1->func_item_edited() = bind_member(this, &ListView::on_item_edited);
	listview1->func_key_pressed() = bind_member(this, &ListView::on_key_pressed);
	listview1->func_key_released() = bind_member(this, &ListView::on_key_released);
	listview1->func_mouse_right_up() = bind_member(this, &ListView::on_mouse_right_up);
	clan::ListViewItem doc_item = listview1->get_document_item(); 

	clan::ListViewHeader *lv_header = listview1->get_header();  
	lv_header->append(lv_header->create_column("col1_id", "col1")).set_width(130);
	lv_header->append(lv_header->create_column("col2_id", "col2")).set_width(80);
	lv_header->append(lv_header->create_column("col3_id", "col3")).set_width(80);

	clan::ListViewIcon icon;
	icon.set_sprite(sprite_mycomputer, clan::listview_mode_details);
	icon.set_sprite(sprite_folder, clan::listview_mode_icons);
	icon.set_sprite(sprite_folder, clan::listview_mode_thumbnails);

	clan::ListViewIcon olay;
	olay.set_sprite(sprite_overlay, clan::listview_mode_thumbnails);
	olay.set_offset(clan::Point(0, 96-sprite_overlay.get_height()), clan::listview_mode_thumbnails);
	olay.set_scalable(false);

	clan::ListViewIconList ico_list = listview1->get_icon_list();
	ico_list.set_icon(1, icon);
	ico_list.set_icon(1001, olay);

	clan::ListViewItem i1 = listview1->create_item();
	{
		i1.set_column_text("col1_id", "i1");
		i1.set_column_text("col2_id", "col2 text!");
		i1.set_editable(true);
		i1.set_icon(1);
		i1.add_overlay_icon(1001);
		i1.set_open(false);
		doc_item.append_child(i1);

		clan::ListViewItem i1c1 = listview1->create_item();  
		{ 
			i1c1.set_column_text("col1_id", "i1c1");
			i1c1.set_column_text("col2_id", "BOOYAA!");
			i1c1.set_icon(1);
			i1.append_child(i1c1);
		}
	}

	clan::ListViewItem i2 = listview1->create_item();
	{
		i2.set_column_text("col1_id", "i2");
		i2.set_column_text("col2_id", "bar2");
		i2.set_column_text("col3_id", "foobar!");
		i2.set_icon(1);
		i2.set_open(true);

		clan::ListViewItem i2c1 = listview1->create_item();  
		{
			i2c1.set_column_text("col1_id", "i2c1"); 
			i2c1.set_column_text("col2_id", "BOOYAA!");
			i2c1.set_icon(1);
		}
		i2.append_child(i2c1); 

		clan::ListViewItem i2c2 = listview1->create_item();
		{
			i2c2.set_column_text("col1_id", "i2c2");
			i2c2.set_column_text("col2_id", "BOOYAA!");
			i2c2.set_icon(1);
			i2c2.set_open(true); 

			clan::ListViewItem i2c2c1 = listview1->create_item();
			{
				i2c2c1.set_column_text("col1_id", "i2c2c1"); 
				i2c2c1.set_column_text("col2_id", "BOOYAA!");
				i2c2c1.set_icon(1);
			}
			i2c2.append_child(i2c2c1); 
		}
		i2.append_child(i2c2);
	}
	doc_item.append_child(i2);


	for (int j = 0;j < 15; j++)
	{  
		clan::ListViewItem i = listview1->create_item();
		i.set_editable(true);
		i.set_column_text("col1_id", clan::string_format("item %1", j)); 
		i.set_icon(1);       
		if ((j%4) == 0)
		{ 
			i.set_column_text("col3_id", clan::string_format("item %1, col3", j));
		}
		if (( j%2)==0)
		{
			i.set_column_text("col2_id", clan::string_format("item %1, col2", j));
		} 
		doc_item.append_child(i);
	}

	int xoffset = client_area.left + 100;
	int yoffset = client_area.top + 200;
	const int gap = 16;

	info_selection_changed = new Info(this);
	info_selection_changed->set(xoffset, yoffset, "Selection Changed");
	yoffset += gap;

	info_item_edited = new Info(this);
	info_item_edited->set(xoffset, yoffset, "Item Edited");
	yoffset += gap;

	info_key_pressed = new Info(this);
	info_key_pressed->set(xoffset, yoffset, "Key Pressed");
	yoffset += gap;

	info_key_released = new Info(this);
	info_key_released->set(xoffset, yoffset, "Key Released");
	yoffset += gap;

	info_mouse_right_up = new Info(this);
	info_mouse_right_up->set(xoffset, yoffset, "Mouse Right Up");
}
Beispiel #21
0
Options::Options(Canvas &canvas) : TextureWindow(canvas)
{
	root_view()->style()->set("background: rgb(153, 153, 204)");

	auto spacer1 = std::make_shared<View>();
	auto spacer2 = std::make_shared<View>();
	auto spacer3 = std::make_shared<View>();
	spacer1->style()->set("flex: 1 1");
	spacer2->style()->set("flex: 1 1");
	spacer3->style()->set("flex: 1 1");

	add_subview(column1);
	add_subview(column2);
	add_subview(column3);

	column1->add_subview(rotation_y_view);
	column1->add_subview(rotation_x_view);
	column1->add_subview(rotation_z_view);
	column1->add_subview(spacer1);
	column1->add_subview(button_lerp);

	column2->add_subview(quaternion_w_view);
	column2->add_subview(quaternion_i_view);
	column2->add_subview(quaternion_j_view);
	column2->add_subview(quaternion_k_view);
	column2->add_subview(spacer2);
	column2->add_subview(button_slerp);

	column3->add_subview(target_y_view);
	column3->add_subview(target_x_view);
	column3->add_subview(target_z_view);
	column3->add_subview(spacer3);
	column3->add_subview(button_rotate);

	button_lerp_clicked = false;
	button_slerp_clicked = false;
	button_rotate_clicked = false;

	max_angle_value = 360.0f;

	rotation_x = Angle(0.0f, angle_degrees);
	rotation_y = Angle(0.0f, angle_degrees);
	rotation_z = Angle(0.0f, angle_degrees);

	target_x = Angle(0.0f, angle_degrees);
	target_y = Angle(0.0f, angle_degrees);
	target_z = Angle(0.0f, angle_degrees);

	rotation_y_view->slider->func_value_changed() = bind_member(this, &Options::slider_rotation_y_changed);
	rotation_x_view->slider->func_value_changed() = bind_member(this, &Options::slider_rotation_x_changed);
	rotation_z_view->slider->func_value_changed() = bind_member(this, &Options::slider_rotation_z_changed);

	quaternion_w_view->slider->func_value_changed() = bind_member(this, &Options::slider_quaternion_w_changed);
	quaternion_i_view->slider->func_value_changed() = bind_member(this, &Options::slider_quaternion_i_changed);
	quaternion_j_view->slider->func_value_changed() = bind_member(this, &Options::slider_quaternion_j_changed);
	quaternion_k_view->slider->func_value_changed() = bind_member(this, &Options::slider_quaternion_k_changed);

	target_y_view->slider->func_value_changed() = bind_member(this, &Options::slider_target_y_changed);
	target_x_view->slider->func_value_changed() = bind_member(this, &Options::slider_target_x_changed);
	target_z_view->slider->func_value_changed() = bind_member(this, &Options::slider_target_z_changed);

	button_lerp->label()->set_text("Linear Quaternion Interpolation (lerp)");
	button_slerp->label()->set_text("Spherical Linear Interpolation (slerp)");
	button_rotate->label()->set_text("Rotate : q.multiply(target)");

	button_lerp->slots.connect(button_lerp->sig_pointer_press(), bind_member(this, &Options::on_clicked_button_lerp));
	button_slerp->slots.connect(button_slerp->sig_pointer_press(), bind_member(this, &Options::on_clicked_button_slerp));
	button_rotate->slots.connect(button_rotate->sig_pointer_press(), bind_member(this, &Options::on_clicked_button_rotate));

	set_all_sliders();
}
Beispiel #22
0
// The start of the Application
int App::start(const std::vector<std::string> &args)
{
	quit = false;

    clan::SlotContainer cc;
	DisplayWindowDescription win_desc;
	win_desc.set_allow_resize(true);
	win_desc.set_title("Font Example Application");
	win_desc.set_size(Size( 1000, 700 ), false);

	DisplayWindow window(win_desc);
    cc.connect(window.sig_window_close(), std::function<void()>(this, &App::on_window_close));
    cc.connect(window.get_ic().get_keyboard().sig_key_up(), std::function<void(const clan::InputEvent&)>(this, &App::on_input_up));

	resources = clan::XMLResourceManager::create(clan::XMLResourceDocument("Resources/resources.xml"));

	std::string theme;
	if (FileHelp::file_exists("../../../Resources/GUIThemeAero/theme.css"))
		theme = "../../../Resources/GUIThemeAero";
	else if (FileHelp::file_exists("../../../Resources/GUIThemeBasic/theme.css"))
		theme = "../../../Resources/GUIThemeBasic";
	else
		throw Exception("No themes found");

	gui_manager = GUIWindowManagerTexture(window);
	GUIManager gui(gui_manager, theme);

	canvas = Canvas(window);

	GUITopLevelDescription gui_desc;
	gui_desc.set_title("Options");
	gui_desc.set_position(Rect(10, 10, 250, 400), false);
	GUIComponent gui_window(&gui, gui_desc, "window");

	int offset_x = 10;
	int offset_y = 8;
	int width = 200;
	int height = 20;
	const int gap = 26;

	PushButton button_class_system(&gui_window);
	button_class_system.set_geometry(Rect(offset_x, offset_y, offset_x + width, offset_y + height));
	button_class_system.func_clicked() = bind_member(this, &App::on_button_clicked_class_system);
	button_class_system.set_text("Class: System");
	offset_y += gap;

	PushButton button_class_sprite(&gui_window);
	button_class_sprite.set_geometry(Rect(offset_x, offset_y, offset_x + width, offset_y + height));
	button_class_sprite.func_clicked() = bind_member(this, &App::on_button_clicked_class_sprite);
	button_class_sprite.set_text("Class: Sprite");
	offset_y += gap;

	PushButton button_typeface_tahoma(&gui_window);
	button_typeface_tahoma_ptr = &button_typeface_tahoma;
	button_typeface_tahoma.set_geometry(Rect(offset_x, offset_y, offset_x + width, offset_y + height));
	button_typeface_tahoma.func_clicked() = bind_member(this, &App::on_button_clicked_typeface_tahoma);
	button_typeface_tahoma.set_text("Typeface: Tahoma");
	offset_y += gap;

	PushButton button_typeface_sans(&gui_window);
	button_typeface_sans_ptr = &button_typeface_sans;
	button_typeface_sans.set_geometry(Rect(offset_x, offset_y, offset_x + width, offset_y + height));
	button_typeface_sans.func_clicked() = bind_member(this, &App::on_button_clicked_typeface_sans);
	button_typeface_sans.set_text("Typeface: Microsoft Sans Serif");
	offset_y += gap;

	PushButton button_typeface_bitstream(&gui_window);
	button_typeface_bitstream_ptr = &button_typeface_bitstream;
	button_typeface_bitstream.set_geometry(Rect(offset_x, offset_y, offset_x + width, offset_y + height));
	button_typeface_bitstream.func_clicked() = bind_member(this, &App::on_button_clicked_typeface_bitstream);
	button_typeface_bitstream.set_text("Typeface: Bitstream Vera Sans");
	offset_y += gap;

	CheckBox checkbox1(&gui_window);
	checkbox1.set_geometry(Rect(offset_x, offset_y, offset_x + 80, offset_y + height));
	checkbox1.func_state_changed() = bind_member(this, &App::on_checkbox_state_underline);
	checkbox1.set_text("Underline");

	CheckBox checkbox2(&gui_window);
	checkbox2.set_geometry(Rect(offset_x+100, offset_y, offset_x + 180, offset_y + height));
	checkbox2.func_state_changed() = bind_member(this, &App::on_checkbox_state_strikeout);
	checkbox2.set_text("Strikeout");
	offset_y += gap;

	CheckBox checkbox3(&gui_window);
	checkbox3.set_geometry(Rect(offset_x, offset_y, offset_x + 80, offset_y + height));
	checkbox3.func_state_changed() = bind_member(this, &App::on_checkbox_state_italic);
	checkbox3.set_text("Italic");

	CheckBox checkbox4(&gui_window);
	checkbox4.set_checked(true);
	checkbox4.set_geometry(Rect(offset_x+100, offset_y, offset_x + 180, offset_y + height));
	checkbox4.func_state_changed() = bind_member(this, &App::on_checkbox_state_antialias);
	checkbox4.set_text("Anti Alias");
	offset_y += gap;

	CheckBox checkbox5(&gui_window);
	checkbox5.set_checked(true);
	checkbox5.set_geometry(Rect(offset_x, offset_y, offset_x + 120, offset_y + height));
	checkbox5.func_state_changed() = bind_member(this, &App::on_checkbox_state_subpixel);
	checkbox5.set_text("SubPixel Rendering");
	offset_y += gap;

	PushButton button_weight_light(&gui_window);
	button_weight_light.set_geometry(Rect(offset_x, offset_y, offset_x + 60, offset_y + height));
	button_weight_light.func_clicked() = bind_member(this, &App::on_button_clicked_weight_light);
	button_weight_light.set_text("Light");
	PushButton button_weight_normal(&gui_window);
	button_weight_normal.set_geometry(Rect(offset_x+70, offset_y, offset_x + 130, offset_y + height));
	button_weight_normal.func_clicked() = bind_member(this, &App::on_button_clicked_weight_normal);
	button_weight_normal.set_text("Normal");
	PushButton button_weight_bold(&gui_window);
	button_weight_bold.set_geometry(Rect(offset_x+140, offset_y, offset_x + 200, offset_y + height));
	button_weight_bold.func_clicked() = bind_member(this, &App::on_button_clicked_weight_bold);
	button_weight_bold.set_text("Bold");
	offset_y += gap;

	PushButton button_size_16(&gui_window);
	button_size_16.set_geometry(Rect(offset_x, offset_y, offset_x + 60, offset_y + height));
	button_size_16.func_clicked() = bind_member(this, &App::on_button_clicked_size_16);
	button_size_16.set_text("Size 16");
	PushButton button_size_32(&gui_window);
	button_size_32.set_geometry(Rect(offset_x+70, offset_y, offset_x + 130, offset_y + height));
	button_size_32.func_clicked() = bind_member(this, &App::on_button_clicked_size_32);
	button_size_32.set_text("Size 32");
	PushButton button_size_64(&gui_window);
	button_size_64.set_geometry(Rect(offset_x+140, offset_y, offset_x + 200, offset_y + height));
	button_size_64.func_clicked() = bind_member(this, &App::on_button_clicked_size_64);
	button_size_64.set_text("Size 64");
	offset_y += gap;

	font_text = "Ω(The quick brown fox 0123456789)";

	LineEdit lineedit1(&gui_window);
	lineedit_text_ptr = &lineedit1;
	lineedit1.set_geometry(Rect(offset_x, offset_y, offset_x + width, offset_y + 30));
	lineedit1.set_text(font_text); 
	lineedit1.func_after_edit_changed() = bind_member(this, &App::on_lineedit_changed);

	last_fps = 0.0f;
	selected_fontclass = font_ttf;
	font_typeface = "Microsoft Sans Serif";
	font_filename = "";
	font_desc.set_height(32);
	font_desc.set_weight(400);
	select_font();

	small_font = clan::Font(canvas, "Tahoma", 16);

	GameTime game_time;
	while(!quit)
	{
		game_time.update();
		render(window, game_time);
	}

	return 0;
}
Beispiel #23
0
	ProgressBar_Impl()
	: progress_min(0), progress_max(100), step_size(1), position(0), marquee_mode(false),
	  marquee_animation_speed(100), marquee_box_width(10), marquee_position(0), marquee_step_size(2)
	{
		marquee_timer.func_expired() = bind_member(this, &ProgressBar_Impl::on_marquee_progress);
	}
Beispiel #24
0
void App::prepare_gui(GUIComponent &window)
{
	btn_update_soundoutput = PushButton::get_named_item(&window, "btn_update_soundoutput");
	btn_update_soundoutput->func_clicked() = bind_member(this, &App::on_btn_update_soundoutput);
	btn_update_soundoutput->set_enabled(false);

	btn_set_soundoutput_filters = PushButton::get_named_item(&window, "btn_set_soundoutput_filters");
	btn_set_soundoutput_filters->func_clicked() = bind_member(this, &App::on_btn_set_soundoutput_filters);
	btn_set_soundoutput_filters->set_enabled(false);

	btn_play = PushButton::get_named_item(&window, "btn_play");
	btn_play->func_clicked() = bind_member(this, &App::on_btn_play);

	btn_prepare = PushButton::get_named_item(&window, "btn_prepare");
	btn_prepare->func_clicked() = bind_member(this, &App::on_btn_prepare);

	btn_set_fade_filter = PushButton::get_named_item(&window, "btn_set_fade_filter");
	btn_set_fade_filter->func_clicked() = bind_member(this, &App::on_btn_set_fade_filter);
	btn_set_fade_filter->set_enabled(false);

	btn_sess_play = PushButton::get_named_item(&window, "btn_sess_play");
	btn_sess_play->func_clicked() = bind_member(this, &App::on_btn_sess_play);
	btn_sess_play->set_enabled(false);

	btn_sess_stop = PushButton::get_named_item(&window, "btn_sess_stop");
	btn_sess_stop->func_clicked() = bind_member(this, &App::on_btn_sess_stop);
	btn_sess_stop->set_enabled(false);

	btn_sess_destroy = PushButton::get_named_item(&window, "btn_sess_destroy");
	btn_sess_destroy->func_clicked() = bind_member(this, &App::on_btn_sess_destroy);
	btn_sess_destroy->set_enabled(false);

	chk_echo_filter = CheckBox::get_named_item(&window, "chk_echo_filter");
	chk_echo_filter->func_checked() = bind_member(this, &App::on_echo_filter_checked);
	chk_echo_filter->func_unchecked() = bind_member(this, &App::on_echo_filter_unchecked);

	chk_fade_filter = CheckBox::get_named_item(&window, "chk_fade_filter");
	chk_fade_filter->func_checked() = bind_member(this, &App::on_fade_filter_checked);
	chk_fade_filter->func_unchecked() = bind_member(this, &App::on_fade_filter_unchecked);

	chk_inverse_echo = CheckBox::get_named_item(&window, "chk_inverse_echo");
	chk_inverse_echo->func_checked() = bind_member(this, &App::on_inverse_echo_filter_checked);
	chk_inverse_echo->func_unchecked() = bind_member(this, &App::on_inverse_echo_filter_unchecked);

	chk_apply_session = CheckBox::get_named_item(&window, "chk_apply_session");

	chk_looping = CheckBox::get_named_item(&window, "chk_looping");
	chk_looping->set_enabled(false);
	chk_looping->func_checked() = bind_member(this, &App::on_looping_checked);
	chk_looping->func_unchecked() = bind_member(this, &App::on_looping_unchecked);

	cbox_session = ComboBox::get_named_item(&window, "cbox_session");
	cbox_session->set_enabled(false);
	cbox_session->func_item_selected() = bind_member(this, &App::on_cbox_session_selected);

	PopupMenu menu;
	menu.insert_item("Pacman Start Sample(.wav)");
	menu.insert_item("Cheering Sample (.ogg)");

	cbox_sound = ComboBox::get_named_item(&window, "cbox_sound");
	cbox_sound->set_popup_menu(menu);
	cbox_sound->set_selected_item(0);

	spin_output_frequency = set_slide_and_spin(window, "slide_out_mix_freq", "spin_out_mix_freq", 10000, 44100, 60000, true);
	spin_output_latency = set_slide_and_spin(window, "slide_out_mix_latency", "spin_out_mix_latency", 10, 50, 400, true);
	spin_filter_echo_buffer_size = set_slide_and_spin(window, "slide_echo_buffer", "spin_echo_buffer", 1024, 32*1024, 128*1024, false);
	spin_filter_echo_shift_factor = set_slide_and_spin(window, "slide_echo_shift", "spin_echo_shift", 1, 2, 8, false);
	spin_filter_fade_volume = set_slide_and_spin(window, "slide_fade_volume", "spin_fade_volume", 0.0f, 1.0f, 1.0f, false);
	spin_filter_inverse_echo_buffer_size = set_slide_and_spin(window, "slide_inverseecho_buffer", "spin_inverseecho_buffer", 1024, 32*1024, 128*1024, false);
	spin_initial_volume = set_slide_and_spin(window, "slide_initial_volume", "spin_initial_volume", 0.0f, 1.0f, 1.0f, true);
	spin_initial_pan = set_slide_and_spin(window, "slide_initial_pan", "spin_initial_pan", -1.0f, 0.0f, 1.0f, true);
	spin_session_position = set_slide_and_spin(window, "slide_sess_position", "spin_sess_position", 0.0f, 0.0f, 1.0f, false);
	spin_session_frequency = set_slide_and_spin(window, "slide_sess_freq", "spin_sess_freq", 10000, 44100, 60000, false);
	spin_session_volume = set_slide_and_spin(window, "slide_sess_volume", "spin_sess_volume", 0.0f, 1.0f, 1.0f, false);
	spin_session_pan = set_slide_and_spin(window, "slide_sess_pan", "spin_sess_pan", -1.0f, 0.0f, 1.0f, false);
	spin_session_fade_volume = set_slide_and_spin(window, "slide_sess_fade_volume", "spin_sess_fade_volume", 0.0f, 1.0f, 1.0f, false);
	spin_session_fade_duration = set_slide_and_spin(window, "slide_sess_fade_duration", "spin_sess_fade_duration", 1000, 2000, 10000, false);
}
Beispiel #25
0
Win32_App::Win32_App()
{
	SourceDLLName = "Game.dll";
	//GameCode = Win32_LoadGameCode(SourceDLLName);

#ifdef _DEBUG
	// Дебажная консоль
	FileLogger flogger("debug.log");
	log_event("SYSTEM", "Logger initialized");
#endif

	try
	{
		// We support all display targets, in order listed here
#ifdef WIN32
		D3DTarget::enable();
#endif
		OpenGLTarget::enable();
	}
	catch (Exception exception)
	{
		// Create a console window for text-output if not available
		ConsoleWindow console("Console", 80, 160);
		Console::write_line("Exception caught: " + exception.get_message_and_stack_trace());
		console.display_close_message();

		quit = true;
	}

	// TODO: сохранять настройки графики
	fullscreen = 0;
	// TODO: Масштабировать окно
	InitScreenSize = Sizef(1024.0f, 768.0f);
	ScreenSize = InitScreenSize;
	DisplayWindowDescription window_description;
	window_description.set_title("Robot Game");
	window_description.set_size(ScreenSize, true);
	window_description.set_allow_resize(true);
	//window_description.set_type(WindowType::tool);
	window = DisplayWindow(window_description);

	canvas = Canvas(window);

	// Подключим коллбэки на слоты пользовательского ввода
	keyboard = window.get_ic().get_keyboard();
	sc.connect(window.sig_window_close(), bind_member(this, &Win32_App::Win32_OnWindowClose));
	sc.connect(window.get_ic().get_keyboard().sig_key_up(), bind_member(this, &Win32_App::Win32_OnKeyUp));
	sc.connect(window.get_ic().get_keyboard().sig_key_down(), bind_member(this, &Win32_App::Win32_OnKeyDown));
	sc.connect(window.get_ic().get_mouse().sig_key_down(), bind_member(this, &Win32_App::Win32_OnMouseDown));

	// Sound
	SoundOutput sound_output(48000);
/*
	SoundBuffer sbuffer("cheer1.ogg");
	sbuffer.play();
*/


	// Game memory
	LPVOID BaseAddress = 0;
	GameMemory.PermanentStorageSize = Megabytes(256);
	GameMemory.TransientStorageSize = Megabytes(256);
	size_t TotalStorageSize = (size_t)(GameMemory.PermanentStorageSize + GameMemory.TransientStorageSize);
	GameMemory.PermanentStorage = VirtualAlloc(BaseAddress, TotalStorageSize, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE);
	GameMemory.TransientStorage = ((uint8*)GameMemory.PermanentStorage + GameMemory.PermanentStorageSize);

	// Game state
	GameState = (game_state*)GameMemory.PermanentStorage;
	*GameState = {};
	GameState->ScreenSize = ScreenSize;


	// Resources
	//OpenGLTarget::set_current();
	GameState->game_resources = clan::XMLResourceManager::create(clan::XMLResourceDocument("sprites.xml"));

	GameState->LoadGameSpriteFromImage = &LoadGameSpriteFromImage;
	GameState->LoadGameSpriteFromResource = &LoadGameSpriteFromResource;
	GameState->AddGameSpriteFrameFromImage = &AddGameSpriteFrameFromImage;

	// Main display buffers
	//GameState->MainDisplayBuffer = PixelBuffer(1024, 768, TextureFormat::tf_rgba8, GameMemory.TransientStorage);


	// Win32 Timings
	CanSleepSafe = (timeBeginPeriod(1) == TIMERR_NOERROR);
	QueryPerformanceFrequency(&PerfCounterFrequencyQ);
	PerfCounterFrequency = PerfCounterFrequencyQ.QuadPart;

	QueryPerformanceCounter(&LastCounter);

	LastCycleCount = __rdtsc();

	game_time.reset();

	//console.display_close_message();
	//timeEndPeriod(1);
}
Beispiel #26
0
void TestApp::test_timer(void)
{
	Console::write_line(" Header: timer.h");
	Console::write_line("  Class: Timer");

	Console::write_line("   Function: start() (for 1600ms)");
	
	g_TimerValue1 = 0;
	g_TimerValue2 = 0;
	g_TimerValue3 = 0;
	g_TimerValue4 = 0;
	g_TimerValue5 = 0;
	g_TimerValue6 = 0;

	Timer timer_1;
	Timer timer_2;
	Timer timer_3;
	Timer timer_4;
	Timer timer_5;
	Timer timer_6;

	clan::ubyte64 start_time = System::get_time();

	timer_1.func_expired() = bind_member(this, &TestApp::funx_timer_1);
	timer_2.func_expired() = bind_member(this, &TestApp::funx_timer_2);
	timer_3.func_expired() = bind_member(this, &TestApp::funx_timer_3);
	timer_4.func_expired() = bind_member(this, &TestApp::funx_timer_4);
	timer_5.func_expired() = bind_member(this, &TestApp::funx_timer_5);
	timer_6.func_expired() = bind_member(this, &TestApp::funx_timer_6);

	timer_1.start(500, false);
	timer_2.start(1000, false);
	timer_3.start(1500, false);
	timer_4.start(500, true);
	timer_5.start(1000, true);
	timer_6.start(1500, true);

	bool stopped_flag = false;
	while(true)
	{
		clan::ubyte64 time_now = System::get_time();
		int time_diff = time_now - start_time;
		if (time_diff >= 1600) break;

		// Stop timer after 1200ms
		if (time_diff >= 1200)
		{
				if (!stopped_flag)
				{
						timer_3.stop();
						timer_4.stop();
						stopped_flag = true;
				}
		}

		KeepAlive::process();
	}

	if (g_TimerValue1 != 1) fail();
	if (g_TimerValue2 != 1) fail();
	if (g_TimerValue3 != 0) fail();
	if (g_TimerValue4 != 2) fail();
	if (g_TimerValue5 != 1) fail();
	if (g_TimerValue6 != 1) fail();

	Console::write_line("   Function: start() Test adjusting timer after started");

	stopped_flag = false;
	start_time = System::get_time();
	g_TimerValue1 = 0;
	timer_1.start(3000, false);
	while(true)
	{
		clan::ubyte64 time_now = System::get_time();
		int time_diff = time_now - start_time;
		if (time_diff >= 1600) break;

		// Reset timer after 500ms
		if (time_diff >= 500)
		{
				if (!stopped_flag)
				{
						timer_1.start(100, false);
						stopped_flag = true;
				}
		}

		KeepAlive::process();
	}
	if (g_TimerValue1 != 1) fail();

}
Beispiel #27
0
Spin::Spin(clan::GUIManager &manager) :
	clan::Window(&manager, clan::GUITopLevelDescription("Spin", clan::Rect(256*3 + 32, 256 + 16, clan::Size(256, 180)), false))
{

	func_close() = bind_member(this, &Spin::on_close);

	clan::Rect client_area = get_client_area();

	spin1 = new clan::Spin(this);
	spin1->set_geometry(clan::Rect(client_area.left + 11, client_area.top + 10, clan::Size(128, 21)));
	spin1->set_number_of_decimal_places(2);
	spin1->set_value(500);
	spin1->set_step_size(50);
	spin1->set_ranges(200, 2000);
	spin1->set_floating_point_mode(false);
	spin1->func_value_changed() = bind_member(this, &Spin::on_value_changed);

	int xoffset = client_area.left + 16;
	int yoffset = client_area.top + 40;
	const int gap = 16;
	clan::Size label_size(50, 15);

	info_value_changed = new Info(this);
	info_value_changed->set(xoffset, yoffset, "Value Changed");
	yoffset += gap;

	clan::Size lineedit_size(48, 20);
	int lineedit_xpos = client_area.left + 6;
	int label_xpos = client_area.left + 56;
	int lineedit_ypos = client_area.top + 60;
	const int lineedit_gap = 25;

	lineedit_value = new clan::LineEdit(this);
	lineedit_value->set_geometry(clan::Rect(lineedit_xpos, lineedit_ypos, lineedit_size));
	lineedit_value->set_text("500");
	lineedit_value->set_numeric_mode(true);
	lineedit_value->func_enter_pressed() = bind_member(this, &Spin::on_value_enter_pressed);

	lineedit_label_value = new clan::Label(this);
	lineedit_label_value->set_geometry(clan::Rect(label_xpos, lineedit_ypos, label_size));
	lineedit_label_value->set_text("Value");
	lineedit_ypos += lineedit_gap;

	lineedit_decimal_places = new clan::LineEdit(this);
	lineedit_decimal_places->set_geometry(clan::Rect(lineedit_xpos, lineedit_ypos, lineedit_size));
	lineedit_decimal_places->set_text("2");
	lineedit_decimal_places->set_numeric_mode(true, true);
	lineedit_decimal_places->func_enter_pressed() = bind_member(this, &Spin::on_decimal_places_enter_pressed);

	lineedit_label_decimal_places = new clan::Label(this);
	lineedit_label_decimal_places->set_geometry(clan::Rect(label_xpos, lineedit_ypos, label_size));
	lineedit_label_decimal_places->set_text("Decimal Places");
	lineedit_ypos += lineedit_gap;
	lineedit_decimal_places->set_enabled(false);

	lineedit_xpos = client_area.left + 146;
	label_xpos = client_area.left + 196;
	lineedit_ypos = client_area.top + 10;

	lineedit_min = new clan::LineEdit(this);
	lineedit_min->set_geometry(clan::Rect(lineedit_xpos, lineedit_ypos, lineedit_size));
	lineedit_min->set_text("200");
	lineedit_min->set_numeric_mode(true, true);
	lineedit_min->func_enter_pressed() = bind_member(this, &Spin::on_min_enter_pressed);

	lineedit_label_min = new clan::Label(this);
	lineedit_label_min->set_geometry(clan::Rect(label_xpos, lineedit_ypos, label_size));
	lineedit_label_min->set_text("Min");
	lineedit_ypos += lineedit_gap;

	lineedit_max = new clan::LineEdit(this);
	lineedit_max->set_geometry(clan::Rect(lineedit_xpos, lineedit_ypos, lineedit_size));
	lineedit_max->set_text("2000");
	lineedit_max->set_numeric_mode(true, true);
	lineedit_max->func_enter_pressed() = bind_member(this, &Spin::on_max_enter_pressed);

	lineedit_label_max = new clan::Label(this);
	lineedit_label_max->set_geometry(clan::Rect(label_xpos, lineedit_ypos, label_size));
	lineedit_label_max->set_text("Max");
	lineedit_ypos += lineedit_gap;

	lineedit_step = new clan::LineEdit(this);
	lineedit_step->set_geometry(clan::Rect(lineedit_xpos, lineedit_ypos, lineedit_size));
	lineedit_step->set_text("50");
	lineedit_step->set_numeric_mode(true, true);
	lineedit_step->func_enter_pressed() = bind_member(this, &Spin::on_step_enter_pressed);

	lineedit_label_step = new clan::Label(this);
	lineedit_label_step->set_geometry(clan::Rect(label_xpos, lineedit_ypos, label_size));
	lineedit_label_step->set_text("Step");
	lineedit_ypos += lineedit_gap;

	pushbutton_apply = new clan::PushButton(this);
	pushbutton_apply->set_geometry(clan::Rect(lineedit_xpos, lineedit_ypos, clan::Size(48, 20)));
	pushbutton_apply->set_text("Apply");
	pushbutton_apply->func_clicked() = bind_member(this, &Spin::on_apply_clicked);

	xoffset = client_area.left + 1;
	yoffset = client_area.top + 126 - gap;

	checkbox_fp_mode = new clan::CheckBox(this);
	checkbox_fp_mode->set_geometry(clan::Rect(xoffset, yoffset, clan::Size(100, 15)));
	checkbox_fp_mode->func_checked() = bind_member(this, &Spin::on_checked_fp_mode);
	checkbox_fp_mode->func_unchecked() = bind_member(this, &Spin::on_unchecked_fp_mode);
	checkbox_fp_mode->set_text("Floating Point Mode");

	yoffset += gap;

	checkbox_disable = new clan::CheckBox(this);
	checkbox_disable->set_geometry(clan::Rect(xoffset, yoffset, clan::Size(100, 15)));
	checkbox_disable->func_checked() = bind_member(this, &Spin::on_checked_disable);
	checkbox_disable->func_unchecked() = bind_member(this, &Spin::on_unchecked_disable);
	checkbox_disable->set_text("Disable");
}
D3DDisplayWindowProvider::D3DDisplayWindowProvider()
: site(0), use_fake_front_buffer(false), current_interval_setting(1)
{
	window.set_allow_drop_shadow(true);
	window.func_on_resized() = bind_member(this, &D3DDisplayWindowProvider::on_window_resized);
}