Quintus icon indicating copy to clipboard operation
Quintus copied to clipboard

Left alignment of UI elements possible?

Open DanEEStar opened this issue 12 years ago • 5 comments

I do not understand how the alignment of UI-Labels should work. If I attach two UI-Labels with different label-text into the same UI-Container, then I expect that the Labels are both left aligned.

But that is not what happens. The draw method of the UI-Labels draws the label with a "-this.p.cx" which is different for the two UI-Labels.

Is it possible to make UI-Labels left aligned according to a point?

DanEEStar avatar Jan 08 '14 10:01 DanEEStar

They should, but right now p.w and p.cx are getting overridden regardless - will fix

cykod avatar Jan 09 '14 19:01 cykod

I could try a bugfix. As far as I understand the calcSize method Q.UI.Text works only for center-aligned elements. Are there other places I have to look for?

DanEEStar avatar Jan 10 '14 08:01 DanEEStar

if you want to take a stab at it, calcSize is the issue - default sprites are centered on their origin, but that doesn't make sense for most text. It'd be best to be top aligned by default and then either left, right or centered by moving the cx and cy

left: cx=0, cy=0, right: cx=w, cy=0 center: cx = w/2, cy=0

cykod avatar Jan 10 '14 12:01 cykod

@DanEEStar,

I've fixed the align property of UI.Text, if you set the align to 'left' and stick a label in the left side of a parent the text will render properly. Same for center and right. See: http://htmlpreview.github.io/?https://github.com/mpkorstanje/Quintus/blob/master/examples/text_allign/index.html

Can you check if it works when its done in a UI.Container?

mpkorstanje avatar Jun 04 '14 11:06 mpkorstanje

So close this right? @mpkorstanje

ghost avatar Jun 20 '14 03:06 ghost