A | 添加了一个 Button Draw Theme
This commit is contained in:
parent
c0f1e8f58a
commit
3612d8b06e
@ -31,6 +31,16 @@ from Difficult_Rocket.api.types import Options, FontData
|
||||
RGBA = Tuple[int, int, int, int]
|
||||
|
||||
|
||||
class ButtonDrawTheme(Options):
|
||||
"""
|
||||
直接绘制按钮的风格
|
||||
"""
|
||||
name = 'ButtonDrawTheme'
|
||||
untouch_batch: Batch
|
||||
touch_batch: Batch
|
||||
hit_batch: Batch
|
||||
|
||||
|
||||
class ButtonThemeOptions(Options):
|
||||
""" 基于 Options 写的 ButtonTheme """
|
||||
name = 'ButtonTheme'
|
||||
@ -60,6 +70,7 @@ class PressTextButton(widgets.WidgetBase):
|
||||
):
|
||||
super().__init__(x, y, width, height)
|
||||
self.main_batch = batch or Batch()
|
||||
self.user_batch = batch is not None
|
||||
self.front_group = Group(order=10, parent=group)
|
||||
self.back_ground_group = Group(order=5, parent=group)
|
||||
self.pressed = False
|
||||
@ -104,6 +115,10 @@ class PressTextButton(widgets.WidgetBase):
|
||||
def __contains__(self, item):
|
||||
return item in self.back_rec
|
||||
|
||||
def on_draw(self):
|
||||
if not self.user_batch:
|
||||
self.main_batch.draw()
|
||||
|
||||
def on_mouse_motion(self, x, y, dx, dy):
|
||||
if (x, y) in self.back_rec:
|
||||
self.back_rec.color = self.touched_color
|
||||
|
Loading…
Reference in New Issue
Block a user