Cegui Study Notes 6-use cegui to solve specific problems

Source: Internet
Author: User
Cegui Study Notes 6 --
Use cegui to solve specific problems

This article describes how to implement the following issues:
1. Set the control background to transparent.
2. When d3d9 is used as the rendering layer, tooltip is not working properly (flashing ).
3. Simulate MessageBox.

 

 

1. Set the control background to transparent

There are three ways to solve this problem:

1. Modify the imageset file to provide transparent bitmaps;
Modify the looknfeel file and draw it using a transparent bitmap;
Modify the scheme file and use the new appearance configuration.

2. Write the following code in the program:

D_framewindow-> setproperty ("frameenabled", "false ");
D_framewindow-> setproperty ("backgroundenabled", "false ");

3. Configure the frameenabled and backgroundenabled attributes of the object in layoutedit to false.

 

 

2. When d3d9 is used as the rendering layer, tooltip is not working properly (flashing ).

This problem is caused by a bug, but it is not a problem of cegui itself.

The problematic statement in ceguid3d9baseapplication. cpp:

Guisystem. injecttimepulse (gettickcount ()-d_lasttime );

It is obviously a problematic statement .... In this case, the time passing in the cegui is completely messy... and at least 1000 times faster than the reality. Tooltip is displayed in 7.5 seconds by default, and 7.5 seconds * 000.1 = 7.5ns. Therefore, the display flash.

Change

Unsigned int time_diff = gettickcount ()-d_lasttime;
D_lasttime = gettickcount ();
Guisystem. injecttimepulse (time_diff * 0.001f)

This problem does not occur in the rendering layer using OpenGL or ogre.

 

 

3. Simulate MessageBox

1. Use layoutedit to build a MessageBox, and add the following code to the appropriate position of the program:

Bool handlemessageboxbtnokclicked (const cegui: eventargs & ARGs );
Void cegui_messagebox ();


Bool handlemessageboxbtnokclicked (const cegui: eventargs & ARGs)
...{
Using namespace cegui;
Const incluwevetargs & export Wargs = static_cast <const incluweventargs &> (ARGs );
Export Wargs. Window-> getparent ()-> setmodalstate (false );
Export Wargs. Window-> getparent ()-> setvisible (false );
Export Wargs. Window-> getparent ()-> destroy ();
}

Void cegui_messagebox (const cegui: string & layoutfilename)
...{
Using namespace cegui;
// Read the layout file of MessageBox
Window * msgbox = cegui: windowmanager: getsingleton (). loadwindowlayout (layoutfilename );
// Register the MessageBox button event
Msgbox-> getchild ("frame/OK")-> subscribeevent (window: eventmouseclick, event: subscriber (& handlemessageboxbtnokclicked ));
// Set the MessageBox attribute to the modal window
Msgbox-> setmodalstate (true );
// Display MessageBox
Cegui: System: getsingleton (). getguisheet ()-> addchildwindow (msgbox );
}

Don't worry about deletion. cegui adopts the One-Stop deletion policy, and any destory operations are delayed. You can view the ceguisystem code.

In ms, we generally write mbox code like this:
Int ret = MessageBox ("123", "123", null, mb_okcancel );
If (ret = 6)
{}
Else
{}

Do not implement MessageBox in MS, otherwise it will face a very complicated "re-import" problem.

And because we already know what to do when a button in MessageBox is pressed, we only need to write the logic in advance, then you can register the corresponding Button Object in MessageBox.

 

 

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.