Back to index

unity  6.0.0
SearchBarSpinner.h
Go to the documentation of this file.
00001 // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
00002 /*
00003  * Copyright (C) 2011 Canonical Ltd
00004  *
00005  * This program is free software: you can redistribute it and/or modify
00006  * it under the terms of the GNU General Public License version 3 as
00007  * published by the Free Software Foundation.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00016  *
00017  * Authored by: Neil Jagdish Patel <neil.patel@canonical.com>
00018  */
00019 
00020 #ifndef SEARCH_BAR_SPINNER_H
00021 #define SEARCH_BAR_SPINNER_H
00022 
00023 #include <Nux/Nux.h>
00024 #include <Nux/View.h>
00025 #include <NuxGraphics/GraphicsEngine.h>
00026 #include <Nux/TextureArea.h>
00027 #include <NuxCore/Math/Matrix4.h>
00028 #include <UnityCore/GLibSource.h>
00029 #include "unity-shared/Introspectable.h"
00030 
00031 namespace unity
00032 {
00033 
00034 enum SpinnerState
00035 {
00036   STATE_READY,
00037   STATE_SEARCHING,
00038   STATE_CLEAR
00039 };
00040 
00041 class SearchBarSpinner : public unity::debug::Introspectable, public nux::View
00042 {
00043   NUX_DECLARE_OBJECT_TYPE(SearchBarSpinner, nux::View);
00044 public:
00045   SearchBarSpinner();
00046 
00047   void Draw(nux::GraphicsEngine& GfxContext, bool force_draw);
00048   void DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw);
00049 
00050   void SetState(SpinnerState state);
00051 
00052 protected:
00053   // Introspectable methods
00054   std::string GetName() const;
00055   void AddProperties(GVariantBuilder* builder);
00056 
00057   // Key navigation
00058   virtual bool AcceptKeyNavFocus();
00059 
00060 private:
00061   bool OnFrameTimeout();
00062 
00063   SpinnerState _state;
00064 
00065   nux::BaseTexture* _magnify;
00066   nux::BaseTexture* _circle;
00067   nux::BaseTexture* _close;
00068   nux::BaseTexture* _spin;
00069 
00070   glib::Source::UniquePtr _spinner_timeout;
00071   glib::Source::UniquePtr _frame_timeout;
00072 
00073   nux::Matrix4 _2d_rotate;
00074   float _rotation;
00075 };
00076 
00077 }
00078 
00079 #endif