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