Compare commits
2 Commits
67ecba2d26
...
89b7b81314
Author | SHA1 | Date | |
---|---|---|---|
89b7b81314 | |||
4295d6ba62 |
@ -13,7 +13,7 @@ from pyglet.gui import widgets
|
||||
from pyglet.window import mouse
|
||||
|
||||
# from pyglet.sprite import Sprite
|
||||
from pyglet.shapes import Rectangle
|
||||
from pyglet.shapes import Rectangle, BorderedRectangle
|
||||
|
||||
# from pyglet.image import AbstractImage
|
||||
from pyglet.graphics import Batch, Group
|
||||
@ -96,21 +96,22 @@ class MinecraftWikiButtonTheme(BaseButtonTheme):
|
||||
pad = 2 # 边框宽度 2 px
|
||||
list_pad = 4 # 下巴 4px
|
||||
# 主背景
|
||||
self.back_ground = Rectangle(x=x, y=y,
|
||||
width=width, height=height,
|
||||
color=a, batch=batch, group=Group(order=0, parent=group))
|
||||
self.back_ground = Rectangle(x=x + (pad * 2), y=y + (pad * 2) + list_pad,
|
||||
width=width - (pad * 4), height=height - (pad * 4) - list_pad,
|
||||
color=a, batch=batch, group=Group(order=3, parent=group))
|
||||
# 左上方向的覆盖
|
||||
self.cover_back = Rectangle(x=x, y=y + pad + list_pad,
|
||||
width=width - pad, height=height - pad - list_pad,
|
||||
self.cover_back = Rectangle(x=x + pad, y=y + pad + list_pad,
|
||||
width=width - (pad * 2), height=height - (pad * 2) - list_pad,
|
||||
color=b, batch=batch, group=Group(order=1, parent=group))
|
||||
# 右下方向的覆盖
|
||||
self.cover_back2 = Rectangle(x=x + pad, y=y + pad + list_pad,
|
||||
width=width - (pad * 2), height=height - (pad * 2) - list_pad,
|
||||
self.cover_back2 = Rectangle(x=x + (pad * 2), y=y + pad + list_pad,
|
||||
width=width - (pad * 3), height=height - (pad * 3) - list_pad,
|
||||
color=c, batch=batch, group=Group(order=2, parent=group))
|
||||
# 下巴的框
|
||||
self.list_back = Rectangle(x=x, y=y,
|
||||
width=width, height=list_pad,
|
||||
color=e, batch=batch, group=Group(order=1, parent=group))
|
||||
self.list_back = BorderedRectangle(x=x, y=y,
|
||||
width=width, height=height,
|
||||
border=pad, border_color=(0, 0, 0, 255),
|
||||
color=e, batch=batch, group=Group(order=0, parent=group))
|
||||
self.a = a
|
||||
self.b = b
|
||||
self.c = c
|
||||
@ -122,6 +123,8 @@ class MinecraftWikiButtonTheme(BaseButtonTheme):
|
||||
self.touch_d = touch_d
|
||||
self.pad = pad
|
||||
self.list_pad = list_pad
|
||||
self.base_x = x
|
||||
self.base_y = y
|
||||
|
||||
def on_touch(self, x, y) -> None:
|
||||
"""
|
||||
@ -147,6 +150,12 @@ class MinecraftWikiButtonTheme(BaseButtonTheme):
|
||||
self.back_ground.color = self.touch_a
|
||||
self.cover_back.color = self.touch_b
|
||||
self.cover_back2.color = self.touch_c
|
||||
self.back_ground.y = self.base_y + (self.pad * 2)
|
||||
self.back_ground.height = self.height - (self.pad * 4)
|
||||
self.cover_back.y = self.base_y + self.pad
|
||||
self.cover_back.height = self.height - (self.pad * 2)
|
||||
self.cover_back2.y = self.base_y + self.pad
|
||||
self.cover_back2.height = self.height - (self.pad * 3)
|
||||
|
||||
def on_release(self) -> None:
|
||||
"""
|
||||
@ -156,6 +165,12 @@ class MinecraftWikiButtonTheme(BaseButtonTheme):
|
||||
self.back_ground.color = self.a
|
||||
self.cover_back.color = self.b
|
||||
self.cover_back2.color = self.c
|
||||
self.back_ground.y = self.base_y + (self.pad * 2) + self.list_pad
|
||||
self.back_ground.height = self.height - (self.pad * 4) - self.list_pad
|
||||
self.cover_back.y = self.base_y + self.pad + self.list_pad
|
||||
self.cover_back.height = self.height - (self.pad * 2) - self.list_pad
|
||||
self.cover_back2.y = self.base_y + self.pad + self.list_pad
|
||||
self.cover_back2.height = self.height - (self.pad * 3) - self.list_pad
|
||||
|
||||
|
||||
class ButtonThemeOptions(Options):
|
||||
|
Loading…
Reference in New Issue
Block a user