def rebuild(self): """ A complete rebuild of the drawable shape used by this button. """ theming_parameters = { 'normal_bg': self.colours['normal_bg'], 'normal_text': self.colours['normal_text'], 'normal_border': self.colours['normal_border'], 'normal_image': self.normal_image, 'hovered_bg': self.colours['hovered_bg'], 'hovered_text': self.colours['hovered_text'], 'hovered_border': self.colours['hovered_border'], 'hovered_image': self.hovered_image, 'disabled_bg': self.colours['disabled_bg'], 'disabled_text': self.colours['disabled_text'], 'disabled_border': self.colours['disabled_border'], 'disabled_image': self.disabled_image, 'selected_bg': self.colours['selected_bg'], 'selected_text': self.colours['selected_text'], 'selected_border': self.colours['selected_border'], 'selected_image': self.selected_image, 'active_bg': self.colours['active_bg'], 'active_border': self.colours['active_border'], 'active_text': self.colours['active_text'], 'active_image': self.selected_image, 'border_width': self.border_width, 'shadow_width': self.shadow_width, 'font': self.font, 'text': self.text, 'text_horiz_alignment': self.text_horiz_alignment, 'text_vert_alignment': self.text_vert_alignment, 'text_horiz_alignment_padding': self.text_horiz_alignment_padding, 'text_vert_alignment_padding': self.text_vert_alignment_padding, 'shape_corner_radius': self.shape_corner_radius, 'transitions': self.state_transitions } if self.shape_type == 'rectangle': self.drawable_shape = RectDrawableShape( self.rect, theming_parameters, ['normal', 'hovered', 'disabled', 'selected', 'active'], self.ui_manager) elif self.shape_type == 'ellipse': self.drawable_shape = EllipseDrawableShape( self.rect, theming_parameters, ['normal', 'hovered', 'disabled', 'selected', 'active'], self.ui_manager) elif self.shape_type == 'rounded_rectangle': self.drawable_shape = RoundedRectangleShape( self.rect, theming_parameters, ['normal', 'hovered', 'disabled', 'selected', 'active'], self.ui_manager) self.on_fresh_drawable_shape_ready()
def rebuild(self): """ A complete rebuild of the drawable shape used by this button. """ self.rect.width = -1 if self.dynamic_width else self.rect.width self.relative_rect.width = -1 if self.dynamic_width else self.relative_rect.width self.rect.height = -1 if self.dynamic_height else self.rect.height self.relative_rect.height = -1 if self.dynamic_height else self.relative_rect.height theming_parameters = { 'normal_bg': self.colours['normal_bg'], 'normal_text': self.colours['normal_text'], 'normal_text_shadow': self.colours['normal_text_shadow'], 'normal_border': self.colours['normal_border'], 'normal_image': self.normal_image, 'hovered_bg': self.colours['hovered_bg'], 'hovered_text': self.colours['hovered_text'], 'hovered_text_shadow': self.colours['hovered_text_shadow'], 'hovered_border': self.colours['hovered_border'], 'hovered_image': self.hovered_image, 'disabled_bg': self.colours['disabled_bg'], 'disabled_text': self.colours['disabled_text'], 'disabled_text_shadow': self.colours['disabled_text_shadow'], 'disabled_border': self.colours['disabled_border'], 'disabled_image': self.disabled_image, 'selected_bg': self.colours['selected_bg'], 'selected_text': self.colours['selected_text'], 'selected_text_shadow': self.colours['selected_text_shadow'], 'selected_border': self.colours['selected_border'], 'selected_image': self.selected_image, 'active_bg': self.colours['active_bg'], 'active_border': self.colours['active_border'], 'active_text': self.colours['active_text'], 'active_text_shadow': self.colours['active_text_shadow'], 'active_image': self.selected_image, 'border_width': self.border_width, 'shadow_width': self.shadow_width, 'font': self.font, 'text': translate(self.text), 'text_shadow': (self.text_shadow_size, self.text_shadow_offset[0], self.text_shadow_offset[1], self.colours['normal_text_shadow'], True), 'text_horiz_alignment': self.text_horiz_alignment, 'text_vert_alignment': self.text_vert_alignment, 'text_horiz_alignment_padding': self.text_horiz_alignment_padding, 'text_horiz_alignment_method': self.text_horiz_alignment_method, 'text_vert_alignment_padding': self.text_vert_alignment_padding, 'shape_corner_radius': self.shape_corner_radius, 'transitions': self.state_transitions } if self.shape == 'rectangle': self.drawable_shape = RectDrawableShape( self.rect, theming_parameters, ['normal', 'hovered', 'disabled', 'selected', 'active'], self.ui_manager) elif self.shape == 'ellipse': self.drawable_shape = EllipseDrawableShape( self.rect, theming_parameters, ['normal', 'hovered', 'disabled', 'selected', 'active'], self.ui_manager) elif self.shape == 'rounded_rectangle': self.drawable_shape = RoundedRectangleShape( self.rect, theming_parameters, ['normal', 'hovered', 'disabled', 'selected', 'active'], self.ui_manager) self.on_fresh_drawable_shape_ready() if self.relative_rect.width == -1 or self.relative_rect.height == -1: self.dynamic_width = self.relative_rect.width == -1 self.dynamic_height = self.relative_rect.height == -1 self.set_dimensions(self.image.get_size()) # if we have anchored the left side of our button to the right of it's container then # changing the width is going to mess up the horiz position as well. new_left = self.relative_rect.left new_top = self.relative_rect.top if self.anchors['left'] == 'right' and self.dynamic_width: left_offset = self.dynamic_dimensions_orig_top_left[0] new_left = left_offset - self.relative_rect.width # if we have anchored the top side of our button to the bottom of it's container then # changing the height is going to mess up the vert position as well. if self.anchors['top'] == 'bottom' and self.dynamic_height: top_offset = self.dynamic_dimensions_orig_top_left[1] new_top = top_offset - self.relative_rect.height self.set_relative_position((new_left, new_top))