v2!
This commit is contained in:
parent
8385df0cd5
commit
d12975bf9b
@ -70,6 +70,13 @@ class BaseButtonTheme:
|
||||
:return:
|
||||
"""
|
||||
|
||||
def on_update(self, button) -> None:
|
||||
"""
|
||||
当按钮的位置发生变化的时候
|
||||
:param button: 按钮
|
||||
:return:
|
||||
"""
|
||||
|
||||
|
||||
class MinecraftWikiButtonTheme(BaseButtonTheme):
|
||||
"""
|
||||
@ -95,18 +102,33 @@ class MinecraftWikiButtonTheme(BaseButtonTheme):
|
||||
touch_d = (106, 107, 108, 255) # 同上
|
||||
pad = 2 # 边框宽度 2 px
|
||||
list_pad = 4 # 下巴 4px
|
||||
# 主背景
|
||||
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 + 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 * 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))
|
||||
pop_out = False
|
||||
if pop_out:
|
||||
# 主背景
|
||||
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 + 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 * 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))
|
||||
else:
|
||||
# 主背景
|
||||
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=c, batch=batch, group=Group(order=3, parent=group))
|
||||
# 左上方向的覆盖
|
||||
self.cover_back = Rectangle(x=x + pad, y=y + (pad * 2) + list_pad,
|
||||
width=width - (pad * 3), height=height - (pad * 3) - list_pad,
|
||||
color=b, batch=batch, group=Group(order=2, parent=group))
|
||||
# 右下方向的覆盖
|
||||
self.cover_back2 = Rectangle(x=x + pad, y=y + pad + list_pad,
|
||||
width=width - (pad * 2), height=height - (pad * 2) - list_pad,
|
||||
color=a, batch=batch, group=Group(order=1, parent=group))
|
||||
# 下巴的框
|
||||
self.list_back = BorderedRectangle(x=x, y=y,
|
||||
width=width, height=height,
|
||||
@ -123,8 +145,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
|
||||
self.pop_out = pop_out
|
||||
self.drag_list = False
|
||||
|
||||
def on_touch(self, x, y) -> None:
|
||||
"""
|
||||
@ -147,30 +169,42 @@ class MinecraftWikiButtonTheme(BaseButtonTheme):
|
||||
:param y: 鼠标绝对位置
|
||||
:return:
|
||||
"""
|
||||
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)
|
||||
if self.pop_out:
|
||||
self.back_ground.color = self.touch_a
|
||||
self.cover_back.color = self.touch_b
|
||||
self.cover_back2.color = self.touch_c
|
||||
else:
|
||||
self.back_ground.color = self.touch_c
|
||||
self.cover_back.color = self.touch_b
|
||||
self.cover_back2.color = self.touch_a
|
||||
if self.drag_list:
|
||||
self.back_ground.y = self.y + (self.pad * 2)
|
||||
self.back_ground.height = self.height - (self.pad * 4)
|
||||
self.cover_back.y = self.y + self.pad
|
||||
self.cover_back.height = self.height - (self.pad * 2)
|
||||
self.cover_back2.y = self.y + self.pad
|
||||
self.cover_back2.height = self.height - (self.pad * 3)
|
||||
|
||||
def on_release(self) -> None:
|
||||
"""
|
||||
当鼠标松开按钮的时候
|
||||
:return:
|
||||
"""
|
||||
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
|
||||
if self.pop_out:
|
||||
self.back_ground.color = self.a
|
||||
self.cover_back.color = self.b
|
||||
self.cover_back2.color = self.c
|
||||
else:
|
||||
self.back_ground.color = self.c
|
||||
self.cover_back.color = self.b
|
||||
self.cover_back2.color = self.a
|
||||
if self.drag_list:
|
||||
self.back_ground.y = self.y + (self.pad * 2) + self.list_pad
|
||||
self.back_ground.height = self.height - (self.pad * 4) - self.list_pad
|
||||
self.cover_back.y = self.y + self.pad + self.list_pad
|
||||
self.cover_back.height = self.height - (self.pad * 2) - self.list_pad
|
||||
self.cover_back2.y = self.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