Back to index

unity  6.0.0
FilterExpanderLabel.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_FILTEREXPANDERLABEL_H
00024 #define UNITYSHELL_FILTEREXPANDERLABEL_H
00025 
00026 #include <memory>
00027 
00028 #include <Nux/Nux.h>
00029 #include <Nux/GridHLayout.h>
00030 #include <Nux/HLayout.h>
00031 #include <Nux/View.h>
00032 #include <Nux/VLayout.h>
00033 #include <UnityCore/Filter.h>
00034 
00035 #include "unity-shared/IconTexture.h"
00036 #include "unity-shared/Introspectable.h"
00037 #include "unity-shared/StaticCairoText.h"
00038 
00039 namespace nux
00040 {
00041 class AbstractPaintLayer;
00042 }
00043 
00044 namespace unity
00045 {
00046 
00047 class HSeparator;
00048 
00049 namespace dash
00050 {
00051 
00052 class FilterExpanderLabel : public nux::View,  public debug::Introspectable
00053 {
00054   NUX_DECLARE_OBJECT_TYPE(FilterExpanderLabel, nux::View);
00055 public:
00056   FilterExpanderLabel(std::string const& label, NUX_FILE_LINE_PROTO);
00057   virtual ~FilterExpanderLabel();
00058 
00059   void SetRightHandView(nux::View* view);
00060   void SetLabel(std::string const& label);
00061   void SetContents(nux::Layout* layout);
00062 
00063   virtual void SetFilter(Filter::Ptr const& filter) = 0;
00064   virtual std::string GetFilterType() = 0;
00065 
00066   nux::Property<bool> expanded;
00067   nux::Property<bool> draw_separator;
00068 
00069 protected:
00070   virtual bool AcceptKeyNavFocus();
00071   virtual void Draw(nux::GraphicsEngine& GfxContext, bool force_draw);
00072   virtual void DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw);
00073 
00074   // Introspection
00075   virtual std::string GetName() const;
00076   virtual void AddProperties(GVariantBuilder* builder);
00077 
00078 private:
00079   void BuildLayout();
00080   void DoExpandChange(bool change);
00081   bool ShouldBeHighlighted();
00082 
00083   nux::LinearLayout* layout_;
00084   nux::LinearLayout* top_bar_layout_;
00085   nux::View* expander_view_;
00086   nux::LinearLayout* expander_layout_;
00087   nux::View* right_hand_contents_;
00088   nux::StaticCairoText* cairo_label_;
00089   std::string raw_label_;
00090   std::string label_;
00091   nux::VLayout* arrow_layout_;
00092   nux::SpaceLayout* arrow_top_space_;
00093   nux::SpaceLayout* arrow_bottom_space_;
00094   IconTexture* expand_icon_;
00095   HSeparator* separator_;
00096   nux::SpaceLayout* space_;
00097 
00098   nux::ObjectPtr<nux::Layout> contents_;
00099   std::unique_ptr<nux::AbstractPaintLayer> highlight_layer_;
00100 };
00101 
00102 } // namespace dash
00103 } // namespace unity
00104 
00105 #endif // UNITYSHELL_FILTEREXPANDERLABEL_H