文本控件也支持设置最大宽度了
This commit is contained in:
@@ -72,20 +72,23 @@ function text:draw()
|
|||||||
if self.alpha>0 then
|
if self.alpha>0 then
|
||||||
local c=self.color
|
local c=self.color
|
||||||
gc_setColor(c[1],c[2],c[3],self.alpha)
|
gc_setColor(c[1],c[2],c[3],self.alpha)
|
||||||
|
local w=self.obj:getWidth()
|
||||||
|
local k=min(self.lim/self.obj:getWidth(),1)
|
||||||
if self.align=='M'then
|
if self.align=='M'then
|
||||||
gc_draw(self.obj,self.x-self.obj:getWidth()*.5,self.y)
|
gc_draw(self.obj,self.x,self.y,nil,k,1,w*.5,0)
|
||||||
elseif self.align=='L'then
|
elseif self.align=='L'then
|
||||||
gc_draw(self.obj,self.x,self.y)
|
gc_draw(self.obj,self.x,self.y,nil,k,1)
|
||||||
elseif self.align=='R'then
|
elseif self.align=='R'then
|
||||||
gc_draw(self.obj,self.x-self.obj:getWidth(),self.y)
|
gc_draw(self.obj,self.x,self.y,nil,k,1,w,0)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
function WIDGET.newText(D)--name,x,y[,fText][,color][,font=30][,fType][,align='M'][,hideF][,hide]
|
function WIDGET.newText(D)--name,x,y[,lim][,fText][,color][,font=30][,fType][,align='M'][,hideF][,hide]
|
||||||
local _={
|
local _={
|
||||||
name= D.name or"_",
|
name= D.name or"_",
|
||||||
x= D.x,
|
x= D.x,
|
||||||
y= D.y,
|
y= D.y,
|
||||||
|
lim= D.lim or 1e99,
|
||||||
|
|
||||||
fText=D.fText,
|
fText=D.fText,
|
||||||
color=D.color and(COLOR[D.color]or D.color)or COLOR.Z,
|
color=D.color and(COLOR[D.color]or D.color)or COLOR.Z,
|
||||||
|
|||||||
@@ -173,7 +173,7 @@ end
|
|||||||
|
|
||||||
scene.widgetScrollHeight=450
|
scene.widgetScrollHeight=450
|
||||||
scene.widgetList={
|
scene.widgetList={
|
||||||
WIDGET.newText{name='title', x=520,y=15,font=70,align='R'},
|
WIDGET.newText{name='title', x=40,y=15,lim=900,font=70,align='L'},
|
||||||
|
|
||||||
WIDGET.newKey{name='reset', x=1110,y=90,w=230,h=90,color='R',code=pressKey'delete'},
|
WIDGET.newKey{name='reset', x=1110,y=90,w=230,h=90,color='R',code=pressKey'delete'},
|
||||||
WIDGET.newKey{name='mod', x=1110,y=200,w=230,h=90,color='Z',code=pressKey'f1'},
|
WIDGET.newKey{name='mod', x=1110,y=200,w=230,h=90,color='Z',code=pressKey'f1'},
|
||||||
|
|||||||
Reference in New Issue
Block a user