Adding new enum for Text positioning to allow center.
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Adsooi 2022-01-28 11:50:57 +01:00
parent b03ae3b784
commit 4a6777f637
Signed by: Ad5001
GPG key ID: EF45F9C6AFE20160
2 changed files with 13 additions and 7 deletions

View file

@ -36,7 +36,7 @@ class Text extends Common.DrawableObject {
static properties() {return { static properties() {return {
[QT_TRANSLATE_NOOP('prop','x')]: 'Expression', [QT_TRANSLATE_NOOP('prop','x')]: 'Expression',
[QT_TRANSLATE_NOOP('prop','y')]: 'Expression', [QT_TRANSLATE_NOOP('prop','y')]: 'Expression',
[QT_TRANSLATE_NOOP('prop','labelPosition')]: P.Enum.Position, [QT_TRANSLATE_NOOP('prop','labelPosition')]: P.Enum.Positioning,
[QT_TRANSLATE_NOOP('prop','text')]: 'string' [QT_TRANSLATE_NOOP('prop','text')]: 'string'
}} }}
@ -70,11 +70,9 @@ class Text extends Common.DrawableObject {
canvas.drawVisibleText(ctx, this.text, canvasX-textSize/2, canvasY+4) canvas.drawVisibleText(ctx, this.text, canvasX-textSize/2, canvasY+4)
break; break;
case 'top': case 'top':
case 'above':
canvas.drawVisibleText(ctx, this.text, canvasX-textSize/2, canvasY-16) canvas.drawVisibleText(ctx, this.text, canvasX-textSize/2, canvasY-16)
break; break;
case 'bottom': case 'bottom':
case 'below':
canvas.drawVisibleText(ctx, this.text, canvasX-textSize/2, canvasY+16) canvas.drawVisibleText(ctx, this.text, canvasX-textSize/2, canvasY+16)
break; break;
case 'left': case 'left':
@ -84,19 +82,15 @@ class Text extends Common.DrawableObject {
canvas.drawVisibleText(ctx, this.text, canvasX+5, canvasY+4) canvas.drawVisibleText(ctx, this.text, canvasX+5, canvasY+4)
break; break;
case 'top-left': case 'top-left':
case 'above-left':
canvas.drawVisibleText(ctx, this.text, canvasX-textSize-5, canvasY-16) canvas.drawVisibleText(ctx, this.text, canvasX-textSize-5, canvasY-16)
break; break;
case 'top-right': case 'top-right':
case 'above-right':
canvas.drawVisibleText(ctx, this.text, canvasX+5, canvasY-16) canvas.drawVisibleText(ctx, this.text, canvasX+5, canvasY-16)
break; break;
case 'bottom-left': case 'bottom-left':
case 'below-left':
canvas.drawVisibleText(ctx, this.text, canvasX-textSize-5, canvasY+16) canvas.drawVisibleText(ctx, this.text, canvasX-textSize-5, canvasY+16)
break; break;
case 'bottom-right': case 'bottom-right':
case 'below-right':
canvas.drawVisibleText(ctx, this.text, canvasX+5, canvasY+16) canvas.drawVisibleText(ctx, this.text, canvasX+5, canvasY+16)
break; break;

View file

@ -69,6 +69,18 @@ Enum.Position = new Enum(
QT_TR_NOOP('below-right') QT_TR_NOOP('below-right')
) )
Enum.Positioning = new Enum(
QT_TR_NOOP('center'),
QT_TR_NOOP('top'),
QT_TR_NOOP('bottom'),
QT_TR_NOOP('left'),
QT_TR_NOOP('right'),
QT_TR_NOOP('top-left'),
QT_TR_NOOP('top-right'),
QT_TR_NOOP('bottom-left'),
QT_TR_NOOP('bottom-right')
)
Enum.FunctionDisplayType = new Enum( Enum.FunctionDisplayType = new Enum(
QT_TR_NOOP('application'), QT_TR_NOOP('application'),
QT_TR_NOOP('function') QT_TR_NOOP('function')