Skip to content

Commit

Permalink
add a cursor
Browse files Browse the repository at this point in the history
  • Loading branch information
LupaDevStudio committed Dec 11, 2023
1 parent b59ae25 commit 242d3df
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 1 deletion.
Binary file added resources/images/cursor.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions screens/custom_widgets/bottom_bar.kv
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
#:kivy 2.2.1
#:import PATH_IMAGES tools.path.PATH_IMAGES

# <Cursor@Widget>:
# color: (0,0,0,1)
# canvas:
# Color:
# rgba: self.color
# Rectangle:
# pos: self.pos
# size: self.size

<BottomBar>:

canvas.before:
Expand All @@ -18,29 +27,41 @@
pos: (0,self.height)
size: (self.width, self.separation_height)

Image:
id: selected_cursor
source: PATH_IMAGES + "cursor.png"
pos_hint: root.selected_rect_pos
fit_mode: "contain"
size_hint: root.selected_rect_size
color: root.selected_color

# Home button
ImageButton:
id: home_button
source: PATH_IMAGES + "home.png"
size_hint: root.button_width, root.button_height
pos_hint: {"center_x":0.125, "center_y":0.5}
# release_function: root.manager.current = "home"

# Customization button
ImageButton:
id: customization_button
source: PATH_IMAGES + "customization.png"
size_hint: root.button_width, root.button_height
pos_hint: {"center_x":0.375, "center_y":0.5}
# release_function: root.manager.current = "customization"

# Profile button
ImageButton:
id: profile_button
source: PATH_IMAGES + "profile.png"
size_hint: root.button_width, root.button_height
pos_hint: {"center_x":0.625, "center_y":0.5}
# release_function: root.manager.current = "customization"

# Settings button
ImageButton:
id: settings_button
source: PATH_IMAGES + "settings.png"
size_hint: root.button_width, root.button_height
pos_hint: {"center_x":0.875, "center_y":0.5}
Expand Down
20 changes: 20 additions & 0 deletions screens/custom_widgets/bottom_bar.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
### Imports ###
###############

### Kivy imports ###
from kivy.uix.relativelayout import RelativeLayout
from kivy.properties import ListProperty, StringProperty, ObjectProperty

### Local imports ###
from tools.kivy_tools import ImageButton

#############
Expand All @@ -17,6 +21,22 @@
class BottomBar(RelativeLayout):
background_color = (0, 0, 0, 0.5)
separation_color = (1, 1, 1, 1)
selected_color = (1, 0, 0, 1)
separation_height = 3
button_width = 0.15
button_height = 0.7
selected = StringProperty()
selected_rect_pos = ObjectProperty((0, 0))
selected_rect_size = ObjectProperty((0, 0))

def __init__(self, **kw):
super().__init__(**kw)

def on_kv_post(self, base_widget):
if self.selected + "_button" in self.ids.keys():
self.selected_rect_pos = self.ids[self.selected +
"_button"].pos_hint
self.selected_rect_size = \
(self.ids[self.selected + "_button"].size_hint[0] * 1.2,
self.ids[self.selected + "_button"].size_hint[1] * 1.2)
return super().on_kv_post(base_widget)
3 changes: 2 additions & 1 deletion screens/home.kv
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@

BottomBar:
size_hint: (1, BOTTOM_BAR_HEIGHT)
pos_hint: {"bottom":0,"left":0}
pos_hint: {"bottom":0,"left":0}
selected: "home"

0 comments on commit 242d3df

Please sign in to comment.