示例#1
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);

}
示例#2
0
文件: clangl.cpp 项目: sim82/shooter2
	GUI(CL_DisplayWindow * wnd)
	{


		//resources_internal = CL_ResourceManager("../CommonCode/Resources/resources.xml");

		CL_GraphicContext gc = wnd->get_gc();
		fps_font = CL_Font(gc, "Tahoma", 24);







		//std::cout << gui_manager.impl.get() << "\n";
		gui_manager.set_window_manager(wm);

		// Use a texture group to store all the gui textures

		CL_TextureGroup texture_group(CL_Size(1024, 1024));
		wm.set_texture_group(texture_group);    // Note: This line is optional

		resources_gui = CL_ResourceManager(gui->get_resources_location());

		theme.set_resources(resources_gui);
		gui_manager.set_theme(theme);

		gui_manager.set_css_document(gui->get_theme_location());

		// Since this example rebuilds the gui when the theme changes, we have to manually delete the components
		// (We could have instead recreated the CL_GUIManager, so it's destructor deletes them)

		pushbutton.reset(new PushButton(gui->get_gui_manager(), gui->get_resources_internal()));
	}
示例#3
0
GUI_Texture::GUI_Texture(GUI *gui) : gui(gui), window_ptr(gui->get_app()->get_window()), wm(*window_ptr)
{
	CL_GUIManager *gui_manager = &gui->get_gui_manager();

	gui_manager->set_window_manager(wm);

	// Use a texture group to store all the gui textures
	CL_GraphicContext gc = window_ptr->get_gc();
	CL_TextureGroup texture_group(gc, CL_Size(1024, 1024));
	wm.set_texture_group(texture_group);	// Note: This line is optional

	resources_gui = CL_ResourceManager(gui->get_resources_location());

	theme.set_resources(resources_gui);
	gui_manager->set_theme(theme); 

	gui_manager->set_css_document(gui->get_theme_location());

	wm.func_repaint().set(this, &GUI_Texture::gui_repaint);

	pushbutton.reset(new PushButton(gui) );
	lineedit.reset(new LineEdit(gui) );
	checkbox.reset(new CheckBox(gui) );
	slider.reset(new Slider(gui) );
	radiobutton.reset(new RadioButton(gui) );
	scrollbar.reset(new ScrollBar(gui) );
	progressbar.reset(new ProgressBar(gui) );
	tabpage.reset(new TabPage(gui) );
	menubar.reset(new MenuBar(gui) );
	spin.reset(new Spin(gui) );
	combobox.reset(new ComboBox(gui) );
	manager.reset(new Manager(gui) );
	listview.reset(new ListView(gui) );
}
示例#4
0
int ExampleText::start(const std::vector<CL_String> &args)
{ 
	// Create a console window for text-output if not available
	CL_ConsoleWindow console("Console");
	
	quit = false;

	// Set a videomode
	CL_DisplayWindowDescription desc;
	desc.set_allow_resize(false);
	desc.set_title("ClanLib CL_SpanLayout Example");
	desc.set_size(CL_Size(800, 600), true);
	CL_DisplayWindow window(desc);

	// Connect the Window close event
	CL_Slot slot_quit = window.sig_window_close().connect(this, &ExampleText::on_window_close);

	// Connect a keyboard handler to on_key_up()
	CL_Slot slot_keyboard_up = window.get_ic().get_keyboard().sig_key_up().connect(this, &ExampleText::on_keyboard_up);

	CL_GraphicContext gc = window.get_gc();

	CL_TextureGroup texture_group(gc, CL_Size(512, 512));

	CL_FontDescription font_desc;
	font_desc.set_typeface_name("Tahoma");
	font_desc.set_anti_alias(true);
	font_desc.set_height(32);
	CL_Font_System font_normal(gc, font_desc);

	font_desc.set_weight(800);
	font_desc.set_height(40);
	CL_Font_System font_bold(gc, font_desc);

	// Share the font texture
	font_normal.set_texture_group(texture_group);
	font_bold.set_texture_group(texture_group);

	CL_Texture texture_text(gc, text_window_size, text_window_size);
	texture_text.set_wrap_mode(cl_wrap_repeat, cl_wrap_repeat, cl_wrap_repeat);
	texture_text.set_min_filter(cl_filter_linear);
	texture_text.set_mag_filter(cl_filter_linear);

	// Create the framebuffer, and attach the texture text into its color buffer
	CL_FrameBuffer fb_text;
	fb_text = CL_FrameBuffer(gc);
	fb_text.attach_color_buffer(0, texture_text);

	float angle = 0.0f;

	std::vector<CL_SpanLayout> layout;

	// Count number of lines
	int num_lines = 0;
	for (const char **text_ptr = TextToShow; *text_ptr; text_ptr++)
	{
		num_lines++;
	}

	// Extend layout vector
	layout.resize(num_lines);

	int ypos = 60;
	for (int line_count=0; line_count < num_lines; line_count++, ypos += 8)
	{
		layout[line_count] = CL_SpanLayout();

		layout[line_count].set_position(CL_Point(20, ypos));

		layout[line_count].set_align(cl_justify);

		const char *text_ptr = TextToShow[line_count];
		if (text_ptr[0] == '-')
		{
			layout[line_count].add_text(text_ptr, font_normal, CL_Colorf::red);
		}
		else if (strstr(text_ptr, "Clan"))
		{
			layout[line_count].add_text(text_ptr, font_bold, CL_Colorf::yellow);
		}
		else
		{
			layout[line_count].add_text(text_ptr, font_normal, CL_Colorf::yellow);
		}

		layout[line_count].layout(gc, texture_text.get_width() - 60);

		ypos += layout[line_count].get_size().height;

	}

	// Run until someone presses escape
	while (!quit)
	{
		int start_time = CL_System::get_time();

		gc.set_map_mode(CL_MapMode(cl_map_2d_upper_left));

		// Draw a nice blue gradient in the background
		CL_Draw::gradient_fill(gc, window.get_viewport(), CL_Gradient(CL_Colorf::lightblue, CL_Colorf::lightblue, CL_Colorf::darkblue, CL_Colorf::darkblue));

		// Draw the text into the frame buffer
		update_text(gc, fb_text, font_normal, layout);

		angle += 0.5f;
		if (angle >= 360.0f)
			angle -= 360.0f;

		// Draw the text
		draw_text(gc, texture_text, CL_Angle(angle, cl_degrees));

		last_fps = 1000.0f / (CL_System::get_time()-start_time);
		// Flip the display, showing on the screen what we have drawn
		window.flip(1);

		// This call updates input and performs other "housekeeping" call this each frame
		CL_KeepAlive::process();
	}

	return 0;
}