diff options
| author | Nick Dedekind <nicholas.dedekind@gmail.com> | 2012-07-12 16:54:25 +0100 |
|---|---|---|
| committer | Nick Dedekind <nicholas.dedekind@gmail.com> | 2012-07-12 16:54:25 +0100 |
| commit | 706b1b5f07aa5211e1223b1d52b049f3f343f42c (patch) | |
| tree | fc727841530aa07a63bb982b55e66799d794d85e /hud | |
| parent | 5cbcbb7692ee02c5f83cc1944750e94ae123af4d (diff) | |
| parent | 736d0528f0f6721f7cf2f14af156b74dadef91cc (diff) | |
Merged with trunk
(bzr r2419.4.16)
Diffstat (limited to 'hud')
| -rw-r--r-- | hud/CMakeLists.txt | 7 | ||||
| -rw-r--r-- | hud/HudButton.cpp | 31 | ||||
| -rw-r--r-- | hud/HudButton.h | 10 | ||||
| -rw-r--r-- | hud/HudController.cpp | 9 | ||||
| -rw-r--r-- | hud/HudView.cpp | 48 | ||||
| -rw-r--r-- | hud/HudView.h | 4 |
6 files changed, 86 insertions, 23 deletions
diff --git a/hud/CMakeLists.txt b/hud/CMakeLists.txt index 294ba8a6a..4da89417c 100644 --- a/hud/CMakeLists.txt +++ b/hud/CMakeLists.txt @@ -10,13 +10,14 @@ set (CFLAGS "-I${CMAKE_CURRENT_BINARY_DIR}" ) -if (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64") +if (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64" OR ${CMAKE_SYSTEM_PROCESSOR} STREQUAL "armv7l") set (CFLAGS ${CFLAGS} "-fPIC") -endif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64") +endif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64" OR ${CMAKE_SYSTEM_PROCESSOR} STREQUAL "armv7l") add_definitions (${CFLAGS}) -set (LIBS ${CACHED_UNITY_DEPS_LIBRARIES} "-lunity-core-${UNITY_API_VERSION} -lm -lGL -lGLU") +set (LIBS ${CACHED_UNITY_DEPS_LIBRARIES} ${UNITY_STANDALONE_LADD}) + link_libraries (${LIBS}) set (LIB_PATHS ${CACHED_UNITY_DEPS_LIBRARY_DIRS}) diff --git a/hud/HudButton.cpp b/hud/HudButton.cpp index 13b889b50..435ae0126 100644 --- a/hud/HudButton.cpp +++ b/hud/HudButton.cpp @@ -28,7 +28,7 @@ #include <Nux/Nux.h> #include <Nux/HLayout.h> #include <NuxCore/Logger.h> -#include <NuxImage/CairoGraphics.h> +#include <NuxGraphics/CairoGraphics.h> #include <NuxGraphics/NuxGraphics.h> #include <UnityCore/GLibWrapper.h> #include <UnityCore/Variant.h> @@ -52,10 +52,13 @@ namespace unity namespace hud { +NUX_IMPLEMENT_OBJECT_TYPE(HudButton); + HudButton::HudButton(NUX_FILE_LINE_DECL) : nux::Button(NUX_FILE_LINE_PARAM) , is_rounded(false) , is_focused_(false) + , skip_draw_(true) { hlayout_ = new nux::HLayout(NUX_TRACKER_LOCATION); hlayout_->SetLeftAndRightPadding(hlayout_left_padding, -1); @@ -106,7 +109,7 @@ void HudButton::RedrawTheme(nux::Geometry const& geom, cairo_t* cr, nux::ButtonV bool HudButton::AcceptKeyNavFocus() { - // The button will not receive the keyboard focus. The keyboard focus is always to remain with the + // The button will not receive the keyboard focus. The keyboard focus is always to remain with the // text entry in the hud. return false; } @@ -131,7 +134,11 @@ long HudButton::ComputeContentSize() void HudButton::Draw(nux::GraphicsEngine& GfxContext, bool force_draw) { + if (skip_draw_) + return; + nux::Geometry const& geo = GetGeometry(); + GfxContext.PushClippingRectangle(geo); gPainter.PaintBackground(GfxContext, geo); // set up our texture mode @@ -171,12 +178,21 @@ void HudButton::Draw(nux::GraphicsEngine& GfxContext, bool force_draw) nux::color::White); GfxContext.GetRenderStates().SetBlend(alpha, src, dest); + + GfxContext.PopClippingRectangle(); } void HudButton::DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw) { + if (skip_draw_) + return; + if (IsFullRedraw()) + { + GfxContext.PushClippingRectangle(GetGeometry()); hlayout_->ProcessDraw(GfxContext, force_draw); + GfxContext.PopClippingRectangle(); + } } void HudButton::SetQuery(Query::Ptr query) @@ -189,7 +205,7 @@ void HudButton::SetQuery(Query::Ptr query) hlayout_->Clear(); for (auto item : items) { - nux::StaticCairoText* text = new nux::StaticCairoText(item.first.c_str()); + nux::StaticCairoText* text = new nux::StaticCairoText(item.first); text->SetTextColor(nux::Color(1.0f, 1.0f, 1.0f, item.second ? 1.0f : 0.5f)); text->SetFont(button_font); hlayout_->AddView(text, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL); @@ -201,6 +217,12 @@ Query::Ptr HudButton::GetQuery() return query_; } +void HudButton::SetSkipDraw(bool skip_draw) +{ + skip_draw_ = skip_draw; +} + + // Introspectable std::string HudButton::GetName() const { @@ -210,7 +232,8 @@ std::string HudButton::GetName() const void HudButton::AddProperties(GVariantBuilder* builder) { variant::BuilderWrapper(builder) - .add("label", label()); + .add("label", label()) + .add("focused", fake_focused()); } } // namespace hud diff --git a/hud/HudButton.h b/hud/HudButton.h index 555f5ab38..9ccf43d14 100644 --- a/hud/HudButton.h +++ b/hud/HudButton.h @@ -38,8 +38,8 @@ namespace hud class HudButton : public nux::Button, public unity::debug::Introspectable { - typedef nux::ObjectPtr<nux::BaseTexture> BaseTexturePtr; - typedef std::unique_ptr<nux::CairoWrapper> NuxCairoPtr; + NUX_DECLARE_OBJECT_TYPE(HudButton, nux::Button); + public: typedef nux::ObjectPtr<HudButton> Ptr; @@ -48,6 +48,8 @@ public: void SetQuery(Query::Ptr query); std::shared_ptr<Query> GetQuery(); + void SetSkipDraw(bool skip_draw); + nux::Property<std::string> label; nux::Property<bool> is_rounded; nux::Property<bool> fake_focused; @@ -65,9 +67,13 @@ protected: void RedrawTheme(nux::Geometry const& geom, cairo_t* cr, nux::ButtonVisualState faked_state); private: + typedef std::unique_ptr<nux::CairoWrapper> NuxCairoPtr; + Query::Ptr query_; nux::Geometry cached_geometry_; + bool is_focused_; + bool skip_draw_; NuxCairoPtr prelight_; NuxCairoPtr active_; diff --git a/hud/HudController.cpp b/hud/HudController.cpp index f2f05805a..7f9bc75e3 100644 --- a/hud/HudController.cpp +++ b/hud/HudController.cpp @@ -75,7 +75,9 @@ Controller::Controller(std::function<AbstractView*(void)> const& function) launcher_width.changed.connect([&] (int new_width) { Relayout(); }); - WindowManager::Default()->compiz_screen_ungrabbed.connect(sigc::mem_fun(this, &Controller::OnScreenUngrabbed)); + auto wm = WindowManager::Default(); + wm->compiz_screen_ungrabbed.connect(sigc::mem_fun(this, &Controller::OnScreenUngrabbed)); + wm->initiate_spread.connect(sigc::bind(sigc::mem_fun(this, &Controller::HideHud), true)); hud_service_.queries_updated.connect(sigc::mem_fun(this, &Controller::OnQueriesFinished)); timeline_animator_.animation_updated.connect(sigc::mem_fun(this, &Controller::OnViewShowHideFrame)); @@ -93,10 +95,11 @@ void Controller::SetupWindow() window_->mouse_down_outside_pointer_grab_area.connect(sigc::mem_fun(this, &Controller::OnMouseDownOutsideWindow)); /* FIXME - first time we load our windows there is a race that causes the input window not to actually get input, this side steps that by causing an input window show and hide before we really need it. */ - WindowManager::Default()->saveInputFocus (); + auto wm = WindowManager::Default(); + wm->saveInputFocus (); window_->EnableInputWindow(true, "Hud", true, false); window_->EnableInputWindow(false, "Hud", true, false); - WindowManager::Default()->restoreInputFocus (); + wm->restoreInputFocus (); } void Controller::SetupHudView() diff --git a/hud/HudView.cpp b/hud/HudView.cpp index 6c0e02531..54e77f1f5 100644 --- a/hud/HudView.cpp +++ b/hud/HudView.cpp @@ -27,6 +27,8 @@ #include <Nux/HLayout.h> #include <Nux/VLayout.h> +#include "unity-shared/Introspectable.h" + #include "unity-shared/UBusMessages.h" #include "unity-shared/DashStyle.h" @@ -116,10 +118,6 @@ View::View() View::~View() { - for (auto button = buttons_.begin(); button != buttons_.end(); button++) - { - RemoveChild((*button).GetPointer()); - } } void View::ProcessGrowShrink() @@ -149,6 +147,11 @@ void View::ProcessGrowShrink() current_height_ = new_height; } + for (auto button : buttons_) + { + button->SetSkipDraw((button->GetAbsoluteY() + button->GetBaseHeight()) > (GetAbsoluteY() + current_height_)); + } + QueueDraw(); if (diff > grow_anim_length + pause_before_grow_length) @@ -238,6 +241,8 @@ void View::SetQueries(Hud::Queries queries) HudButton::Ptr button(new HudButton()); buttons_.push_front(button); + button->SetMinimumWidth(content_width); + button->SetMaximumWidth(content_width); button->SetQuery(query); button_views_->AddView(button.GetPointer(), 0, nux::MINOR_POSITION_LEFT); @@ -250,12 +255,11 @@ void View::SetQueries(Hud::Queries queries) query_activated.emit(dynamic_cast<HudButton*>(area)->GetQuery()); }); - button->key_nav_focus_change.connect([&](nux::Area* area, bool recieving, KeyNavDirection direction){ + button->key_nav_focus_change.connect([&](nux::Area* area, bool recieving, nux::KeyNavDirection direction){ if (recieving) query_selected.emit(dynamic_cast<HudButton*>(area)->GetQuery()); }); - button->SetMinimumWidth(content_width); ++found_items; } @@ -350,7 +354,7 @@ void View::SetupViews() { dash::Style& style = dash::Style::Instance(); - nux::VLayout* super_layout = new nux::VLayout(); + nux::VLayout* super_layout = new nux::VLayout(); layout_ = new nux::HLayout(); { // fill layout with icon @@ -398,7 +402,7 @@ void View::OnSearchChanged(std::string const& search_string) { button->fake_focused = false; } - + if (!buttons_.empty()) buttons_.back()->fake_focused = true; } @@ -417,7 +421,9 @@ void View::OnKeyDown (unsigned long event_type, unsigned long keysym, void View::OnMouseButtonDown(int x, int y, unsigned long button, unsigned long key) { - if (!content_geo_.IsPointInside(x, y)) + nux::Geometry current_geo(content_geo_); + current_geo.height = current_height_; + if (!current_geo.IsPointInside(x, y)) { ubus.SendMessage(UBUS_HUD_CLOSE_REQUEST); } @@ -457,7 +463,7 @@ void View::DrawContent(nux::GraphicsEngine& gfx_context, bool force_draw) x += content_width - 1; nux::GetPainter().Draw2DLine(gfx_context, x, y, x, y + height, nux::color::White * 0.13); } - + GetLayout()->ProcessDraw(gfx_context, force_draw); nux::GetPainter().PopBackgroundStack(); } @@ -500,6 +506,18 @@ void View::AddProperties(GVariantBuilder* builder) .add("num_buttons", num_buttons); } +debug::Introspectable::IntrospectableList View::GetIntrospectableChildren() +{ + introspectable_children_.clear(); + introspectable_children_.merge(debug::Introspectable::GetIntrospectableChildren()); + for (auto button: buttons_) + { + introspectable_children_.push_front(button.GetPointer()); + } + + return introspectable_children_; +} + bool View::InspectKeyEvent(unsigned int eventType, unsigned int key_sym, const char* character) @@ -547,6 +565,10 @@ nux::Area* View::FindKeyFocusArea(unsigned int event_type, unsigned long x11_key_code, unsigned long special_keys_state) { + // Only care about states of Alt, Ctrl, Super, Shift, not the lock keys + special_keys_state &= (nux::NUX_STATE_ALT | nux::NUX_STATE_CTRL | + nux::NUX_STATE_SUPER | nux::NUX_STATE_SHIFT); + nux::KeyNavDirection direction = nux::KEY_NAV_NONE; switch (x11_key_code) { @@ -573,6 +595,12 @@ nux::Area* View::FindKeyFocusArea(unsigned int event_type, // Not sure if Enter should be a navigation key direction = nux::KEY_NAV_ENTER; break; + case NUX_VK_F4: + if (special_keys_state == nux::NUX_STATE_ALT) + { + ubus.SendMessage(UBUS_HUD_CLOSE_REQUEST); + } + break; default: direction = nux::KEY_NAV_NONE; break; diff --git a/hud/HudView.h b/hud/HudView.h index ca1e1a6f4..8e654b49f 100644 --- a/hud/HudView.h +++ b/hud/HudView.h @@ -61,7 +61,7 @@ public: void AboutToHide(); void SetWindowGeometry(nux::Geometry const& absolute_geo, nux::Geometry const& geo); - + protected: virtual Area* FindKeyFocusArea(unsigned int event_type, unsigned long x11_key_code, @@ -87,6 +87,7 @@ private: std::string GetName() const; void AddProperties(GVariantBuilder* builder); + IntrospectableList GetIntrospectableChildren(); private: UBusManager ubus; @@ -94,6 +95,7 @@ private: nux::ObjectPtr<nux::Layout> content_layout_; nux::ObjectPtr<nux::VLayout> button_views_; std::list<HudButton::Ptr> buttons_; + IntrospectableList introspectable_children_; //FIXME - replace with dash search bar once modifications to dash search bar land SearchBar::Ptr search_bar_; |
