C++ Shuffleboard fixes (#1595)

* Fix C++ ShuffleboardComponent template type

* Fix `WithWidget(WidgetType&)`not being properly capitalized

* Fix data members across dll boundaries by using enum for built in types
This commit is contained in:
Sam Carlberg
2019-02-14 23:44:30 -05:00
committed by Peter Johnson
parent 182758c05b
commit e8b24717c7
12 changed files with 184 additions and 89 deletions

View File

@@ -9,6 +9,7 @@
#include <wpi/Twine.h>
#include "frc/shuffleboard/BuiltInWidgets.h"
#include "frc/shuffleboard/ShuffleboardComponent.h"
#include "frc/shuffleboard/WidgetType.h"
@@ -16,6 +17,10 @@ namespace frc {
class ShuffleboardContainer;
namespace detail {
const char* GetStringForWidgetType(BuiltInWidgets type);
} // namespace detail
/**
* Abstract superclass for widgets.
*
@@ -24,12 +29,11 @@ class ShuffleboardContainer;
* @tparam Derived the self type
*/
template <typename Derived>
class ShuffleboardWidget
: public ShuffleboardComponent<ShuffleboardWidget<Derived>> {
class ShuffleboardWidget : public ShuffleboardComponent<Derived> {
public:
ShuffleboardWidget(ShuffleboardContainer& parent, const wpi::Twine& title)
: ShuffleboardValue(title),
ShuffleboardComponent<ShuffleboardWidget<Derived>>(parent, title) {}
ShuffleboardComponent<Derived>(parent, title) {}
/**
* Sets the type of widget used to display the data. If not set, the default
@@ -39,7 +43,18 @@ class ShuffleboardWidget
* @return this widget object
* @see BuiltInWidgets
*/
Derived& withWidget(const WidgetType& widgetType) {
Derived& WithWidget(BuiltInWidgets widgetType) {
return WithWidget(detail::GetStringForWidgetType(widgetType));
}
/**
* Sets the type of widget used to display the data. If not set, the default
* widget type will be used.
*
* @param widgetType the type of the widget used to display the data
* @return this widget object
*/
Derived& WithWidget(const WidgetType& widgetType) {
return WithWidget(widgetType.GetWidgetName());
}