Skip to content

Commit

Permalink
day 2.5 progress
Browse files Browse the repository at this point in the history
  • Loading branch information
T-Dynamos committed Mar 4, 2024
1 parent 3228304 commit 5f38937
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 15 deletions.
4 changes: 2 additions & 2 deletions kivymd/uix/carousel/carousel.kv
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@
default_size_hint:[None, 1]
size_hint:[None, 1]
width:self.minimum_width
spacing:dp(8)
padding:[dp(16), dp(8)]
#spacing:dp(8)
#padding:[dp(16), dp(8)]
22 changes: 12 additions & 10 deletions kivymd/uix/carousel/carousel.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class MDCarousel(RecycleView):
_strategy = None
_container = None
_distance_scroll = NumericProperty(0.0)
_variable_item_size = dp(50)
_variable_item_size = dp(50)

def __init__(self, *arg, **kwargs):
super().__init__(*arg, **kwargs)
Expand All @@ -77,32 +77,34 @@ def fit_count(self, type_item, child_count):
return range(suitable_count)

def set_init_size(self, *arg):
predicted_size = (self._strategy.large_count*self._strategy.large_size) + (self._strategy.medium_count*self._strategy.medium_size) + (self._strategy.small_count*self._strategy.small_size)

print(predicted_size)
print(self.size,self._strategy, len(self._container.children))

child_count = len(self._container.children)
if child_count <= (
if child_count < (
self._strategy.small_count
+ self._strategy.medium_count
+ self._strategy.large_count
):
return

print(self.size,self._strategy, len(self._container.children))

index = 0
for type_item in ["large", "medium", "small"]:
item_size = getattr(self._strategy, f"{type_item}_size")
for _, widget in zip(
self.fit_count(type_item, child_count),
self._container.children[::-1][index:],
for widget_index in (
self.fit_count(type_item, child_count)
):
widget = self._container.children[::-1][index]
widget.width = item_size
index += 1

def on__distance_scroll(self, instance, distance):
pass

def update_strategy(self, *args):
self._strategy = AvaliableStrategies.get(self.strategy).arrange(
self, self.desired_item_size, len(self.data)
self.width, self.desired_item_size, len(self.data)
)
Clock.schedule_once(self.set_init_size)
return self._strategy
Expand Down
5 changes: 2 additions & 3 deletions kivymd/uix/carousel/carousel_strategy.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ class MultiBrowseCarouselStrategy(CarouselStrategy):
small_counts = [1]
medium_counts = [1, 0]

def arrange(self, carousel: Widget, measured_child_size, item_len):
available_space = (carousel.width-dp(40)) if carousel.is_horizontal else carousel.height
def arrange(self, available_space, measured_child_size, item_len):
small_child_size_min = self.small_size_min
small_child_size_max = max(self.small_size_max, small_child_size_min)
target_large_child_size = min(measured_child_size, available_space)
Expand All @@ -62,7 +61,7 @@ def arrange(self, carousel: Widget, measured_child_size, item_len):
small_counts = [0]
medium_counts = self.medium_counts

if carousel.alignment == "center":
if False:#carousel.alignment == "center":
small_counts = self.double_counts(small_counts)
medium_counts = self.double_counts(medium_counts)

Expand Down

0 comments on commit 5f38937

Please sign in to comment.