Label text editor doesn't respect Justification


#1

Create a Label, use setJustificationType( Justification::centred ), and allow editing.

Result: The label text is centered, but when the user clicks to edit the label, the resulting text editor is left justified, causing the text to jump to the left.

It would be desirable if, when entering edit mode, the text editor activated in such a way that the text did not visibly shift at all, to create the appearance that it is being changed in-place (i.e. displaying using the Label’s Justification).

In addition, if a Label is editable, but the editor is not active, the cursor should probably change to an I-beam to indicate that the text can be edited. And if you want to provide the option to pass the click that activated edit mode, on to the text editor, so that the insertion point can be set to the place where the user clicked to get into edit mode, hey I’m not going to hold that against you (but if you don’t do it, I won’t complain either).


Msc Project Ideas - Anything JUCE users need?
#2

Yes, I know. But the TextEditor doesn’t handle justification yet, so I can’t change that at the moment (it’s on my to-do-list…)


#3

Jules - I Imagine your to-do list is horrible. But I'm working on an app with someone where this would be nice.  Is it anywhere near the top of the to-do list yet? :) 

It's only the one-line case this is normally annoying for.

cheers!! Jim. 


#4

Sorry, it's not an urgent one for me right now.. Obviously if you want to offer a suggested change that'd get things moving!


#5

No worries.  

I may have a look later when I've lit the fire and have a glass of wine in my hand :) 


#6

I see why this isn't simple. The way the Iterator object builds it up from the left isn't really encouraging justification.

It'd be easier to add SimpleTextEditor which ditched with most of the font/colour/multi-line code but offered Justification.  But I'm not sure that the easy path is the right solution. 

Going to have a look at how that Iterator is used and see if there's not another level of abstraction that'll sort it out. [... moderately long pause ...].

I think it'd be possible to add something like JustifyingIterator in as a wrapper over Iterator. It can deal with offsetting the horizontal axis and deal with adjusting indexToX type function calls.

Adding in an Iterator::getGlyphArrangement to replace Iterator::draw() gets me half of the way there.  I can then join the Glyphs on one line to a single GlyphArrangement and draw them so they look justified.  

I'm not sure how to handle vertical justification yet mind you ...

I'm leaning towards SimpleTextEditor :)