WPILibC++ 2024.3.2
ShuffleboardWidget.h
Go to the documentation of this file.
1// Copyright (c) FIRST and other WPILib contributors.
2// Open Source Software; you can modify and/or share it under the terms of
3// the WPILib BSD license file in the root directory of this project.
4
5#pragma once
6
7#include <string_view>
8
12
13namespace frc {
14
15class ShuffleboardContainer;
16
17namespace detail {
19} // namespace detail
20
21/**
22 * Abstract superclass for widgets.
23 *
24 * <p>This class is package-private to minimize API surface area.
25 *
26 * @tparam Derived the self type
27 */
28template <typename Derived>
30 public:
32 : ShuffleboardValue(title),
33 ShuffleboardComponent<Derived>(parent, title) {}
34
35 /**
36 * Sets the type of widget used to display the data. If not set, the default
37 * widget type will be used.
38 *
39 * @param widgetType the type of the widget used to display the data
40 * @return this widget object
41 * @see BuiltInWidgets
42 */
43 Derived& WithWidget(BuiltInWidgets widgetType) {
45 }
46
47 /**
48 * Sets the type of widget used to display the data. If not set, the default
49 * widget type will be used.
50 *
51 * @param widgetType the type of the widget used to display the data
52 * @return this widget object
53 */
54 Derived& WithWidget(const WidgetType& widgetType) {
55 return WithWidget(widgetType.GetWidgetName());
56 }
57
58 /**
59 * Sets the type of widget used to display the data. If not set, the default
60 * widget type will be used. This method should only be used to use a widget
61 * that does not come built into Shuffleboard (i.e. one that comes with a
62 * custom or third-party plugin). To use a widget that is built into
63 * Shuffleboard, use WithWidget(WidgetType) and BuiltInWidgets.
64 *
65 * @param widgetType the type of the widget used to display the data
66 * @return this widget object
67 */
68 Derived& WithWidget(std::string_view widgetType) {
69 this->SetType(widgetType);
70 return *static_cast<Derived*>(this);
71 }
72};
73
74} // namespace frc
void SetType(std::string_view type)
A generic component in Shuffleboard.
Definition: ShuffleboardComponent.h:27
Common interface for objects that can contain shuffleboard components.
Definition: ShuffleboardContainer.h:42
Definition: ShuffleboardValue.h:15
Abstract superclass for widgets.
Definition: ShuffleboardWidget.h:29
ShuffleboardWidget(ShuffleboardContainer &parent, std::string_view title)
Definition: ShuffleboardWidget.h:31
Derived & WithWidget(BuiltInWidgets widgetType)
Sets the type of widget used to display the data.
Definition: ShuffleboardWidget.h:43
Derived & WithWidget(const WidgetType &widgetType)
Sets the type of widget used to display the data.
Definition: ShuffleboardWidget.h:54
Derived & WithWidget(std::string_view widgetType)
Sets the type of widget used to display the data.
Definition: ShuffleboardWidget.h:68
Represents the type of a widget in Shuffleboard.
Definition: WidgetType.h:18
std::string_view GetWidgetName() const
Gets the string type of the widget as defined by that widget in Shuffleboard.
basic_string_view< char > string_view
Definition: core.h:501
detail namespace with internal helper functions
Definition: xchar.h:20
type
Definition: core.h:556
const char * GetStringForWidgetType(BuiltInWidgets type)
Definition: AprilTagPoseEstimator.h:15
BuiltInWidgets
The types of the widgets bundled with Shuffleboard.
Definition: BuiltInWidgets.h:25