Allolib  1.0
C++ Components For Interactive Multimedia
al_Dialog.hpp
1 #ifndef AL_DIALOG_HPP
2 #define AL_DIALOG_HPP
3 
4 /* Allocore --
5  Multimedia / virtual environment application class library
6 
7  Copyright (C) 2009. AlloSphere Research Group, Media Arts & Technology,
8  UCSB. Copyright (C) 2012-2018. The Regents of the University of California.
9  All rights reserved.
10 
11  Redistribution and use in source and binary forms, with or without
12  modification, are permitted provided that the following conditions are
13  met:
14 
15  Redistributions of source code must retain the above copyright
16  notice, this list of conditions and the following disclaimer.
17 
18  Redistributions in binary form must reproduce the above
19  copyright notice, this list of conditions and the following disclaimer in the
20  documentation and/or other materials provided with the
21  distribution.
22 
23  Neither the name of the University of California nor the names
24  of its contributors may be used to endorse or promote products derived from
25  this software without specific prior written permission.
26 
27  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
28  IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
30  PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
31  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
32  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
33  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
34  OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
35  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
36  OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
37  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 
39  File description:
40  ImGui modal query dialog
41 
42  File author(s):
43  AndrĂ©s Cabrera mantaraya36@gmail.com
44 */
45 
46 #include <functional>
47 #include <string>
48 
49 #include "al/graphics/al_Graphics.hpp"
50 #include "al/io/al_Imgui.hpp"
51 
52 namespace al {
53 
56 class Dialog {
57  public:
58  virtual ~Dialog() {}
59 
60  enum Buttons {
61  AL_DIALOG_BUTTON_OK = 0x01,
62  AL_DIALOG_BUTTON_CANCEL = 0x02,
63  AL_DIALOG_BUTTON_YES = 0x04,
64  AL_DIALOG_BUTTON_NO = 0x08
65  };
66 
67  enum class DialogResult : int {
68  AL_DIALOG_OK,
69  AL_DIALOG_CANCEL,
70  AL_DIALOG_YES,
71  AL_DIALOG_NO
72  };
73 
74  Dialog(std::string title, std::string text,
75  int buttons = Buttons::AL_DIALOG_BUTTON_OK);
76 
77  void start();
78  void start(std::function<void(DialogResult)> doneCallback);
79 
80  bool isOpen();
81  DialogResult getReturnValue();
82 
83  virtual void draw(Graphics &g);
84 
85  protected:
86  private:
87  bool mModal;
88 
89  std::function<void(DialogResult)> mDoneCallback;
90 
91  std::string mTitle;
92  std::string mText;
93  Buttons mButtons;
94  DialogResult mReturnValue;
95  bool mOpen;
96 };
97 
98 } // namespace al
99 
100 #endif // AL_DIALOG_HPP
Interface for loading fonts and rendering text.
Definition: al_Graphics.hpp:63
Definition: al_App.hpp:23