Add constants for built-in Shuffleboard widgets and layouts (#1468)

Prevents users from having to remember (and correctly type) the names of Shuffleboard widgets.
This commit is contained in:
Sam Carlberg
2018-12-29 20:22:47 -05:00
committed by Peter Johnson
parent ceed1d74dc
commit 01d1322066
24 changed files with 1278 additions and 52 deletions

View File

@@ -18,6 +18,9 @@
#include <wpi/StringMap.h>
#include <wpi/Twine.h>
#include "frc/ErrorBase.h"
#include "frc/WPIErrors.h"
#include "frc/shuffleboard/LayoutType.h"
#include "frc/shuffleboard/ShuffleboardComponentBase.h"
#include "frc/shuffleboard/ShuffleboardValue.h"
@@ -31,7 +34,8 @@ class SimpleWidget;
/**
* Common interface for objects that can contain shuffleboard components.
*/
class ShuffleboardContainer : public virtual ShuffleboardValue {
class ShuffleboardContainer : public virtual ShuffleboardValue,
public ErrorBase {
public:
explicit ShuffleboardContainer(const wpi::Twine& title);
@@ -49,12 +53,45 @@ class ShuffleboardContainer : public virtual ShuffleboardValue {
* Gets the layout with the given type and title, creating it if it does not
* already exist at the time this method is called.
*
* @param type the type of the layout, eg "List" or "Grid"
* @param title the title of the layout
* @param title the title of the layout
* @param layoutType the type of the layout, eg "List" or "Grid"
* @return the layout
*/
ShuffleboardLayout& GetLayout(const wpi::Twine& type,
const wpi::Twine& title);
ShuffleboardLayout& GetLayout(const wpi::Twine& title,
const LayoutType& type);
/**
* Gets the layout with the given type and title, creating it if it does not
* already exist at the time this method is called. Note: this method should
* only be used to use a layout type that is not already built into
* Shuffleboard. To use a layout built into Shuffleboard, use
* {@link #GetLayout(String, LayoutType)} and the layouts in {@link
* BuiltInLayouts}.
*
* @param title the title of the layout
* @param type the type of the layout, eg "List Layout" or "Grid Layout"
* @return the layout
* @see #GetLayout(String, LayoutType)
*/
ShuffleboardLayout& GetLayout(const wpi::Twine& title,
const wpi::Twine& type);
/**
* Gets the already-defined layout in this container with the given title.
*
* <pre>{@code
* Shuffleboard::GetTab("Example Tab")->getLayout("My Layout",
* &BuiltInLayouts.kList);
*
* // Later...
* Shuffleboard::GetTab("Example Tab")->GetLayout("My Layout");
* }</pre>
*
* @param title the title of the layout to get
* @return the layout with the given title
* @throws if no layout has yet been defined with the given title
*/
ShuffleboardLayout& GetLayout(const wpi::Twine& title);
/**
* Adds a widget to this container to display the given sendable.