Skip to content

Commit

Permalink
add override to fix class structure shit
Browse files Browse the repository at this point in the history
  • Loading branch information
Forairaaaaa committed May 21, 2024
1 parent 7f63340 commit fb4c7f8
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 4 deletions.
3 changes: 0 additions & 3 deletions src/widgets/selector/base/selector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,6 @@ void SelectorBase::goTo(int optionIndex)

_selector_base_data.hovering_option_index = optionIndex;
onGoTo();

// Hover option
((OptionBase*)getHoveringWidget())->hover();
}

void SelectorBase::selectOption()
Expand Down
2 changes: 1 addition & 1 deletion src/widgets/selector/base/selelctor.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ namespace SmoothUIToolKit
inline size_t getOptionNum() { return _selector_base_data.current_widget->getChildren().size(); }
inline int getHoveringOptionIndex() { return _selector_base_data.hovering_option_index; }
WidgetBase* getHoveringWidget();
bool isHoveringOptionSelected();
virtual bool isHoveringOptionSelected();

public:
/**
Expand Down
31 changes: 31 additions & 0 deletions src/widgets/selector/smooth_selector/smooth_selector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ void SmoothSelector::onGoTo()
// Get selected widget frame
auto target_frame = ((SmoothOption*)getHoveringWidget())->getTransition().getTargetPoint();
getTransition().moveTo(target_frame);

// Hover
((SmoothOption*)getHoveringWidget())->hover();
}

void SmoothSelector::moveTo(int optionIndex) { goTo(optionIndex); }
Expand All @@ -27,3 +30,31 @@ void SmoothSelector::jumpTo(int optionIndex)
goTo(optionIndex);
getTransition().jumpTo(getTransition().getTargetPoint());
}

bool SmoothSelector::isHoveringOptionSelected()
{
auto hovering_widget = getHoveringWidget();
if (hovering_widget == nullptr)
return false;
return ((SmoothOption*)hovering_widget)->isSelected();
}

void SmoothSelector::selectOption()
{
auto hovering_widget = getHoveringWidget();
if (hovering_widget == nullptr)
return;

((SmoothOption*)hovering_widget)->select();
onSelectOption();
}

void SmoothSelector::unSelectOption()
{
auto hovering_widget = getHoveringWidget();
if (hovering_widget == nullptr)
return;

((SmoothOption*)hovering_widget)->unSelect();
onUnSelectOption();
}
8 changes: 8 additions & 0 deletions src/widgets/selector/smooth_selector/smooth_selector.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ namespace SmoothUIToolKit
class SmoothSelector : public SmoothWidgetBase, public SelectorBase
{
public:
// Override to fit new class structure

bool isHoveringOptionSelected() override;

void selectOption() override;

void unSelectOption() override;

/**
* @brief Override to add option frame matching
*
Expand Down

0 comments on commit fb4c7f8

Please sign in to comment.