Skip to content

Commit

Permalink
virtual some shit, add move and jump
Browse files Browse the repository at this point in the history
  • Loading branch information
Forairaaaaa committed May 21, 2024
1 parent b4165d8 commit 2253678
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 6 deletions.
8 changes: 8 additions & 0 deletions src/widgets/base/base.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,14 @@ namespace SmoothUIToolKit
inline void setVisible(bool isVisible) { _base_data.is_visible = isVisible; }
inline bool isVisible() { return _base_data.is_visible; }

/**
* @brief Set auto invoke render() after root widget update
*
* @param renderOnUpdate
*/
inline void setRenderOnUpdate(bool renderOnUpdate) { _base_data.render_on_update = renderOnUpdate; }
inline bool getRenderOnUpdate() { return _base_data.render_on_update; }

/**
* @brief Init your shit
*
Expand Down
10 changes: 5 additions & 5 deletions src/widgets/selector/base/selelctor.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,21 @@ namespace SmoothUIToolKit
*
* @param widget
*/
void enter(WidgetBase* widget);
virtual void enter(WidgetBase* widget);

/**
* @brief Go back to last widget
*
* @return true
* @return false
*/
bool back();
virtual bool back();

void goLast();
virtual void goLast();

void goNext();
virtual void goNext();

void goTo(int optionIndex);
virtual void goTo(int optionIndex);

public:
virtual void onEnter() {}
Expand Down
8 changes: 8 additions & 0 deletions src/widgets/selector/smooth_selector/smooth_selector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,11 @@ void SmoothSelector::onGoTo()
auto target_frame = ((SmoothOption*)getSelectedWidget())->getTransition().getTargetPoint();
getTransition().moveTo(target_frame);
}

void SmoothSelector::moveTo(int optionIndex) { goTo(optionIndex); }

void SmoothSelector::jumpTo(int optionIndex)
{
goTo(optionIndex);
getTransition().jumpTo(getTransition().getTargetPoint());
}
25 changes: 24 additions & 1 deletion src/widgets/selector/smooth_selector/smooth_selector.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,30 @@ namespace SmoothUIToolKit
{
class SmoothSelector : public SmoothWidgetBase, public SelectorBase
{
void onGoTo() override;
public:
/**
* @brief Override to add option frame matching
*
*/
virtual void onGoTo() override;

/**
* @brief Move to option with transition
*
* @param optionIndex
*/
virtual void moveTo(int optionIndex);

/**
* @brief Jump to option without transition
*
* @param optionIndex
*/
virtual void jumpTo(int optionIndex);

public:
virtual void onMoveTo() {}
virtual void onJumpTo() {}
};
} // namespace Selector
} // namespace Widgets
Expand Down

0 comments on commit 2253678

Please sign in to comment.