ExpressionDim & fontdim "string" parameter

If you found a bug in our library or on our website, please report it in this section. In this forum you can also make concrete suggestions or feature requests.

Moderators: CEGUI MVP, CEGUI Team

pav
Not too shy to talk
Not too shy to talk
Posts: 37
Joined: Thu Dec 01, 2011 14:17

ExpressionDim & fontdim "string" parameter

Postby pav » Tue Dec 13, 2011 23:06

I'm writing a looknfeel and I soon realized that the hardest thing I do is writing the <Area> Dims, with the DimOperator etc.; they can get really complex and have their limits. So I started thinking of an easier system and came up with the following. the ExpressionDim: (wait! :D )

Code: Select all

<ExpressionDim value="Right - (Padding + ImageWidth)">
  <UnifiedDim varName="Right" scale="1.0" type="RightEdge" />
  <PropertyDim varName="Padding" name="PaddingRight" type="Width" />
  <ImageDim varName="ImageWidth" imageset="xxx" image="xxx dimension="Width" />
</ExpressionDim>

Then I went through the code, thinking of how to implement this; it should be really easy and backwards compatible, the hardest part would be the expression parser and evaluator. Imaging my surprise when I saw that this has already been implemented and it's called "ExpressionDim" :o

The actual syntax is similar but uses functions instead of named variables. (Source)

Code: Select all

<ExpressionDim value="udim( 0.5, 0, Height ) + (fontdim( LineSpacing ) * 2)" />

What's the status of this feature? It doesn't seem to be available in my build (0.7.5). I saw somewhere that I have to enable it during build. Will it be on by default on 0.8?

Anyway, the reason I'm positing on this part of the forum is that I think the "fontdim" functions are missing one parameter. According to fal_element_ref.dox from Mercurial, the available fontdim signatures are:
  • fontdim( widget, font, type, padding )
  • fontdim( type, padding )
  • fontdim( type )
What's missing is the "string" parameter. I personally use it to get a character width metric, like this: <FontDim type="HorzExtent" string="W"/>. Was the "string" parameter left out deliberately or can I add this to Mantis?

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Re: ExpressionDim & fontdim "string" parameter

Postby CrazyEddie » Sat Dec 17, 2011 09:37

It is still my intention that ExpressionDim be completed and enabled for general use from 0.8.0. I don't think it's had quite the testing I hoped, but nobody can say they did not get the opportunity :D I don't recall exactly when I added this - it could have been after the 0.7.5 release, and so the files would be missing from that (I think the present version only compiles on *nix too, though the final thing will, of couse, build on all supported systems).

The code as it stands in our default branch (what will become 0.8.0) likely needs some updates, due to some other things that we've changed, but this will happen before there is an 0.8.0 release.

With regards to adding a 'string' parameter, feel free to add a ticket requesting that - I don't recall any specific reason it's not there, so most likely either an accidental omission, or something I thought at the time nobody would want ;)

CE.

pav
Not too shy to talk
Not too shy to talk
Posts: 37
Joined: Thu Dec 01, 2011 14:17

Re: ExpressionDim & fontdim "string" parameter

Postby pav » Tue Jul 24, 2012 10:56

Hello again,

am I right that this feature was removed completely in 3424:07641ca1d079 ?
Is it because the change from DimOperator to OperatorDim is sufficient, or are you planning to reintroduce it?

Thanks.

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Re: ExpressionDim & fontdim "string" parameter

Postby CrazyEddie » Wed Jul 25, 2012 07:48

Hi pav,

The eventual removal of ExpressionDim was discussed somewhat on IRC, and in the end we decided removal was the right thing in this case. The main reasons for taking this decision are as follows:

  • OperatorDim is capable of representing everything that could be done with ExpressionDim
  • OperatorDim is faster than the equivalent ExpressionDim
  • ExpressionDim had never been seen in an actual release.
  • We didn't want to release ExpressionDim as either 'not recommended' or deprecated (which would have been the case)
Of course there is a downside to having removed ExpressionDim and that is that ExpressionDim was easier for humans to read without much mental effort.

The intention is for tools to bridge the gap - to basically take some infix notation expression and output the equivalent expression tree using OperatorDim.

Hope this answers your quesions, and sorry for pulling the rug out from under you as regards to ExpressionDim :?

CE


Return to “Bug Reports, Suggestions, Feature Requests”

Who is online

Users browsing this forum: No registered users and 12 guests