Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Base widget interface #3

Closed
golxzn opened this issue Jan 25, 2022 · 0 comments · Fixed by #10
Closed

Make Base widget interface #3

golxzn opened this issue Jan 25, 2022 · 0 comments · Fixed by #10
Assignees
Labels
enhancement New feature or request

Comments

@golxzn
Copy link
Collaborator

golxzn commented Jan 25, 2022

We need the uniform class for all ImGui widgets. It can be something that saves "update" and "draw" methods as lambdas or implements it in the derived class.

Example 1: Implementing as lambda wrapper.

MEOV::ImGui::Widget::Ref log{ new ... };
log->SetUpdate([](std::chrono::duration<double> delta) {
    // update some data
});
log->SetDraw([](MEOV::Graphics::Ref *g) {
    ImGui::Begin("Some widget");
      ImGui::Text("Hi");
    ImGui::End();
});

Example 2: Implementing as derived classes:

namespace MEOV::ImGui {

class HiWidget : public BaseWidget {
public:
    void Draw(Graphics::Ref) final override;
};

} // namespace MEOV::ImGui
@golxzn golxzn moved this from Todo to In Progress in MEOV Jan 25, 2022
@seigtm seigtm self-assigned this Jan 25, 2022
@seigtm seigtm added the enhancement New feature or request label Jan 25, 2022
Repository owner moved this from In Progress to Done in MEOV Jan 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
No open projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants