1 /* 2 nanogui/popupbutton.h -- Button which launches a popup widget 3 4 NanoGUI was developed by Wenzel Jakob <wenzel.jakob@epfl.ch>. 5 The widget drawing code is based on the NanoVG demo application 6 by Mikko Mononen. 7 8 All rights reserved. Use of this source code is governed by a 9 BSD-style license that can be found in the LICENSE.txt file. 10 */ 11 /** \file */ 12 13 #pragma once 14 15 #include <nanogui/button.h> 16 #include <nanogui/popup.h> 17 #include <nanogui/entypo.h> 18 NAMESPACE_BEGIN(nanogui)19NAMESPACE_BEGIN(nanogui) 20 21 /** 22 * \class PopupButton popupbutton.h nanogui/popupbutton.h 23 * 24 * \brief Button which launches a popup widget. 25 */ 26 class NANOGUI_EXPORT PopupButton : public Button { 27 public: 28 PopupButton(Widget *parent, const std::string &caption = "Untitled", 29 int buttonIcon = 0, 30 int chevronIcon = ENTYPO_ICON_CHEVRON_SMALL_RIGHT); 31 32 void setChevronIcon(int icon) { mChevronIcon = icon; } 33 int chevronIcon() const { return mChevronIcon; } 34 35 Popup *popup() { return mPopup; } 36 const Popup *popup() const { return mPopup; } 37 38 virtual void draw(NVGcontext* ctx) override; 39 virtual Vector2i preferredSize(NVGcontext *ctx) const override; 40 virtual void performLayout(NVGcontext *ctx) override; 41 42 virtual void save(Serializer &s) const override; 43 virtual bool load(Serializer &s) override; 44 protected: 45 Popup *mPopup; 46 int mChevronIcon; 47 }; 48 49 NAMESPACE_END(nanogui) 50