From b0eac8af635973121ebbe1d9f161cd767dc53266 Mon Sep 17 00:00:00 2001 From: MrZ626 <1046101471@qq.com> Date: Fri, 26 Mar 2021 18:01:51 +0800 Subject: [PATCH] =?UTF-8?q?button=E5=92=8Ckey=E6=8E=A7=E4=BB=B6=E5=8F=AF?= =?UTF-8?q?=E4=BB=A5=E6=89=8B=E5=8A=A8=E8=AE=BE=E7=BD=AE=E7=95=99=E7=99=BD?= =?UTF-8?q?=E8=B7=9D=E7=A6=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Zframework/widget.lua | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/Zframework/widget.lua b/Zframework/widget.lua index 2d2ccc8d..da7fb784 100644 --- a/Zframework/widget.lua +++ b/Zframework/widget.lua @@ -154,12 +154,13 @@ function button:draw() setFont(self.font) local y0=y+h*.5-self.font*.7-ATV*.5 gc.setColor(1,1,1,.2+ATV*.05) - gc.printf(t,x+20-2,y0-2,w-40,self.align) - gc.printf(t,x+20-2,y0+2,w-40,self.align) - gc.printf(t,x+20+2,y0-2,w-40,self.align) - gc.printf(t,x+20+2,y0+2,w-40,self.align) + local edge=self.edge + gc.printf(t,x+edge-2,y0-2,w-2*edge,self.align) + gc.printf(t,x+edge-2,y0+2,w-2*edge,self.align) + gc.printf(t,x+edge+2,y0-2,w-2*edge,self.align) + gc.printf(t,x+edge+2,y0+2,w-2*edge,self.align) gc.setColor(r*.5,g*.5,b*.5) - gc.printf(t,x+20,y0,w-40,self.align) + gc.printf(t,x+edge,y0,w-2*edge,self.align) else self.text=self.name or"###" self.color=COLOR.dPurple @@ -173,7 +174,7 @@ function button:press() self:FX() SFX.play("button") end -function WIDGET.newButton(D)--name,x,y,w[,h][,fText][,color][,font][,align],code[,hide] +function WIDGET.newButton(D)--name,x,y,w[,h][,fText][,color][,font][,align="M"[,edge]],code[,hide] if not D.h then D.h=D.w end local _={ name= D.name, @@ -195,6 +196,7 @@ function WIDGET.newButton(D)--name,x,y,w[,h][,fText][,color][,font][,align],code color= D.color and(COLOR[D.color]or D.color)or COLOR.white, font= D.font or 30, align= alignModes[D.align or"M"]or"center", + edge= D.edge or 0, code= D.code, hide= D.hide, } @@ -244,7 +246,7 @@ function key:draw() if t then setFont(self.font) gc.setColor(r,g,b,1.2) - gc.printf(t,x+20,y+h*.5-self.font*.7,w-40,self.align) + gc.printf(t,x+self.edge,y+h*.5-self.font*.7,w-2*self.edge,self.align) else self.text=self.name or"###" self.color=COLOR.dPurple @@ -256,7 +258,7 @@ end function key:press() self.code() end -function WIDGET.newKey(D)--name,x,y,w[,h][,fText][,color][,font][,align],code[,hide] +function WIDGET.newKey(D)--name,x,y,w[,h][,fText][,color][,font][,align="M"[,edge]],code[,hide] if not D.h then D.h=D.w end local _={ name= D.name, @@ -278,6 +280,7 @@ function WIDGET.newKey(D)--name,x,y,w[,h][,fText][,color][,font][,align],code[,h color= D.color and(COLOR[D.color]or D.color)or COLOR.white, font= D.font or 30, align= alignModes[D.align or"M"]or"center", + edge= D.edge or 0, code= D.code, hide= D.hide, }