NDEVR
API Documentation
ColorChooserButton.h
1/*--------------------------------------------------------------------------------------------
2Copyright (c) 2019, NDEVR LLC
3tyler.parke@ndevr.org
4 __ __ ____ _____ __ __ _______
5 | \ | | | __ \ | ___|\ \ / / | __ \
6 | \ | | | | \ \ | |___ \ \ / / | |__) |
7 | . \| | | |__/ / | |___ \ V / | _ /
8 | |\ |_|_____/__|_____|___\_/____| | \ \
9 |__| \__________________________________| \__\
10
11Subject to the terms of the Enterprise+ Agreement, NDEVR hereby grants
12Licensee a limited, non-exclusive, non-transferable, royalty-free license
13(without the right to sublicense) to use the API solely for the purpose of
14Licensee's internal development efforts to develop applications for which
15the API was provided.
16
17The above copyright notice and this permission notice shall be included in all
18copies or substantial portions of the Software.
19
20THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
21INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
22PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
23FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25DEALINGS IN THE SOFTWARE.
26
27Library: Widgets
28File: ColorChooserButton
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include "DLLInfo.h"
34#include <NDEVR/Button.h>
35#include <NDEVR/Resource.h>
36#include <NDEVR/RGBColor.h>
37class QColorDialog;
38namespace NDEVR
39{
46 class NDEVR_WIDGETS_API ColorChooserButton : public Button
47 {
48 Q_OBJECT
49 public:
54 ColorChooserButton(QWidget* parent = nullptr);
59 ColorChooserButton(const std::function<void(RGBColor)>& on_click);
65 ColorChooserButton(const TranslatedString& name, const std::function<void(RGBColor)>& on_click);
72 ColorChooserButton(const TranslatedString& name, const String& icon, const std::function<void(RGBColor)>& on_click);
78 ColorChooserButton(const TranslatedString& title, const RGBColor& start_color = Constant<RGBColor>::Invalid);
87 void setShowAlpha(bool show_alpha);
92 void setCallback(const std::function<void(RGBColor)>& on_click);
96 void openDialog();
97 protected:
101 void init();
102 protected slots:
108 signals:
117 protected:
120 public:
122 };
123}
const TranslatedString & title() const
Returns the translated title of the button.
Button(QWidget *parent=nullptr)
Constructs a Button with an optional parent widget.
~ColorChooserButton()
Destroys the ColorChooserButton and releases the color dialog.
void openDialog()
Opens the color chooser dialog.
Resource< RGBColor > color
The currently selected color resource, updated when a color is chosen.
ColorChooserButton(const TranslatedString &title, const RGBColor &start_color=Constant< RGBColor >::Invalid)
Constructs a ColorChooserButton with a title and optional starting color.
void updateFromColorDialog(RGBColor c)
Slot that updates the button's background color and resource when the dialog color changes.
void setShowAlpha(bool show_alpha)
Sets whether the color dialog should include an alpha channel slider.
void init()
Performs common initialization shared by all constructors.
void colorChosen()
Emitted when a color has been chosen and the dialog is accepted.
QCustomColorDialog * m_dialog
The color chooser dialog instance.
ColorChooserButton(const TranslatedString &name, const String &icon, const std::function< void(RGBColor)> &on_click)
Constructs a ColorChooserButton with a title, icon, and color selection callback.
bool m_show_alpha
Whether the alpha channel control is visible in the color dialog.
ColorChooserButton(const std::function< void(RGBColor)> &on_click)
Constructs a ColorChooserButton with a color selection callback.
void setCallback(const std::function< void(RGBColor)> &on_click)
Sets the callback invoked when a color is chosen from the dialog.
ColorChooserButton(QWidget *parent=nullptr)
Constructs a ColorChooserButton with an optional parent widget.
void colorEdited()
Emitted when the color is changed interactively in the dialog.
ColorChooserButton(const TranslatedString &name, const std::function< void(RGBColor)> &on_click)
Constructs a ColorChooserButton with a title and color selection callback.
A dialog devoted to allowing the user to select a custom color.
Represents a color in the RGB space with optional alpha transparency.
Definition RGBColor.h:57
A core part of the engine, stores variables that can be listened to with ResourceListener which will ...
Definition Resource.h:42
The core String class for the NDEVR API.
Definition String.h:95
Any text displayed to the user should be defined as a TranslatedString which allows the program to lo...
The primary namespace for the NDEVR SDK.