Back to index

unity  6.0.0
HudButton.h
Go to the documentation of this file.
00001 /*
00002  * Copyright 2011 Canonical Ltd.
00003  *
00004  * This program is free software: you can redistribute it and/or modify it
00005  * under the terms of the GNU Lesser General Public License version 3, as
00006  * published by the  Free Software Foundation.
00007  *
00008  * This program is distributed in the hope that it will be useful, but
00009  * WITHOUT ANY WARRANTY; without even the implied warranties of
00010  * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
00011  * PURPOSE.  See the applicable version of the GNU Lesser General Public
00012  * License for more details.
00013  *
00014  * You should have received a copy of both the GNU Lesser General Public
00015  * License version 3 along with this program.  If not, see
00016  * <http://www.gnu.org/licenses/>
00017  *
00018  * Authored by: Gordon Allott <gord.allott@canonical.com>
00019  *
00020  */
00021 
00022 #ifndef UNITYSHELL_HUDBUTTON_H
00023 #define UNITYSHELL_HUDBUTTON_H
00024 
00025 #include <Nux/Nux.h>
00026 #include <Nux/CairoWrapper.h>
00027 #include <Nux/Button.h>
00028 #include <Nux/TextureArea.h>
00029 #include <UnityCore/Hud.h>
00030 #include "unity-shared/Introspectable.h"
00031 
00032 namespace nux { class HLayout; }
00033 
00034 namespace unity
00035 {
00036 namespace hud
00037 {
00038 
00039 class HudButton : public nux::Button, public unity::debug::Introspectable 
00040 {
00041   NUX_DECLARE_OBJECT_TYPE(HudButton, nux::Button);
00042 
00043 public:
00044   typedef nux::ObjectPtr<HudButton> Ptr;
00045 
00046   HudButton(NUX_FILE_LINE_PROTO);
00047 
00048   void SetQuery(Query::Ptr query);
00049   std::shared_ptr<Query> GetQuery();
00050 
00051   void SetSkipDraw(bool skip_draw);
00052 
00053   nux::Property<std::string> label;
00054   nux::Property<bool> is_rounded;
00055   nux::Property<bool> fake_focused;
00056 
00057 protected:
00058   virtual bool AcceptKeyNavFocus();
00059   virtual long ComputeContentSize();
00060   virtual void Draw(nux::GraphicsEngine& GfxContext, bool force_draw);
00061   virtual void DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw);
00062 
00063   std::string GetName() const;
00064   void AddProperties(GVariantBuilder* builder);
00065  
00066   void InitTheme();
00067   void RedrawTheme(nux::Geometry const& geom, cairo_t* cr, nux::ButtonVisualState faked_state);
00068 
00069 private:
00070   typedef std::unique_ptr<nux::CairoWrapper> NuxCairoPtr;
00071 
00072   Query::Ptr query_;
00073   nux::Geometry cached_geometry_;
00074 
00075   bool is_focused_;
00076   bool skip_draw_;
00077 
00078   NuxCairoPtr prelight_;
00079   NuxCairoPtr active_;
00080   NuxCairoPtr normal_;
00081 
00082   nux::HLayout* hlayout_;
00083 };
00084 
00085 } // namespace hud
00086 } // namespace unity
00087 
00088 #endif // UNITYSHELL_HUDBUTTON_H