Back to index

unity  6.0.0
FilterBar.h
Go to the documentation of this file.
00001 // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
00002 /*
00003  * Copyright 2011 Canonical Ltd.
00004  *
00005  * This program is free software: you can redistribute it and/or modify it
00006  * under the terms of the GNU Lesser 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, but
00010  * WITHOUT ANY WARRANTY; without even the implied warranties of
00011  * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
00012  * PURPOSE.  See the applicable version of the GNU Lesser General Public
00013  * License for more details.
00014  *
00015  * You should have received a copy of both the GNU Lesser General Public
00016  * License version 3 along with this program.  If not, see
00017  * <http://www.gnu.org/licenses/>
00018  *
00019  * Authored by: Gordon Allott <gord.allott@canonical.com>
00020  *
00021  */
00022 
00023 #ifndef UNITYSHELL_FILTERBAR_H
00024 #define UNITYSHELL_FILTERBAR_H
00025 
00026 #include <Nux/View.h>
00027 
00028 #include <UnityCore/Filters.h>
00029 
00030 #include "FilterFactory.h"
00031 #include "unity-shared/Introspectable.h"
00032 
00033 namespace unity
00034 {
00035 namespace dash
00036 {
00037 
00038 class FilterExpanderLabel;
00039 
00040 class FilterBar : public nux::View, public debug::Introspectable
00041 {
00042   NUX_DECLARE_OBJECT_TYPE(FilterBar, nux::View);
00043 public:
00044   FilterBar(NUX_FILE_LINE_PROTO);
00045   ~FilterBar();
00046 
00047   void SetFilters(Filters::Ptr const& filters);
00048 
00049   void AddFilter(Filter::Ptr const& filter);
00050   void RemoveFilter(Filter::Ptr const& filter);
00051 
00052 protected:
00053   virtual bool AcceptKeyNavFocus();
00054   virtual void Draw(nux::GraphicsEngine& GfxContext, bool force_draw);
00055   virtual void DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw);
00056 
00057   // Introspection
00058   virtual std::string GetName() const;
00059   virtual void AddProperties(GVariantBuilder* builder);
00060 
00061 private:
00062   void Init();
00063   void UpdateDrawSeparators();
00064 
00065   FilterFactory factory_;
00066   Filters::Ptr filters_;
00067   std::map<Filter::Ptr, FilterExpanderLabel*> filter_map_;
00068 };
00069 
00070 } // namespace dash
00071 } // namespace unity
00072 
00073 #endif // UNITYSHELL_FILTERBAR_H
00074