Cannot center align text

For help with general CEGUI usage:
- Questions about the usage of CEGUI and its features, if not explained in the documentation.
- Problems with the CMAKE configuration or problems occuring during the build process/compilation.
- Errors or unexpected behaviour.

Moderators: CEGUI MVP, CEGUI Team

Blackroot
Just popping in
Just popping in
Posts: 7
Joined: Tue Dec 27, 2016 16:20

Cannot center align text

Postby Blackroot » Tue Dec 27, 2016 16:32

Hello beautiful peoples,

I'm having some trouble center-aligning some text, specifically the property I'm under the impression controls alignment doesn't appear to exist when I alter the property. (The specific widget I'm working on is a TaharezLook titlebar)

I poked at the XML files to try and find the correct property name,

Code: Select all

XML definition:
                <HorzFormat type="RightAligned" />

and also
        <PropertyDefinition name="HorzFormatting" initialValue="CentreAligned" redrawOnWrite="true" type="HorizontalTextFormatting" />
       


However, when I go to set either one of these definitions

Code: Select all

//   CEGUI::Titlebar* titlebar = static_cast<CEGUI::Titlebar*>(m_gui.createWidget("TaharezLook/Titlebar", glm::vec4(0.5f, 0.00f, .5f, .060f), glm::vec4(0), "Main Menu Titlebar"));
   titlebar->setProperty("HorzFormatting", "CentreAligned");
   //OR
   titlebar->setProperty("HorzFormat", "CentreAligned");


I'm being told "There is no property named 'X' in the set. I can't for the life of me figure out what I'm doing wrong, it seems like the property name I'm using must exist if the XML file is using it. I'd greatly appreciate clarification on this one! Cheers!

User avatar
Ident
CEGUI Team
Posts: 1998
Joined: Sat Oct 31, 2009 13:57
Location: Austria

Re: Cannot center align text

Postby Ident » Tue Dec 27, 2016 17:00

Did you debug and look into the property container of the window? What is in it?
CrazyEddie: "I don't like GUIs"

Blackroot
Just popping in
Just popping in
Posts: 7
Joined: Tue Dec 27, 2016 16:20

Re: Cannot center align text

Postby Blackroot » Tue Dec 27, 2016 23:41

Code: Select all

Area
Font
Name
Size
Text
Alpha
MaxSize
MinSize
Visible
Disabled
NamePath
Position
Rotation
LookNFeel
NonClient
AspectMode
AutoWindow
UpdateMode
AlwaysOnTop
AspectRatio
TooltipText
TooltipType
PixelAligned
CaptionColour
InheritsAlpha
AutoRepeatRate
DragDropTarget
MarginProperty
WindowRenderer
AutoRepeatDelay
ClippedByParent
DraggingEnabled
MouseCursorImage
ZOrderingEnabled
DestroyedByParent
RestoreOldCapture
VerticalAlignment
RiseOnClickEnabled
TextParsingEnabled
HorizontalAlignment
InheritsTooltipText
AutoRenderingSurface
WantsMultiClickEvents
MouseAutoRepeatEnabled
MousePassThroughEnabled
DistributeCapturedInputs
MouseInputPropogationEnabled


The only property that struck me was HorizontalAlignment, but that set the window's horizontal alignment. Bollocks!

Any ideas?

YaronCT
CEGUI Team
Posts: 448
Joined: Fri Jun 19, 2015 12:18
Location: Kiryat-Bialik, Israel

Re: Cannot center align text

Postby YaronCT » Wed Dec 28, 2016 07:36

From looking at "TaharezLook.looknfeel" it seems there's no control over the text alignment. However, if u want to add such control, I think it should b easy: look e.g. at how "TaharezLook/Label" is defined in that file, specifically search for ""HorzFormatting".

Blackroot
Just popping in
Just popping in
Posts: 7
Joined: Tue Dec 27, 2016 16:20

Re: Cannot center align text

Postby Blackroot » Wed Dec 28, 2016 23:30

YaronCT wrote:From looking at "TaharezLook.looknfeel" it seems there's no control over the text alignment. However, if u want to add such control, I think it should b easy: look e.g. at how "TaharezLook/Label" is defined in that file, specifically search for ""HorzFormatting".



Ahh! I had thought this was a native property for widgets, guess I was wrong! Simple fix, thanks for the help!

For any curious peoples,

Code: Select all

//Widget header
   <PropertyDefinition name="HorzFormatting" initialValue="CentreAligned" redrawOnWrite="true" type="HorizontalTextFormatting" />
      
        <ImagerySection name="caption">
            <TextComponent>
                <Area>
                    <Dim type="LeftEdge" ><ImageDim name="TaharezLook/NewTitlebarLeft" dimension="Width" /></Dim>
                    <Dim type="Width" ><UnifiedDim scale="1" offset="-75" type="Width" /></Dim>
                </Area>
                <ColourProperty name="CaptionColour" />
                <VertFormat type="CentreAligned" />
      <HorzFormatProperty name="HorzFormatting" />
            </TextComponent>
        </ImagerySection>

User avatar
Ident
CEGUI Team
Posts: 1998
Joined: Sat Oct 31, 2009 13:57
Location: Austria

Re: Cannot center align text

Postby Ident » Wed Dec 28, 2016 23:41

We got a property list for the included skins for each widget, available here: http://static.cegui.org.uk under "Property lists (for LookNFeel skins)"

We should probably also document the native properties better. We had this one in 0.7.X which was quite perfect: http://static.cegui.org.uk/docs/0.7.9/n ... CEGUI.html

The docu has been changed since, as this part has been refactored, and something equally good (or better) has not been put in place yet. Maybe someone skilled enough got an idea how to do it?

The perfect situation would imo be to have an overview for core classes and the falagard classes (in two separate section) , the rest could be similar to the above link.

We should probably autogenerate something like that on each doxy run.
CrazyEddie: "I don't like GUIs"

YaronCT
CEGUI Team
Posts: 448
Joined: Fri Jun 19, 2015 12:18
Location: Kiryat-Bialik, Israel

Re: Cannot center align text

Postby YaronCT » Thu Dec 29, 2016 06:26

@Ident: I think we should make in the official cegui a change similar to what @Blackroot has done (and in other look`n`feel files, if they miss it). What do u think?

User avatar
Ident
CEGUI Team
Posts: 1998
Joined: Sat Oct 31, 2009 13:57
Location: Austria

Re: Cannot center align text

Postby Ident » Thu Dec 29, 2016 09:30

Sure
CrazyEddie: "I don't like GUIs"

YaronCT
CEGUI Team
Posts: 448
Joined: Fri Jun 19, 2015 12:18
Location: Kiryat-Bialik, Israel

Re: Cannot center align text

Postby YaronCT » Sat Dec 31, 2016 11:42

@Ident: I'm gonna keep the default horizontal text alignment as "left" in branches "v0-8" and "v0" in order to maintain behaviour, but change it to "center" in branch "default". Comments?

YaronCT
CEGUI Team
Posts: 448
Joined: Fri Jun 19, 2015 12:18
Location: Kiryat-Bialik, Israel

Re: Cannot center align text

Postby YaronCT » Sat Dec 31, 2016 11:46

@Ident: Actually, I even consider removing the property in branch "default" and make it always centre aligned. Of course, it's still possible to add the property in the look`n`feel file. What do u think?

User avatar
Ident
CEGUI Team
Posts: 1998
Joined: Sat Oct 31, 2009 13:57
Location: Austria

Re: Cannot center align text

Postby Ident » Sat Dec 31, 2016 11:56

YaronCT wrote:@Ident: Actually, I even consider removing the property in branch "default" and make it always centre aligned. Of course, it's still possible to add the property in the look`n`feel file. What do u think?

Can you explain the reasoning behind it? Isn't it good to have the option?
CrazyEddie: "I don't like GUIs"

YaronCT
CEGUI Team
Posts: 448
Joined: Fri Jun 19, 2015 12:18
Location: Kiryat-Bialik, Israel

Re: Cannot center align text

Postby YaronCT » Sat Dec 31, 2016 14:17

@Blackroot: Glad to help, and thanx for helping us catch that issue and improve it in our next release.

If you're interested, feel free to share with us about the project u work on (in the dedicated forum).

@Ident: Sure it's good.. however by that reasoning I guess we could add many other properties in the look`n`feel files. I think properties which r rarely useful shouldn't b added to our distributed look`n`feel files. Now, I ask myself, is left or right alignment useful here? I dunno.. I think titlebars almost always use centre-aligned text, and I think it makes sense to do that. But I could b wrong.

Btw e.g. in "Vanilla.looknfeel" it's always centre aligned (without a property).

YaronCT
CEGUI Team
Posts: 448
Joined: Fri Jun 19, 2015 12:18
Location: Kiryat-Bialik, Israel

Re: Cannot center align text

Postby YaronCT » Fri Jan 06, 2017 15:19

@Ident: Is it possible u missed the fact that my last post was addressing u too?

User avatar
Ident
CEGUI Team
Posts: 1998
Joined: Sat Oct 31, 2009 13:57
Location: Austria

Re: Cannot center align text

Postby Ident » Fri Jan 06, 2017 15:22

Thanks for the reminder.

What about just adding a new property for this to the FalagardTitlebar, then we don't need to do anything in the look n feel files?

Edit: Default alignment? No clue. I would go by what is the most commonly used one for our current widgets.
CrazyEddie: "I don't like GUIs"

YaronCT
CEGUI Team
Posts: 448
Joined: Fri Jun 19, 2015 12:18
Location: Kiryat-Bialik, Israel

Re: Cannot center align text

Postby YaronCT » Fri Jan 06, 2017 15:26

But what I wanna do is the opposite: I think users will rarely want a titlebar that's not center aligned (though I'm not sure about it and would b glad to hear other views). Therefore I'd like to remove it from all look`n`feel files where a titlebar contains a horizontal text alignment property (it's not all of them), and users still wishing to use left or right alignment can add it to the look`n`feel file (which is just a matter of adding 2 or 3 lines).


Return to “Help”

Who is online

Users browsing this forum: No registered users and 27 guests