bWidgets
Core widget toolkit designed for Blender
bwAbstractButton.h
Go to the documentation of this file.
1#pragma once
2
3#include <memory>
4#include <string>
5
6#include "bwUtil.h"
7#include "bwWidget.h"
8#include "bwWidgetBaseStyle.h"
9
10namespace bWidgets {
11
12class bwIconInterface;
13
17class bwAbstractButton : public bwWidget {
18 public:
19 void draw(class bwStyle& style) override;
20 void registerProperties() override;
21
22 auto getLabel() const -> const std::string* override;
23 auto setLabel(const std::string& label) -> bwAbstractButton&;
24 virtual auto getIcon() const -> const bwIconInterface*;
25
26 auto createHandler() -> std::unique_ptr<bwScreenGraph::EventHandler> override;
27
31 std::unique_ptr<bwFunctorInterface> apply_functor{nullptr};
32
33 unsigned int rounded_corners;
34
35 protected:
36 // Protected constructor to force calling through inherited class (pseudo abstract).
37 bwAbstractButton(const std::string& text,
38 std::optional<unsigned int> width_hint = std::nullopt,
39 std::optional<unsigned int> height_hint = std::nullopt);
40 void apply();
41
42 std::string text;
43
44 public:
46 base_style; // XXX public for setWidgetStyle. Should only be temporarily needed.
47};
48
50 public:
52 virtual ~bwAbstractButtonHandler() = default;
53
54 void onMouseEnter(bwEvent&) override;
55 void onMouseLeave(bwEvent&) override;
56 void onMousePress(bwMouseButtonEvent&) override;
57 void onMouseRelease(bwMouseButtonEvent&) override;
58
59 protected:
61
62 void apply();
63};
64
65} // namespace bWidgets
Definition: bwAbstractButton.h:49
void onMouseEnter(bwEvent &) override
Definition: bwAbstractButton.cc:64
void apply()
Definition: bwAbstractButton.cc:96
void onMouseRelease(bwMouseButtonEvent &) override
Definition: bwAbstractButton.cc:86
bwAbstractButton & button
Definition: bwAbstractButton.h:60
bwAbstractButtonHandler(bwAbstractButton &button)
Definition: bwAbstractButton.cc:60
void onMousePress(bwMouseButtonEvent &) override
Definition: bwAbstractButton.cc:78
virtual ~bwAbstractButtonHandler()=default
void onMouseLeave(bwEvent &) override
Definition: bwAbstractButton.cc:71
Base class for button like widgets.
Definition: bwAbstractButton.h:17
std::unique_ptr< bwFunctorInterface > apply_functor
Definition: bwAbstractButton.h:31
void registerProperties() override
Definition: bwAbstractButton.cc:33
bwWidgetBaseStyle base_style
Definition: bwAbstractButton.h:46
bwAbstractButton(const std::string &text, std::optional< unsigned int > width_hint=std::nullopt, std::optional< unsigned int > height_hint=std::nullopt)
Definition: bwAbstractButton.cc:9
void draw(class bwStyle &style) override
Definition: bwAbstractButton.cc:19
auto getLabel() const -> const std::string *override
Definition: bwAbstractButton.cc:38
std::string text
Definition: bwAbstractButton.h:42
auto createHandler() -> std::unique_ptr< bwScreenGraph::EventHandler > override
Definition: bwAbstractButton.cc:53
virtual auto getIcon() const -> const bwIconInterface *
Definition: bwAbstractButton.cc:48
unsigned int rounded_corners
Definition: bwAbstractButton.h:33
auto setLabel(const std::string &label) -> bwAbstractButton &
Definition: bwAbstractButton.cc:42
Definition: bwEvent.h:8
Interface to reference icons from within bWidgets.
Definition: bwIconInterface.h:22
Definition: bwEvent.h:24
API for registering and calling event-listeners.
Definition: EventHandler.h:31
Definition: bwStyle.h:10
Properties for typical widgets with roundbox corners.
Definition: bwWidgetBaseStyle.h:14
Abstract base class that all widgets derive from.
Definition: bwWidget.h:22
unsigned int height_hint
Definition: bwWidget.h:68
unsigned int width_hint
Definition: bwWidget.h:68
Definition: bwContext.h:3