diff options
| author | Thomi Richards <thomi.richards@canonical.com> | 2012-11-23 11:26:51 +1300 |
|---|---|---|
| committer | Thomi Richards <thomi.richards@canonical.com> | 2012-11-23 11:26:51 +1300 |
| commit | b9d0dca7985b330370998c1d39d55500cb73109d (patch) | |
| tree | 77ef926064ee8857065365727510acccef039c2c | |
| parent | 7c8cbb3cd670b78bb7908b9ee01f2e7949fa192c (diff) | |
| parent | c71ac9d8174a75ca7e0312e898c43eabad8729b4 (diff) | |
Merged trunk.
(bzr r2895.1.16)
| -rw-r--r-- | CMakeLists.txt | 4 | ||||
| -rwxr-xr-x | dash/CoverflowResultView.cpp | 18 | ||||
| -rwxr-xr-x | dash/CoverflowResultView.h | 6 | ||||
| -rw-r--r-- | dash/DashController.cpp | 4 | ||||
| -rw-r--r-- | dash/DashView.cpp | 18 | ||||
| -rw-r--r-- | dash/FilterAllButton.cpp | 2 | ||||
| -rw-r--r-- | dash/FilterRatingsButton.cpp | 2 | ||||
| -rw-r--r-- | dash/LensBar.cpp | 4 | ||||
| -rw-r--r-- | dash/LensBarIcon.cpp | 2 | ||||
| -rwxr-xr-x | dash/LensView.cpp | 14 | ||||
| -rwxr-xr-x | dash/PlacesGroup.cpp | 21 | ||||
| -rw-r--r-- | dash/PlacesGroup.h | 2 | ||||
| -rw-r--r-- | dash/PreviewStateMachine.cpp | 2 | ||||
| -rw-r--r-- | dash/PreviewStateMachine.h | 2 | ||||
| -rw-r--r-- | dash/ResultView.cpp | 4 | ||||
| -rw-r--r-- | dash/ResultViewGrid.cpp | 12 | ||||
| -rw-r--r-- | dash/ResultViewGrid.h | 2 | ||||
| -rw-r--r-- | debian/changelog | 16 | ||||
| -rw-r--r-- | tests/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | tests/test_text_input.cpp | 116 | ||||
| -rw-r--r-- | unity-shared/DebugDBusInterface.cpp | 1 | ||||
| -rw-r--r-- | unity-shared/StaticCairoText.cpp | 5 | ||||
| -rw-r--r-- | unity-shared/StaticCairoText.h | 1 | ||||
| -rw-r--r-- | unity-shared/TextInput.cpp | 55 | ||||
| -rw-r--r-- | unity-shared/TextInput.h | 41 |
25 files changed, 228 insertions, 127 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index d2ccf1daf..e8edd6443 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -127,12 +127,12 @@ add_custom_command (OUTPUT ${CMAKE_SOURCE_DIR}/po/unity.pot ) if (I18N_SUPPORT) -if (${GETTEXT_FOUND} STREQUAL "TRUE") +if (GETTEXT_FOUND) set (HAVE_GETTEXT true) file (GLOB _translations ${CMAKE_SOURCE_DIR}/po/*.po) GETTEXT_CREATE_TRANSLATIONS (${CMAKE_SOURCE_DIR}/po/${PROJECT_NAME}.pot ALL ${_translations}) -endif (${GETTEXT_FOUND} STREQUAL "TRUE") +endif (GETTEXT_FOUND) endif() # diff --git a/dash/CoverflowResultView.cpp b/dash/CoverflowResultView.cpp index 7c2d04d23..742b0297a 100755 --- a/dash/CoverflowResultView.cpp +++ b/dash/CoverflowResultView.cpp @@ -84,11 +84,11 @@ CoverflowResultItem::CoverflowResultItem(Result& result, CoverflowResultView *pa std::string const& icon_hint = result.icon_hint; std::string icon_name = !icon_hint.empty() ? icon_hint : ". GThemedIcon text-x-preview"; static const int element_size = style.GetTileHeight(); - + icon_texture_ = new IconTexture(icon_name.c_str(), element_size, true); icon_texture_->SinkReference(); icon_texture_->LoadIcon(); - + icon_texture_->texture_updated.connect([&] (nux::BaseTexture *texture) { if (parent_) @@ -168,7 +168,7 @@ CoverflowResultView::Impl::Impl(CoverflowResultView *parent) glib::String proposed_unique_id; g_variant_get(data, "(iss)", &nav_mode, &uri, &proposed_unique_id); - + if (proposed_unique_id.Str() != parent_->unique_id()) return; @@ -176,7 +176,7 @@ CoverflowResultView::Impl::Impl(CoverflowResultView *parent) int current_index = GetIndexForUri(uri); if (nav_mode == -1) // left { - current_index--; + current_index--; } else if (nav_mode == 1) // right { @@ -187,7 +187,7 @@ CoverflowResultView::Impl::Impl(CoverflowResultView *parent) { return; } - + if (nav_mode) { std::string uri = GetUriForIndex(current_index); @@ -198,7 +198,7 @@ CoverflowResultView::Impl::Impl(CoverflowResultView *parent) CoverflowResultView::Impl::~Impl() { - + } int CoverflowResultView::Impl::GetIndexForUri(std::string uri) @@ -228,7 +228,7 @@ CoverflowResultView::CoverflowResultView(NUX_FILE_LINE_DECL) CoverflowResultView::~CoverflowResultView() { - + } void CoverflowResultView::SetModelRenderer(ResultRenderer* renderer) @@ -254,7 +254,7 @@ void CoverflowResultView::RemoveResult(Result& result) pimpl->coverflow_->model()->RemoveItem(item); break; } - } + } } void CoverflowResultView::Draw(nux::GraphicsEngine& GfxContext, bool force_draw) @@ -280,7 +280,7 @@ void CoverflowResultView::DrawContent(nux::GraphicsEngine& GfxContext, bool forc GfxContext.GetRenderStates().SetBlend(current_alpha_blend, current_src_blend_factor, current_dest_blend_factor); } - + if (GetCompositionLayout()) { nux::Geometry geo = GetCompositionLayout()->GetGeometry(); diff --git a/dash/CoverflowResultView.h b/dash/CoverflowResultView.h index 57cc4fa72..d841d211c 100755 --- a/dash/CoverflowResultView.h +++ b/dash/CoverflowResultView.h @@ -39,7 +39,7 @@ public: virtual void AddResult(Result& result); virtual void RemoveResult(Result& result); - + virtual void Activate(std::string const& uri, int index, ActivateType type); protected: @@ -51,9 +51,9 @@ protected: private: struct Impl; Impl* pimpl; -}; +}; } } -#endif \ No newline at end of file +#endif diff --git a/dash/DashController.cpp b/dash/DashController.cpp index dfe0151eb..ffcebe9cc 100644 --- a/dash/DashController.cpp +++ b/dash/DashController.cpp @@ -83,7 +83,7 @@ Controller::Controller() { // Relayout here so the input window size updates. Relayout(); - + window_->PushToFront(); window_->SetInputFocus(); nux::GetWindowCompositor().SetKeyFocusArea(view_->default_focus()); @@ -443,7 +443,7 @@ void Controller::OnBusAcquired(GObject *obj, GAsyncResult *result, gpointer user { LOG_WARNING(logger) << "Object registration failed. Dash DBus interface not available."; } - + g_dbus_node_info_unref(introspection_data); } } diff --git a/dash/DashView.cpp b/dash/DashView.cpp index 8450089c0..566f86b59 100644 --- a/dash/DashView.cpp +++ b/dash/DashView.cpp @@ -266,10 +266,10 @@ void DashView::BuildPreview(Preview::Ptr model) AddChild(preview_container_.GetPointer()); preview_container_->SetParentObject(this); preview_container_->Preview(model, previews::Navigation::NONE); // no swipe left or right - + preview_container_->SetGeometry(layout_->GetGeometry()); preview_displaying_ = true; - + // connect to nav left/right signals to request nav left/right movement. preview_container_->navigate_left.connect([&] () { preview_navigation_mode_ = previews::Navigation::LEFT; @@ -281,7 +281,7 @@ void DashView::BuildPreview(Preview::Ptr model) preview_container_->navigate_right.connect([&] () { preview_navigation_mode_ = previews::Navigation::RIGHT; - + // sends a message to all result views, sending the the uri of the current preview result // and the unique id of the result view that should be handling the results ubus_manager_.SendMessage(UBUS_DASH_PREVIEW_NAVIGATION_REQUEST, g_variant_new("(iss)", 1, last_activated_uri_.c_str(), stored_activated_unique_id_.c_str())); @@ -531,7 +531,7 @@ void DashView::DrawContent(nux::GraphicsEngine& graphics_engine, bool force_draw auto& style = dash::Style::Instance(); renderer_.DrawInner(graphics_engine, content_geo_, GetAbsoluteGeometry(), GetGeometry()); - + nux::Geometry clip_geo = layout_->GetGeometry(); clip_geo.x += style.GetVSeparatorSize(); graphics_engine.PushClippingRectangle(clip_geo); @@ -600,7 +600,7 @@ void DashView::DrawContent(nux::GraphicsEngine& graphics_engine, bool force_draw { layout_->ProcessDraw(graphics_engine, force_draw); } - + // Animation effect rendering if (display_ghost || IsFullRedraw()) { @@ -609,7 +609,7 @@ void DashView::DrawContent(nux::GraphicsEngine& graphics_engine, bool force_draw unsigned int current_dest_blend_factor; graphics_engine.GetRenderStates().GetBlend(current_alpha_blend, current_src_blend_factor, current_dest_blend_factor); - float ghost_opacity = 0.25f; + float ghost_opacity = 0.25f; float tint_factor = 1.2f; float saturation_ref = 0.4f; nux::Color bg_color = background_color_; @@ -643,7 +643,7 @@ void DashView::DrawContent(nux::GraphicsEngine& graphics_engine, bool force_draw nux::Color(fade_out_value_, fade_out_value_, fade_out_value_, fade_out_value_) ); filter_width += active_lens_view_->filter_bar()->GetWidth(); - } + } float saturation = fade_out_value_ + (1.0f - fade_out_value_) * saturation_ref; float opacity = fade_out_value_ < ghost_opacity ? ghost_opacity : fade_out_value_; @@ -1186,7 +1186,7 @@ bool DashView::InspectKeyEvent(unsigned int eventType, search_bar_->search_string = ""; else ubus_manager_.SendMessage(UBUS_PLACE_VIEW_CLOSE_REQUEST); - + return true; } return false; @@ -1439,7 +1439,7 @@ nux::Area* DashView::FindAreaUnderMouse(const nux::Point& mouse_position, nux::N nux::Geometry const& DashView::GetContentGeometry() const { - return content_geo_; + return content_geo_; } } diff --git a/dash/FilterAllButton.cpp b/dash/FilterAllButton.cpp index 013be5690..0ca2b157f 100644 --- a/dash/FilterAllButton.cpp +++ b/dash/FilterAllButton.cpp @@ -38,7 +38,7 @@ FilterAllButton::FilterAllButton(NUX_FILE_LINE_DECL) SetInputEventSensitivity(false); state_change.connect(sigc::mem_fun(this, &FilterAllButton::OnStateChanged)); - + SetRedirectRenderingToTexture(true); //SetCopyPreviousFboTexture(false); SetClearBeforeDraw(true); diff --git a/dash/FilterRatingsButton.cpp b/dash/FilterRatingsButton.cpp index e472051f4..9be5a4015 100644 --- a/dash/FilterRatingsButton.cpp +++ b/dash/FilterRatingsButton.cpp @@ -126,7 +126,7 @@ void FilterRatingsButton::Draw(nux::GraphicsEngine& GfxContext, bool force_draw) for (int index = 0; index < num_stars; ++index) { - Style& style = Style::Instance(); + Style& style = Style::Instance(); nux::BaseTexture* texture = style.GetStarSelectedIcon(); if (index < total_full_stars) { diff --git a/dash/LensBar.cpp b/dash/LensBar.cpp index e35c1058e..c4a6306ee 100644 --- a/dash/LensBar.cpp +++ b/dash/LensBar.cpp @@ -234,8 +234,8 @@ void LensBar::ActivatePrevious() if (activate_previous && icon->IsVisible()) { - SetActive(icon); - return; + SetActive(icon); + return; } if (icon->active) activate_previous = true; diff --git a/dash/LensBarIcon.cpp b/dash/LensBarIcon.cpp index cfb71c4da..783c17302 100644 --- a/dash/LensBarIcon.cpp +++ b/dash/LensBarIcon.cpp @@ -49,7 +49,7 @@ LensBarIcon::LensBarIcon(std::string id_, std::string icon_hint) SetMaximumHeight(FOCUS_OVERLAY_HEIGHT); focus_layer_.reset(Style::Instance().FocusOverlay(FOCUS_OVERLAY_WIDTH, FOCUS_OVERLAY_HEIGHT)); - + SetOpacity(inactive_opacity_); SetAcceptKeyNavFocus(true); diff --git a/dash/LensView.cpp b/dash/LensView.cpp index 76cac5177..815aa49c3 100755 --- a/dash/LensView.cpp +++ b/dash/LensView.cpp @@ -155,12 +155,12 @@ LensView::LensView(Lens::Ptr lens, nux::Area* show_filters) lens_->connected.changed.connect([&](bool is_connected) { if (is_connected) initial_activation_ = true; }); lens_->categories_reordered.connect(sigc::mem_fun(this, &LensView::OnCategoryOrderChanged)); search_string.SetGetterFunction(sigc::mem_fun(this, &LensView::get_search_string)); - filters_expanded.changed.connect([&](bool expanded) - { - fscroll_view_->SetVisible(expanded); - QueueRelayout(); + filters_expanded.changed.connect([&](bool expanded) + { + fscroll_view_->SetVisible(expanded); + QueueRelayout(); OnColumnsChanged(); - ubus_manager_.SendMessage(UBUS_REFINE_STATUS, + ubus_manager_.SendMessage(UBUS_REFINE_STATUS, g_variant_new(UBUS_REFINE_STATUS_FORMAT_STRING, expanded ? TRUE : FALSE)); }); view_type.changed.connect(sigc::mem_fun(this, &LensView::OnViewTypeChanged)); @@ -360,7 +360,7 @@ void LensView::OnCategoryAdded(Category const& category) { case ResultView::ActivateType::DIRECT: { - lens_->Activate(uri); + lens_->Activate(uri); } break; case ResultView::ActivateType::PREVIEW: { @@ -370,7 +370,7 @@ void LensView::OnCategoryAdded(Category const& category) }; }, unique_id)); - + /* Set up filter model for this category */ Results::Ptr results_model = lens_->results; diff --git a/dash/PlacesGroup.cpp b/dash/PlacesGroup.cpp index 82e52e30a..78313ae49 100755 --- a/dash/PlacesGroup.cpp +++ b/dash/PlacesGroup.cpp @@ -195,7 +195,7 @@ PlacesGroup::PlacesGroup(dash::StyleInterface& style) _name->mouse_click.connect(sigc::mem_fun(this, &PlacesGroup::RecvMouseClick)); _expand_label->mouse_click.connect(sigc::mem_fun(this, &PlacesGroup::RecvMouseClick)); _expand_icon->mouse_click.connect(sigc::mem_fun(this, &PlacesGroup::RecvMouseClick)); - + key_nav_focus_change.connect([&](nux::Area* area, bool has_focus, nux::KeyNavDirection direction) { if (!has_focus) @@ -220,7 +220,7 @@ PlacesGroup::PlacesGroup(dash::StyleInterface& style) nux::TexCoordXForm texxform; if (status && _using_nofilters_background) { - _background_layer.reset(new nux::TextureLayer(_background->GetDeviceTexture(), + _background_layer.reset(new nux::TextureLayer(_background->GetDeviceTexture(), texxform, nux::color::White, false, @@ -229,12 +229,12 @@ PlacesGroup::PlacesGroup(dash::StyleInterface& style) } else if (!status && !_using_nofilters_background) { - _background_layer.reset(new nux::TextureLayer(_background_nofilters->GetDeviceTexture(), - texxform, + _background_layer.reset(new nux::TextureLayer(_background_nofilters->GetDeviceTexture(), + texxform, nux::color::White, false, rop)); - + _using_nofilters_background = true; } QueueDraw(); @@ -326,9 +326,9 @@ PlacesGroup::SetChildView(dash::ResultView* view) _group_layout->AddLayout(new nux::SpaceLayout(2,2,2,2), 0); // top padding _group_layout->AddLayout(layout, 1); - view->results_per_row.changed.connect([&] (int results_per_row) + view->results_per_row.changed.connect([&] (int results_per_row) { - _n_visible_items_in_unexpand_mode = results_per_row; + _n_visible_items_in_unexpand_mode = results_per_row; RefreshLabel(); }); @@ -420,7 +420,6 @@ PlacesGroup::OnIdleRelayout() { if (GetChildView()) { - Refresh(); QueueDraw(); @@ -473,7 +472,7 @@ PlacesGroup::DrawContent(nux::GraphicsEngine& graphics_engine, bool force_draw) graphics_engine.GetRenderStates().SetBlend(current_alpha_blend, current_src_blend_factor, current_dest_blend_factor); } - + if (ShouldBeHighlighted()) { nux::Geometry geo(_header_layout->GetGeometry()); @@ -492,10 +491,10 @@ PlacesGroup::DrawContent(nux::GraphicsEngine& graphics_engine, bool force_draw) bg_width = _background->GetWidth(); bg_geo.x = std::max(bg_geo.width - bg_width,0); - + bg_geo.width = std::min(bg_width, bg_geo.GetWidth()) + 1; // to render into a space left over by the scrollview bg_geo.height = _background->GetHeight(); - + _background_layer->SetGeometry(bg_geo); _background_layer->Renderlayer(graphics_engine); diff --git a/dash/PlacesGroup.h b/dash/PlacesGroup.h index 6f068b952..b2e7881b5 100644 --- a/dash/PlacesGroup.h +++ b/dash/PlacesGroup.h @@ -142,7 +142,7 @@ private: unsigned _category_index; std::string _cached_name; nux::Geometry _cached_geometry; - + std::string _renderer_name; bool _coverflow_enabled; diff --git a/dash/PreviewStateMachine.cpp b/dash/PreviewStateMachine.cpp index c64e576e4..c145f07e0 100644 --- a/dash/PreviewStateMachine.cpp +++ b/dash/PreviewStateMachine.cpp @@ -95,7 +95,7 @@ void PreviewStateMachine::CheckPreviewRequirementsFulfilled() if (GetSplitPosition(LENS_BAR) < 0) return; if (GetSplitPosition(SEARCH_BAR) < 0) return; */ - + if (left_results < 0 || right_results < 0) return; diff --git a/dash/PreviewStateMachine.h b/dash/PreviewStateMachine.h index 1652c1583..f98c73f47 100644 --- a/dash/PreviewStateMachine.h +++ b/dash/PreviewStateMachine.h @@ -53,7 +53,7 @@ public: nux::Property<bool> preview_active; nux::Property<int> left_results; nux::Property<int> right_results; - + sigc::signal<void, Preview::Ptr> PreviewActivated; private: diff --git a/dash/ResultView.cpp b/dash/ResultView.cpp index 5d4489462..a53754632 100644 --- a/dash/ResultView.cpp +++ b/dash/ResultView.cpp @@ -223,7 +223,7 @@ debug::Introspectable::IntrospectableList ResultView::GetIntrospectableChildren( // clear children (no delete). RemoveAllChildren(); - + std::set<std::string> existing_results; // re-create list of children. int index = 0; @@ -279,7 +279,7 @@ debug::ResultWrapper* ResultView::CreateResultWrapper(Result const& result, int } void ResultView::UpdateResultWrapper(debug::ResultWrapper* wrapper, Result const& result, int index) -{ +{ } } diff --git a/dash/ResultViewGrid.cpp b/dash/ResultViewGrid.cpp index f2a4dfef1..f48110b58 100644 --- a/dash/ResultViewGrid.cpp +++ b/dash/ResultViewGrid.cpp @@ -106,7 +106,7 @@ ResultViewGrid::ResultViewGrid(NUX_FILE_LINE_DECL) gchar* uri = NULL; gchar* proposed_unique_id = NULL; g_variant_get(data, "(iss)", &nav_mode, &uri, &proposed_unique_id); - + if (std::string(proposed_unique_id) != unique_id()) return; @@ -128,7 +128,7 @@ ResultViewGrid::ResultViewGrid(NUX_FILE_LINE_DECL) LOG_ERROR(logger) << "requested to activated a result that does not exist: " << current_index; return; } - + // closed if (nav_mode == 0) { @@ -506,7 +506,7 @@ void ResultViewGrid::OnKeyNavFocusChange(nux::Area *area, bool has_focus, nux::K focused_uri_ = (*first_iter).uri; selected_index_ = 0; } - + int items_per_row = GetItemsPerRow(); unsigned num_results = GetNumResults(); @@ -519,7 +519,7 @@ void ResultViewGrid::OnKeyNavFocusChange(nux::Area *area, bool has_focus, nux::K int total_rows = std::ceil(num_results / (double)items_per_row); selected_index_ = items_per_row * (total_rows-1); } - + if (direction != nux::KEY_NAV_NONE) { std::tuple<int, int> focused_coord = GetResultPosition(selected_index_); @@ -660,7 +660,7 @@ void ResultViewGrid::Draw(nux::GraphicsEngine& GfxContext, bool force_draw) offset_x = 0; offset_y = 0; } - + nux::Geometry render_geo(x_position, y_position, renderer_->width, renderer_->height); Result result(*GetIteratorAtRow(index)); renderer_->Render(GfxContext, result, state, render_geo, offset_x, offset_y); @@ -764,7 +764,7 @@ std::tuple<int, int> ResultViewGrid::GetResultPosition(const unsigned int& index int items_per_row = GetItemsPerRow(); int column_size = renderer_->width + horizontal_spacing + extra_horizontal_spacing_; int row_size = renderer_->height + vertical_spacing; - + int y = row_size * (index / items_per_row) + padding; int x = column_size * (index % items_per_row) + padding; diff --git a/dash/ResultViewGrid.h b/dash/ResultViewGrid.h index 8a9b4618a..2fdd92da8 100644 --- a/dash/ResultViewGrid.h +++ b/dash/ResultViewGrid.h @@ -52,7 +52,7 @@ public: int GetSelectedIndex(); virtual unsigned GetIndexAtPosition(int x, int y); - + virtual void Activate(std::string const& uri, int index, ActivateType type); protected: diff --git a/debian/changelog b/debian/changelog index be580b796..b28d48427 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -unity (6.12.0-0ubuntu3) UNRELEASED; urgency=low +unity (6.12.0-0ubuntu5) UNRELEASED; urgency=low [ Michael Terry ] * debian/control: @@ -35,6 +35,20 @@ unity (6.12.0-0ubuntu3) UNRELEASED; urgency=low -- Michael Terry <mterry@ubuntu.com> Tue, 06 Nov 2012 10:52:43 -0500 +unity (6.12.0-0ubuntu4) raring; urgency=low + + * Really fix cmake now + + -- Didier Roche <didrocks@ubuntu.com> Thu, 22 Nov 2012 14:51:43 +0100 + +unity (6.12.0-0ubuntu3) raring; urgency=low + + * Apply 2 upstream patches to fix FTBFS on raring: + - gettext cmake support change with new cmake + - include directly iostream needed for std::cout + + -- Didier Roche <didrocks@ubuntu.com> Thu, 22 Nov 2012 12:31:58 +0100 + unity (6.12.0-0ubuntu2) raring; urgency=low * debian/control.in: Recommends gnome-control-center-unity diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 26e80dd29..71f55b6fc 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -243,6 +243,7 @@ if (ENABLE_X_SUPPORT) test_switcher_controller.cpp test_switcher_model.cpp test_texture_cache.cpp + test_text_input.cpp test_thumbnail_generator.cpp test_trash_launcher_icon.cpp test_launcher_minimize_speed.cpp diff --git a/tests/test_text_input.cpp b/tests/test_text_input.cpp new file mode 100644 index 000000000..017aecf42 --- /dev/null +++ b/tests/test_text_input.cpp @@ -0,0 +1,116 @@ +/* + * Copyright 2012 Canonical Ltd. + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser 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 warranties of + * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the applicable version of the GNU Lesser General Public + * License for more details. + * + * You should have received a copy of both the GNU Lesser General Public + * License version 3 along with this program. If not, see + * <http://www.gnu.org/licenses/> + * + * Authored by: Manuel de la Pena <manuel.delapena@canonical.com> + * + */ + + +#include <gtest/gtest.h> + +#include "unity-shared/TextInput.h" +#include "test_utils.h" + +using namespace nux; + +namespace unity +{ + +class TextInputMock : public TextInput +{ + public: + using TextInput::Init; + using TextInput::OnInputHintChanged; + using TextInput::OnMouseButtonDown; + using TextInput::OnEndKeyFocus; + using TextInput::get_input_string; + + + nux::StaticCairoText* GetHint() const { return hint_; } + IMTextEntry* GetPangoEntry() const { return pango_entry_; } +}; + +class TestTextInput : public ::testing::Test +{ + protected: + TestTextInput() + { + entry = new TextInputMock(); + entry->Init(); + hint = entry->GetHint(); + pango_entry = entry->GetPangoEntry(); + } + + nux::ObjectPtr<TextInputMock> entry; + nux::StaticCairoText* hint; + IMTextEntry* pango_entry; +}; + +TEST_F(TestTextInput, HintCorrectInit) +{ + nux::Color color = hint->GetTextColor(); + + EXPECT_EQ(color.red, 1.0f); + EXPECT_EQ(color.green, 1.0f); + EXPECT_EQ(color.blue, 1.0f); + EXPECT_EQ(color.alpha, 0.5f); +} + +TEST_F(TestTextInput, InputStringCorrectSetter) +{ + // set the string and test that we do indeed set the internal va + std::string new_input = "foo"; + entry->input_string.Set(new_input); + EXPECT_EQ(entry->input_string.Get(), new_input); +} + +TEST_F(TestTextInput, HintClearedOnInputHintChanged) +{ + // change the hint and assert that the internal value is correct + hint->SetText("foo"); + entry->OnInputHintChanged(); + EXPECT_EQ(entry->get_input_string(), ""); +} + +TEST_F(TestTextInput, HintHideOnMouseButtonDown) +{ + hint->SetVisible(true); + entry->OnMouseButtonDown(entry->GetBaseWidth()/2, + entry->GetBaseHeight()/2 , 0, 0); + EXPECT_FALSE(hint->IsVisible()); +} + +TEST_F(TestTextInput, HintVisibleOnEndKeyFocus) +{ + // set the text and ensure that later is cleared + pango_entry->SetText("user input"); + entry->OnEndKeyFocus(); + + EXPECT_FALSE(hint->IsVisible()); + +} + +TEST_F(TestTextInput, HintHiddenOnEndKeyFocus) +{ + + pango_entry->SetText(""); + entry->OnEndKeyFocus(); + + EXPECT_TRUE(hint->IsVisible()); +} + +} // unity diff --git a/unity-shared/DebugDBusInterface.cpp b/unity-shared/DebugDBusInterface.cpp index ae07a851b..68c6ef6b2 100644 --- a/unity-shared/DebugDBusInterface.cpp +++ b/unity-shared/DebugDBusInterface.cpp @@ -18,6 +18,7 @@ */ #include <queue> +#include <iostream> #include <fstream> #include <sstream> #include <boost/algorithm/string.hpp> diff --git a/unity-shared/StaticCairoText.cpp b/unity-shared/StaticCairoText.cpp index 7b3ac7729..f3ed86a1e 100644 --- a/unity-shared/StaticCairoText.cpp +++ b/unity-shared/StaticCairoText.cpp @@ -375,6 +375,11 @@ void StaticCairoText::SetFont(std::string const& font) } } +std::string StaticCairoText::GetFont() +{ + return pimpl->font_; +} + int StaticCairoText::GetLineCount() const { return pimpl->actual_lines_; diff --git a/unity-shared/StaticCairoText.h b/unity-shared/StaticCairoText.h index 683afac77..0d9503a89 100644 --- a/unity-shared/StaticCairoText.h +++ b/unity-shared/StaticCairoText.h @@ -72,6 +72,7 @@ public: void SetTextAlignment(AlignState state); void SetTextVerticalAlignment(AlignState state); void SetFont(std::string const& font); + std::string GetFont(); void SetLines(int maximum_lines); void SetLineSpacing(float line_spacing); diff --git a/unity-shared/TextInput.cpp b/unity-shared/TextInput.cpp index 6ce3b50b5..24ee13337 100644 --- a/unity-shared/TextInput.cpp +++ b/unity-shared/TextInput.cpp @@ -17,19 +17,7 @@ * Authored by: Manuel de la Pena <manuel.delapena@canonical.com> */ -#include "config.h" - -#include <Nux/Nux.h> -#include <Nux/HLayout.h> -#include <Nux/VLayout.h> -#include <NuxCore/Logger.h> - -#include <UnityCore/Variant.h> - -#include <glib/gi18n-lib.h> - #include "TextInput.h" -#include "CairoTexture.h" namespace { @@ -51,50 +39,11 @@ const int PANGO_ENTRY_FONT_SIZE = 14; } -DECLARE_LOGGER(logger, "unity.dash.textinput"); -namespace -{ -class ExpanderView : public nux::View -{ -public: - ExpanderView(NUX_FILE_LINE_DECL) - : nux::View(NUX_FILE_LINE_PARAM) - { - SetAcceptKeyNavFocusOnMouseDown(false); - SetAcceptKeyNavFocusOnMouseEnter(true); - } - -protected: - void Draw(nux::GraphicsEngine& graphics_engine, bool force_draw) - {} - - void DrawContent(nux::GraphicsEngine& graphics_engine, bool force_draw) - { - if (GetLayout()) - GetLayout()->ProcessDraw(graphics_engine, force_draw); - } - - bool AcceptKeyNavFocus() - { - return true; - } - - nux::Area* FindAreaUnderMouse(const nux::Point& mouse_position, nux::NuxEventType event_type) - { - bool mouse_inside = TestMousePointerInclusionFilterMouseWheel(mouse_position, event_type); - - if (mouse_inside == false) - return nullptr; - - return this; - } -}; - -} - namespace unity { +nux::logging::Logger logger("unity.dash.textinput"); + NUX_IMPLEMENT_OBJECT_TYPE(TextInput); TextInput::TextInput(NUX_FILE_LINE_DECL) diff --git a/unity-shared/TextInput.h b/unity-shared/TextInput.h index e68f29262..ddcea004c 100644 --- a/unity-shared/TextInput.h +++ b/unity-shared/TextInput.h @@ -20,14 +20,22 @@ #ifndef TEXTINPUT_H #define TEXTINPUT_H +#include <glib/gi18n-lib.h> #include <gtk/gtk.h> -#include <NuxCore/Property.h> + +#include <Nux/Nux.h> +#include <Nux/HLayout.h> #include <Nux/LayeredLayout.h> #include <Nux/VLayout.h> #include <Nux/TextEntry.h> +#include <NuxCore/Logger.h> +#include <NuxCore/Property.h> #include <UnityCore/GLibSignal.h> #include <UnityCore/GLibSource.h> +#include <UnityCore/Variant.h> +#include "config.h" +#include "CairoTexture.h" #include "unity-shared/IconTexture.h" #include "unity-shared/IMTextEntry.h" #include "unity-shared/Introspectable.h" @@ -41,10 +49,10 @@ class LinearLayout; namespace unity { - class TextInput : public unity::debug::Introspectable, public nux::View { NUX_DECLARE_OBJECT_TYPE(TextInput, nux::View); + public: typedef nux::ObjectPtr<TextInput> Ptr; TextInput(NUX_FILE_LINE_PROTO); @@ -59,42 +67,49 @@ public: private: - void Init(); - void OnFontChanged(GtkSettings* settings, GParamSpec* pspec=NULL); - void OnInputHintChanged(); - void Draw(nux::GraphicsEngine& GfxContext, bool force_draw); void DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw); + void UpdateBackground(bool force); + + std::string GetName() const; + + void AddProperties(GVariantBuilder* builder); + bool AcceptKeyNavFocus(); + +protected: - void OnMouseButtonDown(int x, int y, unsigned long button_flags, unsigned long key_flags); + void Init(); + void OnInputHintChanged(); + void OnMouseButtonDown(int x, int y, unsigned long button_flags, + unsigned long key_flags); void OnEndKeyFocus(); - void UpdateBackground(bool force); + // getters & setters std::string get_input_string() const; bool set_input_string(std::string const& string); bool get_im_active() const; bool get_im_preedit() const; - std::string GetName() const; - void AddProperties(GVariantBuilder* builder); - bool AcceptKeyNavFocus(); + // instance vars + nux::StaticCairoText* hint_; + IMTextEntry* pango_entry_; private: + bool ShouldBeHighlighted(); std::unique_ptr<nux::AbstractPaintLayer> bg_layer_; std::unique_ptr<nux::AbstractPaintLayer> highlight_layer_; nux::HLayout* layout_; nux::LayeredLayout* layered_layout_; - nux::StaticCairoText* hint_; - IMTextEntry* pango_entry_; int last_width_; int last_height_; glib::SignalManager sig_manager_; + }; } |
