Page 1 of 2

Cannot center align text

Posted: Tue Dec 27, 2016 16:32
by Blackroot
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!

Re: Cannot center align text

Posted: Tue Dec 27, 2016 17:00
by Ident
Did you debug and look into the property container of the window? What is in it?

Re: Cannot center align text

Posted: Tue Dec 27, 2016 23:41
by Blackroot

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?

Re: Cannot center align text

Posted: Wed Dec 28, 2016 07:36
by YaronCT
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".

Re: Cannot center align text

Posted: Wed Dec 28, 2016 23:30
by Blackroot
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>

Re: Cannot center align text

Posted: Wed Dec 28, 2016 23:41
by Ident
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.

Re: Cannot center align text

Posted: Thu Dec 29, 2016 06:26
by YaronCT
@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?

Re: Cannot center align text

Posted: Thu Dec 29, 2016 09:30
by Ident
Sure

Re: Cannot center align text

Posted: Sat Dec 31, 2016 11:42
by YaronCT
@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?

Re: Cannot center align text

Posted: Sat Dec 31, 2016 11:46
by YaronCT
@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?

Re: Cannot center align text

Posted: Sat Dec 31, 2016 11:56
by Ident
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?

Re: Cannot center align text

Posted: Sat Dec 31, 2016 14:17
by YaronCT
@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).

Re: Cannot center align text

Posted: Fri Jan 06, 2017 15:19
by YaronCT
@Ident: Is it possible u missed the fact that my last post was addressing u too?

Re: Cannot center align text

Posted: Fri Jan 06, 2017 15:22
by Ident
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.

Re: Cannot center align text

Posted: Fri Jan 06, 2017 15:26
by YaronCT
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).