mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-02 02:51:42 +00:00
This does the same thing as right clicking, but provides a visual indicator. The icon disappears if the window is too small or docked (right click keeps working).
60 lines
1.4 KiB
C++
60 lines
1.4 KiB
C++
// Copyright (c) FIRST and other WPILib contributors.
|
|
// Open Source Software; you can modify and/or share it under the terms of
|
|
// the WPILib BSD license file in the root directory of this project.
|
|
|
|
#pragma once
|
|
|
|
#include <memory>
|
|
|
|
#include <wpi/FunctionExtras.h>
|
|
|
|
namespace glass {
|
|
|
|
/**
|
|
* A view is the contents of a window (1:1 mapping).
|
|
* It may reference multiple models.
|
|
*
|
|
* Typically a view is constructed by a Provider and the View's constructor
|
|
* is given the corresponding Model(s).
|
|
*
|
|
* A view may retain a reference to its parent window for dynamic
|
|
* window configuration.
|
|
*/
|
|
class View {
|
|
public:
|
|
virtual ~View() = default;
|
|
|
|
/**
|
|
* Displays the window contents. Called by Window::Display() from within an
|
|
* ImGui::Begin() / ImGui::End() block.
|
|
*/
|
|
virtual void Display() = 0;
|
|
|
|
/**
|
|
* Called instead of Display() when the window is hidden (e.g. when
|
|
* ImGui::Begin() returns false).
|
|
*/
|
|
virtual void Hidden();
|
|
|
|
/**
|
|
* Called from within ImGui::BeginContextPopupItem() and ImGui::EndPopup().
|
|
* Used to display the settings for the view
|
|
*/
|
|
virtual void Settings();
|
|
|
|
/**
|
|
* If the view has settings and if the result of Settings should be displayed.
|
|
*/
|
|
virtual bool HasSettings();
|
|
};
|
|
|
|
/**
|
|
* Make a View for a display functor.
|
|
*
|
|
* @param display Display function
|
|
* @return unique_ptr to View
|
|
*/
|
|
std::unique_ptr<View> MakeFunctionView(wpi::unique_function<void()> display);
|
|
|
|
} // namespace glass
|