Add a bit more functionality to the controls
This commit is contained in:
parent
787d18e12b
commit
b7362aa3f2
7 changed files with 164 additions and 6 deletions
|
|
@ -13,13 +13,19 @@ public:
|
|||
|
||||
void SetChecked(bool value);
|
||||
bool GetChecked() const;
|
||||
void Toggle();
|
||||
|
||||
double GetPreferredHeight() const;
|
||||
|
||||
protected:
|
||||
void OnPaint(Canvas* canvas) override;
|
||||
void OnMouseDown(const Point& pos, int key) override;
|
||||
void OnMouseUp(const Point& pos, int key) override;
|
||||
void OnMouseLeave() override;
|
||||
void OnKeyUp(EInputKey key) override;
|
||||
|
||||
private:
|
||||
std::string text;
|
||||
bool checked = false;
|
||||
bool mouseDownActive = false;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -14,6 +14,10 @@ public:
|
|||
protected:
|
||||
void OnPaint(Canvas* canvas) override;
|
||||
void OnPaintFrame(Canvas* canvas) override;
|
||||
void OnMouseDown(const Point& pos, int key) override;
|
||||
void OnMouseDoubleclick(const Point& pos, int key) override;
|
||||
void OnKeyDown(EInputKey key) override;
|
||||
|
||||
std::vector<std::string> items;
|
||||
int selectedItem = 0;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "../../core/widget.h"
|
||||
#include <functional>
|
||||
|
||||
class PushButton : public Widget
|
||||
{
|
||||
|
|
@ -13,10 +14,22 @@ public:
|
|||
|
||||
double GetPreferredHeight() const;
|
||||
|
||||
void Click();
|
||||
|
||||
std::function<void()> OnClick;
|
||||
|
||||
protected:
|
||||
void OnPaintFrame(Canvas* canvas) override;
|
||||
void OnPaint(Canvas* canvas) override;
|
||||
void OnMouseMove(const Point& pos) override;
|
||||
void OnMouseDown(const Point& pos, int key) override;
|
||||
void OnMouseUp(const Point& pos, int key) override;
|
||||
void OnMouseLeave() override;
|
||||
void OnKeyDown(EInputKey key) override;
|
||||
void OnKeyUp(EInputKey key) override;
|
||||
|
||||
private:
|
||||
std::string text;
|
||||
bool buttonDown = false;
|
||||
bool hot = false;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue