// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
/*
* Copyright (C) 2010, 2011 Canonical Ltd
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Authored by: Neil Jagdish Patel
*/
#ifndef UNITY_LENS_VIEW_H_
#define UNITY_LENS_VIEW_H_
#include
#include
#include
#include
#include
#include
#include
#include
#include "FilterBar.h"
#include "unity-shared/Introspectable.h"
#include "PlacesGroup.h"
#include "PlacesVScrollBar.h"
#include "ResultViewGrid.h"
#include "unity-shared/UBusWrapper.h"
namespace unity
{
namespace dash
{
class LensScrollView;
class LensView : public nux::View, public unity::debug::Introspectable
{
NUX_DECLARE_OBJECT_TYPE(LensView, nux::View);
typedef std::vector CategoryGroups;
typedef std::map ResultCounts;
public:
LensView();
LensView(Lens::Ptr lens, nux::Area* show_filters);
CategoryGroups& categories() { return categories_; }
FilterBar* filter_bar() const { return filter_bar_; }
Lens::Ptr lens() const;
nux::Area* fscroll_view() const;
int GetNumRows();
void JumpToTop();
virtual void ActivateFirst();
nux::ROProperty search_string;
nux::Property filters_expanded;
nux::Property view_type;
nux::Property can_refine_search;
sigc::signal uri_activated;
void PerformSearch(std::string const& search_query);
void CheckNoResults(Lens::Hints const& hints);
void HideResultsMessage();
private:
void SetupViews(nux::Area* show_filters);
void SetupCategories();
void SetupResults();
void SetupFilters();
void OnCategoryAdded(Category const& category);
void OnResultAdded(Result const& result);
void OnResultRemoved(Result const& result);
void UpdateCounts(PlacesGroup* group);
void OnGroupExpanded(PlacesGroup* group);
void OnColumnsChanged();
void OnFilterAdded(Filter::Ptr filter);
void OnFilterRemoved(Filter::Ptr filter);
void OnViewTypeChanged(ViewType view_type);
void QueueFixRenderering();
bool FixRenderering();
virtual void Draw(nux::GraphicsEngine& gfx_context, bool force_draw);
virtual void DrawContent(nux::GraphicsEngine& gfx_context, bool force_draw);
virtual bool AcceptKeyNavFocus();
virtual std::string GetName() const;
virtual void AddProperties(GVariantBuilder* builder);
std::string get_search_string() const;
private:
Lens::Ptr lens_;
CategoryGroups categories_;
ResultCounts counts_;
bool initial_activation_;
bool no_results_active_;
std::string search_string_;
nux::HLayout* layout_;
LensScrollView* scroll_view_;
nux::VLayout* scroll_layout_;
LensScrollView* fscroll_view_;
nux::VLayout* fscroll_layout_;
FilterBar* filter_bar_;
nux::StaticCairoText* no_results_;
UBusManager ubus_manager_;
glib::Source::UniquePtr fix_rendering_idle_;
};
}
}
#endif