-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Continue the design of the customization button
- Loading branch information
1 parent
a06383f
commit db9703e
Showing
17 changed files
with
168 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#:kivy 2.2.1 | ||
|
||
<BuyButton>: | ||
|
||
# Background | ||
canvas.before: | ||
Color: | ||
rgba: self.background_color | ||
RoundedRectangle: | ||
pos:(0,0) | ||
size:self.size | ||
radius:[20,] | ||
|
||
# Button title | ||
Label: | ||
text: root.button_title | ||
pos_hint: { "center_x":0.5,"center_y":0.8} | ||
size_hint: (1,0.7) | ||
text_size: (root.width*0.8,None) | ||
font_size: root.font_ratio * root.font_size | ||
font_name: root.text_font_name | ||
halign: "center" | ||
valign: "center" | ||
color: (0,0,0,1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
""" | ||
Module to create buy and enable buttons | ||
""" | ||
|
||
|
||
############### | ||
### Imports ### | ||
############### | ||
|
||
### Python imports ### | ||
|
||
from typing import Literal | ||
|
||
### Kivy imports ### | ||
|
||
from kivy.uix.relativelayout import RelativeLayout | ||
from kivy.uix.behaviors import ButtonBehavior | ||
from kivy.properties import ( | ||
StringProperty, | ||
NumericProperty, | ||
BooleanProperty | ||
) | ||
|
||
### Local imports ### | ||
|
||
from tools.path import ( | ||
PATH_TEXT_FONT | ||
) | ||
from tools.constants import ( | ||
CUSTOM_BUTTON_BACKGROUND_COLOR, | ||
OPACITY_ON_BUTTON_PRESS, | ||
ACT_BUTTON_FONT_SIZE | ||
) | ||
|
||
############# | ||
### Class ### | ||
############# | ||
|
||
|
||
class BuyButton(ButtonBehavior, RelativeLayout): | ||
""" | ||
A button for the customization screen to buy images or colors. | ||
""" | ||
|
||
background_color = CUSTOM_BUTTON_BACKGROUND_COLOR | ||
button_title = StringProperty() | ||
font_size = NumericProperty() | ||
font_ratio = NumericProperty(1) | ||
text_font_name = StringProperty(PATH_TEXT_FONT) | ||
has_bought = BooleanProperty() | ||
is_using = BooleanProperty() | ||
price = NumericProperty() | ||
|
||
def __init__( | ||
self, | ||
button_title: str = None, | ||
text_font_name=PATH_TEXT_FONT, | ||
font_size=ACT_BUTTON_FONT_SIZE, | ||
has_bought:bool = False, | ||
is_using: bool = False, | ||
price: int = 0, | ||
release_function=lambda: 1 + 1, | ||
font_ratio=None, | ||
**kwargs): | ||
|
||
if button_title is not None: | ||
self.button_title = button_title | ||
if font_ratio is not None: | ||
self.font_ratio = font_ratio | ||
|
||
self.release_function = release_function | ||
self.has_bought = has_bought | ||
self.is_using = is_using | ||
self.price = price | ||
|
||
super().__init__(**kwargs) | ||
self.text_font_name = text_font_name | ||
self.font_size = font_size | ||
|
||
def on_press(self): | ||
self.opacity = OPACITY_ON_BUTTON_PRESS | ||
|
||
def on_release(self): | ||
self.release_function() | ||
self.opacity = 1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters