diff options
| author | handsome_feng <445865575@qq.com> | 2015-12-23 09:16:53 +0800 |
|---|---|---|
| committer | handsome_feng <445865575@qq.com> | 2015-12-23 09:16:53 +0800 |
| commit | 2432f4191405393ca5272008b4306aea7296e311 (patch) | |
| tree | 93758906906a817c585511b1915a68957f465383 | |
| parent | df4cda7e759f303159fd9993ea5d9dc4ae26d12d (diff) | |
| parent | 1d05db764d9a136b00e3781db30935257932173a (diff) | |
merging lp:~3v1n0/unity/rotated-improvements
(bzr r3999.7.15)
| -rw-r--r-- | dash/DashController.cpp | 31 | ||||
| -rw-r--r-- | hud/HudController.cpp | 16 | ||||
| -rw-r--r-- | launcher/BFBLauncherIcon.cpp | 7 | ||||
| -rw-r--r-- | launcher/BFBLauncherIcon.h | 2 | ||||
| -rw-r--r-- | launcher/EdgeBarrierController.cpp | 50 | ||||
| -rw-r--r-- | launcher/HudLauncherIcon.cpp | 8 | ||||
| -rw-r--r-- | launcher/HudLauncherIcon.h | 5 | ||||
| -rw-r--r-- | launcher/Launcher.cpp | 115 | ||||
| -rw-r--r-- | launcher/LauncherController.cpp | 41 | ||||
| -rw-r--r-- | launcher/LauncherControllerPrivate.h | 8 | ||||
| -rw-r--r-- | tests/test_bfb_launcher_icon.cpp | 2 | ||||
| -rw-r--r-- | tests/test_hud_launcher_icon.cpp | 2 | ||||
| -rw-r--r-- | unity-shared/IconRenderer.cpp | 45 | ||||
| -rw-r--r-- | unity-shared/UnitySettings.cpp | 10 | ||||
| -rw-r--r-- | unity-shared/UnitySettings.h | 4 |
15 files changed, 149 insertions, 197 deletions
diff --git a/dash/DashController.cpp b/dash/DashController.cpp index 38a29449c..26c636676 100644 --- a/dash/DashController.cpp +++ b/dash/DashController.cpp @@ -231,25 +231,22 @@ int Controller::GetIdealMonitor() nux::Geometry Controller::GetIdealWindowGeometry() { UScreen *uscreen = UScreen::GetDefault(); - auto monitor_geo = uscreen->GetMonitorGeometry(GetIdealMonitor()); + auto ideal_geo = uscreen->GetMonitorGeometry(GetIdealMonitor()); int launcher_size = unity::Settings::Instance().LauncherSize(monitor_); + // We want to cover as much of the screen as possible to grab any mouse events outside + // of our window if (Settings::Instance().launcher_position() == LauncherPosition::LEFT) { - // We want to cover as much of the screen as possible to grab any mouse events outside - // of our window - return nux::Geometry (monitor_geo.x + launcher_size, - monitor_geo.y, - monitor_geo.width - launcher_size, - monitor_geo.height); + ideal_geo.x += launcher_size; + ideal_geo.width -= launcher_size; } else { - return nux::Geometry (monitor_geo.x, - monitor_geo.y, - monitor_geo.width, - monitor_geo.height - launcher_size ); + ideal_geo.height -= launcher_size; } + + return ideal_geo; } void Controller::Relayout(bool check_monitor) @@ -263,13 +260,13 @@ void Controller::Relayout(bool check_monitor) view_->Relayout(); window_->SetGeometry(geo); + + int horizontal_offset = 0; + if (Settings::Instance().launcher_position() == LauncherPosition::LEFT) - { - int launcher_width = unity::Settings::Instance().LauncherSize(monitor_); - view_->SetMonitorOffset(launcher_width, panel::Style::Instance().PanelHeight(monitor_)); - } - else - view_->SetMonitorOffset(0, panel::Style::Instance().PanelHeight(monitor_)); + horizontal_offset = unity::Settings::Instance().LauncherSize(monitor_); + + view_->SetMonitorOffset(horizontal_offset, panel::Style::Instance().PanelHeight(monitor_)); } void Controller::OnMouseDownOutsideWindow(int x, int y, diff --git a/hud/HudController.cpp b/hud/HudController.cpp index d87ef9ed5..93ac38e0f 100644 --- a/hud/HudController.cpp +++ b/hud/HudController.cpp @@ -174,7 +174,7 @@ int Controller::GetIdealMonitor() bool Controller::IsLockedToLauncher(int monitor) { - if (launcher_locked_out) + if (launcher_locked_out && Settings::Instance().launcher_position() == LauncherPosition::LEFT) { int primary_monitor = UScreen::GetDefault()->GetPrimaryMonitor(); @@ -253,17 +253,9 @@ nux::Geometry Controller::GetIdealWindowGeometry() if (IsLockedToLauncher(ideal_monitor)) { - if (Settings::Instance().launcher_position() == LauncherPosition::LEFT) - { - int launcher_width = unity::Settings::Instance().LauncherSize(ideal_monitor); - geo.x += launcher_width; - geo.width -= launcher_width; - } - else - { - int launcher_height = unity::Settings::Instance().LauncherSize(ideal_monitor); - geo.height -= launcher_height; - } + int launcher_width = unity::Settings::Instance().LauncherSize(ideal_monitor); + geo.x += launcher_width; + geo.width -= launcher_width; } return geo; diff --git a/launcher/BFBLauncherIcon.cpp b/launcher/BFBLauncherIcon.cpp index 12c8a80bc..dfa621ec1 100644 --- a/launcher/BFBLauncherIcon.cpp +++ b/launcher/BFBLauncherIcon.cpp @@ -30,10 +30,10 @@ namespace unity namespace launcher { -BFBLauncherIcon::BFBLauncherIcon(LauncherHideMode hide_mode) +BFBLauncherIcon::BFBLauncherIcon() : SimpleLauncherIcon(IconType::HOME) , reader_(dash::GSettingsScopesReader::GetDefault()) - , launcher_hide_mode_(hide_mode) + , launcher_hide_mode_(LAUNCHER_HIDE_NEVER) { icon_name = PKGDATADIR"/launcher_bfb.png"; position = Position::BEGIN; @@ -73,7 +73,8 @@ void BFBLauncherIcon::OnOverlayShown(GVariant *data, bool visible) // If the hud is open, we hide the BFB if we have a locked launcher else if (overlay_identity.Str() == "hud") { - if (launcher_hide_mode_ == LAUNCHER_HIDE_NEVER) + if (launcher_hide_mode_ == LAUNCHER_HIDE_NEVER && + Settings::Instance().launcher_position() == LauncherPosition::LEFT) { SetVisibleOnMonitor(overlay_monitor, !visible); SkipQuirkAnimation(Quirk::VISIBLE, overlay_monitor); diff --git a/launcher/BFBLauncherIcon.h b/launcher/BFBLauncherIcon.h index 0c03ddb81..75bf0b64a 100644 --- a/launcher/BFBLauncherIcon.h +++ b/launcher/BFBLauncherIcon.h @@ -37,7 +37,7 @@ class BFBLauncherIcon : public SimpleLauncherIcon { public: - BFBLauncherIcon(LauncherHideMode hide_mode); + BFBLauncherIcon(); virtual nux::Color BackgroundColor() const; virtual nux::Color GlowColor(); diff --git a/launcher/EdgeBarrierController.cpp b/launcher/EdgeBarrierController.cpp index 297e2b132..3b706bbe8 100644 --- a/launcher/EdgeBarrierController.cpp +++ b/launcher/EdgeBarrierController.cpp @@ -23,6 +23,7 @@ #include "EdgeBarrierControllerPrivate.h" #include "Decaymulator.h" #include <NuxCore/Logger.h> +#include "unity-shared/UnitySettings.h" #include "unity-shared/UScreen.h" #include "UnityCore/GLibSource.h" @@ -93,6 +94,7 @@ EdgeBarrierController::Impl::Impl(EdgeBarrierController *parent) }));*/ uscreen->changed.connect(sigc::mem_fun(this, &EdgeBarrierController::Impl::OnUScreenChanged)); + Settings::Instance().launcher_position.changed.connect(sigc::hide(sigc::mem_fun(this, &EdgeBarrierController::Impl::OnOptionsChanged))); parent_->force_disable.changed.connect(sigc::mem_fun(this, &EdgeBarrierController::Impl::OnForceDisableChanged)); @@ -172,7 +174,6 @@ void EdgeBarrierController::Impl::ResizeBarrierList(std::vector<nux::Geometry> c { vertical_barriers_.clear(); horizontal_barriers_.clear(); - horizontal_bottom_barriers_.clear(); return; } @@ -184,9 +185,6 @@ void EdgeBarrierController::Impl::ResizeBarrierList(std::vector<nux::Geometry> c if (horizontal_barriers_.size() > num_monitors) horizontal_barriers_.resize(num_monitors); - if (horizontal_bottom_barriers_.size() > num_monitors) - horizontal_bottom_barriers_.resize(num_monitors); - while (vertical_barriers_.size() < num_monitors) { auto barrier = std::make_shared<PointerBarrierWrapper>(); @@ -202,14 +200,6 @@ void EdgeBarrierController::Impl::ResizeBarrierList(std::vector<nux::Geometry> c barrier->barrier_event.connect(sigc::mem_fun(this, &EdgeBarrierController::Impl::OnPointerBarrierEvent)); horizontal_barriers_.push_back(barrier); } - - while (horizontal_bottom_barriers_.size() < num_monitors) - { - auto barrier = std::make_shared<PointerBarrierWrapper>(); - barrier->orientation = VERTICAL; - barrier->barrier_event.connect(sigc::mem_fun(this, &EdgeBarrierController::Impl::OnPointerBarrierEvent)); - horizontal_bottom_barriers_.push_back(barrier); - } } void SetupXI2Events() @@ -230,17 +220,16 @@ void EdgeBarrierController::Impl::SetupBarriers(std::vector<nux::Geometry> const return; bool edge_resist = parent_->sticky_edges(); + auto launcher_position = Settings::Instance().launcher_position(); for (unsigned i = 0; i < layout.size(); i++) { auto vertical_barrier = vertical_barriers_[i]; auto horizontal_barrier = horizontal_barriers_[i]; - auto horizontal_bottom_barrier = horizontal_bottom_barriers_[i]; auto monitor = layout[i]; vertical_barrier->DestroyBarrier(); horizontal_barrier->DestroyBarrier(); - horizontal_bottom_barrier->DestroyBarrier(); if (edge_resist) { @@ -260,28 +249,27 @@ void EdgeBarrierController::Impl::SetupBarriers(std::vector<nux::Geometry> const if (!edge_resist && parent_->options()->hide_mode() == launcher::LauncherHideMode::LAUNCHER_HIDE_NEVER) continue; - vertical_barrier->x1 = monitor.x; - vertical_barrier->x2 = monitor.x; - vertical_barrier->y1 = monitor.y; - vertical_barrier->y2 = monitor.y + monitor.height; - vertical_barrier->index = i; + if (launcher_position == LauncherPosition::LEFT) + { + vertical_barrier->x1 = monitor.x; + vertical_barrier->x2 = monitor.x; + vertical_barrier->y1 = monitor.y; + vertical_barrier->y2 = monitor.y + monitor.height; + } + else + { + vertical_barrier->x1 = monitor.x; + vertical_barrier->x2 = monitor.x + monitor.width; + vertical_barrier->y1 = monitor.y + monitor.height; + vertical_barrier->y2 = monitor.y + monitor.height; + vertical_barrier->direction = DOWN; + } + vertical_barrier->index = i; vertical_barrier->threshold = parent_->options()->edge_stop_velocity(); vertical_barrier->max_velocity_multiplier = parent_->options()->edge_responsiveness(); vertical_barrier->ConstructBarrier(); - - horizontal_bottom_barrier->x1 = monitor.x; - horizontal_bottom_barrier->x2 = monitor.x + monitor.width; - horizontal_bottom_barrier->y1 = monitor.y + monitor.height; - horizontal_bottom_barrier->y2 = monitor.y + monitor.height; - horizontal_bottom_barrier->index = i; - horizontal_bottom_barrier->direction = DOWN; - - horizontal_bottom_barrier->threshold = parent_->options()->edge_stop_velocity(); - horizontal_bottom_barrier->max_velocity_multiplier = parent_->options()->edge_responsiveness(); - - horizontal_bottom_barrier->ConstructBarrier(); } SetupXI2Events(); diff --git a/launcher/HudLauncherIcon.cpp b/launcher/HudLauncherIcon.cpp index b97c326f1..41d833af7 100644 --- a/launcher/HudLauncherIcon.cpp +++ b/launcher/HudLauncherIcon.cpp @@ -22,6 +22,7 @@ #include <NuxCore/Logger.h> #include "unity-shared/UBusMessages.h" +#include "unity-shared/UnitySettings.h" #include "config.h" #include <glib/gi18n-lib.h> @@ -32,9 +33,9 @@ namespace launcher { DECLARE_LOGGER(logger, "unity.launcher.icon.hud"); -HudLauncherIcon::HudLauncherIcon(LauncherHideMode hide_mode) +HudLauncherIcon::HudLauncherIcon() : SingleMonitorLauncherIcon(IconType::HUD) - , launcher_hide_mode_(hide_mode) + , launcher_hide_mode_(LAUNCHER_HIDE_NEVER) , overlay_monitor_(0) , single_launcher_(false) , launcher_monitor_(0) @@ -90,7 +91,7 @@ void HudLauncherIcon::SetSingleLauncher(bool single_launcher, int launcher_monit { if (single_launcher_ == single_launcher && launcher_monitor_ == launcher_monitor) return; - + single_launcher_ = single_launcher; launcher_monitor_ = launcher_monitor; @@ -112,6 +113,7 @@ void HudLauncherIcon::OnOverlayShown(GVariant* data, bool visible) // If the hud is open, we show the HUD button if we have a locked launcher if (overlay_identity.Str() == "hud" && launcher_hide_mode_ == LAUNCHER_HIDE_NEVER && + Settings::Instance().launcher_position() == LauncherPosition::LEFT && (!single_launcher_ || (single_launcher_ && launcher_monitor_ == overlay_monitor_))) { SetMonitor(visible ? overlay_monitor_ : -1); diff --git a/launcher/HudLauncherIcon.h b/launcher/HudLauncherIcon.h index d7c7cade4..9eb7f59a2 100644 --- a/launcher/HudLauncherIcon.h +++ b/launcher/HudLauncherIcon.h @@ -32,9 +32,8 @@ namespace launcher class HudLauncherIcon : public SingleMonitorLauncherIcon { - public: - HudLauncherIcon(LauncherHideMode hide_mode); + HudLauncherIcon(); virtual nux::Color BackgroundColor() const; virtual nux::Color GlowColor(); @@ -53,7 +52,7 @@ private: nux::Color background_color_; LauncherHideMode launcher_hide_mode_; UBusManager ubus_manager_; - gint32 overlay_monitor_; + gint32 overlay_monitor_; bool single_launcher_; int launcher_monitor_; }; diff --git a/launcher/Launcher.cpp b/launcher/Launcher.cpp index dd5da67f0..fef76793d 100644 --- a/launcher/Launcher.cpp +++ b/launcher/Launcher.cpp @@ -690,13 +690,11 @@ void Launcher::FillRenderArg(AbstractLauncherIcon::Ptr const& icon, if (size_modifier <= 0.0f) arg.skip = true; + auto launcher_position = Settings::Instance().launcher_position(); int c_icon_size = icon_size_.CP(cv_); + auto moving_center = (launcher_position == LauncherPosition::LEFT) ? center.y : center.x; // goes for 0.0f when fully unfolded, to 1.0f folded - float folding_progress = 0; - if (Settings::Instance().launcher_position() == LauncherPosition::LEFT) - folding_progress = CLAMP((center.y + c_icon_size - folding_threshold) / (float) c_icon_size, 0.0f, 1.0f); - else - folding_progress = CLAMP((center.x + c_icon_size - folding_threshold) / (float) c_icon_size, 0.0f, 1.0f); + float folding_progress = CLAMP((moving_center + c_icon_size - folding_threshold) / (float) c_icon_size, 0.0f, 1.0f); float unfold_progress = icon->GetQuirkProgress(AbstractLauncherIcon::Quirk::UNFOLDED, monitor()); float active_progress = icon->GetQuirkProgress(AbstractLauncherIcon::Quirk::ACTIVE, monitor()); @@ -716,23 +714,19 @@ void Launcher::FillRenderArg(AbstractLauncherIcon::Ptr const& icon, // icon is crossing threshold, start folding center.z += folded_z_distance * folding_progress; - if (Settings::Instance().launcher_position() == LauncherPosition::LEFT) + if (launcher_position == LauncherPosition::LEFT) arg.rotation.x = animation_neg_rads * folding_progress; else arg.rotation.y = animation_neg_rads * folding_progress; - float spacing_overlap = 0; - if (Settings::Instance().launcher_position() == LauncherPosition::LEFT) - spacing_overlap = CLAMP((float)(center.y + (2.0f * half_size * size_modifier) + (SPACE_BETWEEN_ICONS.CP(cv_) * size_modifier) - folding_threshold) / (float) c_icon_size, 0.0f, 1.0f); - else - spacing_overlap = CLAMP((float)(center.x + (2.0f * half_size * size_modifier) + (SPACE_BETWEEN_ICONS.CP(cv_) * size_modifier) - folding_threshold) / (float) c_icon_size, 0.0f, 1.0f); + float spacing_overlap = CLAMP((float)(moving_center + (2.0f * half_size * size_modifier) + (SPACE_BETWEEN_ICONS.CP(cv_) * size_modifier) - folding_threshold) / (float) c_icon_size, 0.0f, 1.0f); float spacing = (SPACE_BETWEEN_ICONS.CP(cv_) * (1.0f - spacing_overlap) + folded_spacing * spacing_overlap) * size_modifier; nux::Point3 centerOffset; float center_transit_progress = icon->GetQuirkProgress(AbstractLauncherIcon::Quirk::CENTER_SAVED, monitor()); if (center_transit_progress <= 1.0f) { - if (Settings::Instance().launcher_position() == LauncherPosition::LEFT) + if (launcher_position == LauncherPosition::LEFT) { int saved_center = icon->GetSavedCenter(monitor).y - parent_abs_geo.y; centerOffset.y = (saved_center - (center.y + (half_size * size_modifier))) * (1.0f - center_transit_progress); @@ -743,7 +737,7 @@ void Launcher::FillRenderArg(AbstractLauncherIcon::Ptr const& icon, centerOffset.x = (saved_center - (center.x + (half_size * size_modifier))) * (1.0f - center_transit_progress); } } - if (Settings::Instance().launcher_position() == LauncherPosition::LEFT) + if (launcher_position == LauncherPosition::LEFT) { center.y += half_size * size_modifier; // move to center arg.render_center = nux::Point3(roundf(center.x + icon_hide_offset), roundf(center.y + centerOffset.y), roundf(center.z)); @@ -765,7 +759,7 @@ void Launcher::FillRenderArg(AbstractLauncherIcon::Ptr const& icon, drag_window_->SetAnimationTarget(icon_center.x, icon_center.y); } - if (Settings::Instance().launcher_position() == LauncherPosition::LEFT) + if (launcher_position == LauncherPosition::LEFT) center.y += (half_size * size_modifier) + spacing; // move to end else center.x += (half_size * size_modifier) + spacing; @@ -798,6 +792,7 @@ void Launcher::RenderArgs(std::list<RenderArg> &launcher_args, nux::Point3 center; nux::Color const& colorify = FullySaturateColor(options()->background_color); + auto launcher_position = Settings::Instance().launcher_position(); float hover_progress = folded_ ? hover_animation_.GetCurrentValue() : 1.0f; float folded_z_distance = FOLDED_Z_DISTANCE * (1.0f - hover_progress); @@ -810,7 +805,7 @@ void Launcher::RenderArgs(std::list<RenderArg> &launcher_args, float folded_size = c_icon_size * folding_not_constant; float folded_spacing = SPACE_BETWEEN_ICONS.CP(cv_) * folding_not_constant; - if (Settings::Instance().launcher_position() == LauncherPosition::LEFT) + if (launcher_position == LauncherPosition::LEFT) { center.x = geo.width / 2; center.y = SPACE_BETWEEN_ICONS.CP(cv_); @@ -822,11 +817,11 @@ void Launcher::RenderArgs(std::list<RenderArg> &launcher_args, } center.z = 0; - int launcher_size = (Settings::Instance().launcher_position() == LauncherPosition::LEFT) ? geo.height : geo.width; + int launcher_size = (launcher_position == LauncherPosition::LEFT) ? geo.height : geo.width; folded_ = true; // compute required height/width of launcher AND folding threshold - float sum = (Settings::Instance().launcher_position() == LauncherPosition::LEFT) ? (0.0f + center.y) : (0.0f + center.x); + float sum = (launcher_position == LauncherPosition::LEFT) ? (0.0f + center.y) : (0.0f + center.x); float folding_threshold = launcher_size - c_icon_size / 2.5f; for (it = model_->begin(); it != model_->end(); ++it) @@ -868,7 +863,7 @@ void Launcher::RenderArgs(std::list<RenderArg> &launcher_args, { if (autohide_progress > 0.0f) { - if (Settings::Instance().launcher_position() == LauncherPosition::LEFT) + if (launcher_position == LauncherPosition::LEFT) autohide_offset -= geo.width * autohide_progress; else autohide_offset += geo.height * autohide_progress; @@ -881,7 +876,7 @@ void Launcher::RenderArgs(std::list<RenderArg> &launcher_args, if (options()->hide_mode != LAUNCHER_HIDE_NEVER) { float drag_hide_progress = dnd_hide_animation_.GetCurrentValue(); - if (Settings::Instance().launcher_position() == LauncherPosition::LEFT) + if (launcher_position == LauncherPosition::LEFT) autohide_offset -= geo.width * 0.25f * drag_hide_progress; else autohide_offset += geo.height * 0.25f * drag_hide_progress; @@ -893,7 +888,7 @@ void Launcher::RenderArgs(std::list<RenderArg> &launcher_args, if (options()->hide_mode != LAUNCHER_HIDE_NEVER || hide_machine_.GetQuirk(LauncherHideMachine::LOCK_HIDE)) { - if (Settings::Instance().launcher_position() == LauncherPosition::LEFT) + if (launcher_position == LauncherPosition::LEFT) box_geo.x += autohide_offset; else box_geo.y += autohide_offset; @@ -908,7 +903,7 @@ void Launcher::RenderArgs(std::list<RenderArg> &launcher_args, static nux::Geometry last_geo = box_geo; // this happens on hover, basically its a flag and a value in one, we translate this into a dnd offset - if (Settings::Instance().launcher_position() == LauncherPosition::LEFT) + if (launcher_position == LauncherPosition::LEFT) { if (enter_y_ != 0 && enter_y_ + c_icon_size / 2 > folding_threshold) SetDndDelta(last_geo.x + last_geo.width / 2, center.y, geo); @@ -931,58 +926,34 @@ void Launcher::RenderArgs(std::list<RenderArg> &launcher_args, if (hover_progress > 0.0f && launcher_drag_delta_ != 0) { - if (Settings::Instance().launcher_position() == LauncherPosition::LEFT) - { - float delta_y = launcher_drag_delta_; + float delta = launcher_drag_delta_; - if (launcher_drag_delta_ > launcher_drag_delta_max_) - delta_y = launcher_drag_delta_max_ + DragLimiter(delta_y - launcher_drag_delta_max_); - else if (launcher_drag_delta_ < launcher_drag_delta_min_) - delta_y = launcher_drag_delta_min_ + DragLimiter(delta_y - launcher_drag_delta_min_); - - if (GetActionState() != ACTION_DRAG_LAUNCHER) - { - // XXX: nux::Animation should allow to define new kinds of easing curves - float dnd_progress = std::pow(drag_over_animation_.GetCurrentValue(), 2); + if (launcher_drag_delta_ > launcher_drag_delta_max_) + delta = launcher_drag_delta_max_ + DragLimiter(delta - launcher_drag_delta_max_); + else if (launcher_drag_delta_ < launcher_drag_delta_min_) + delta = launcher_drag_delta_min_ + DragLimiter(delta - launcher_drag_delta_min_); - if (launcher_drag_delta_ > launcher_drag_delta_max_) - delta_y = launcher_drag_delta_max_ + (delta_y - launcher_drag_delta_max_) * dnd_progress; - else if (launcher_drag_delta_ < launcher_drag_delta_min_) - delta_y = launcher_drag_delta_min_ + (delta_y - launcher_drag_delta_min_) * dnd_progress; - - if (dnd_progress == 0.0f) - launcher_drag_delta_ = (int) delta_y; - } - - delta_y *= hover_progress; - center.y += delta_y; - folding_threshold += delta_y; - } - else + if (GetActionState() != ACTION_DRAG_LAUNCHER) { - float delta_x = launcher_drag_delta_; + // XXX: nux::Animation should allow to define new kinds of easing curves + float dnd_progress = std::pow(drag_over_animation_.GetCurrentValue(), 2); if (launcher_drag_delta_ > launcher_drag_delta_max_) - delta_x = launcher_drag_delta_max_ + DragLimiter(delta_x - launcher_drag_delta_max_); + delta = launcher_drag_delta_max_ + (delta - launcher_drag_delta_max_) * dnd_progress; else if (launcher_drag_delta_ < launcher_drag_delta_min_) - delta_x = launcher_drag_delta_min_ + DragLimiter(delta_x - launcher_drag_delta_min_); + delta = launcher_drag_delta_min_ + (delta - launcher_drag_delta_min_) * dnd_progress; - if (GetActionState() != ACTION_DRAG_LAUNCHER) - { - float dnd_progress = std::pow(drag_over_animation_.GetCurrentValue(), 2); + if (dnd_progress == 0.0f) + launcher_drag_delta_ = (int) delta; + } - if (launcher_drag_delta_ > launcher_drag_delta_max_) - delta_x = launcher_drag_delta_max_ + (delta_x - launcher_drag_delta_max_) * dnd_progress; - else if (launcher_drag_delta_ < launcher_drag_delta_min_) - delta_x = launcher_drag_delta_min_ + (delta_x - launcher_drag_delta_min_) * dnd_progress; + delta *= hover_progress; + folding_threshold += delta; - if (dnd_progress == 0.0f) - launcher_drag_delta_ = (int) delta_x; - } - delta_x *= hover_progress; - center.x += delta_x; - folding_threshold += delta_x; - } + if (launcher_position == LauncherPosition::LEFT) + center.y += delta; + else + center.x += delta; } else { @@ -1022,7 +993,7 @@ void Launcher::RenderArgs(std::list<RenderArg> &launcher_args, shelf_sum += SPACE_BETWEEN_ICONS.CP(cv_); float shelf_delta = 0; - if (Settings::Instance().launcher_position() == LauncherPosition::LEFT) + if (launcher_position == LauncherPosition::LEFT) { shelf_delta = MAX(((launcher_size - shelf_sum) + SPACE_BETWEEN_ICONS.CP(cv_)) - center.y, 0.0f); center.y += shelf_delta; @@ -2878,14 +2849,15 @@ void Launcher::ProcessDndMove(int x, int y, std::list<char*> mimes) } SetMousePosition(x - parent_->GetGeometry().x, y - parent_->GetGeometry().y); + auto launcher_position = Settings::Instance().launcher_position(); if (options()->hide_mode != LAUNCHER_HIDE_NEVER) { if ((monitor() == 0 && !IsOverlayOpen() && mouse_position_.x == 0 && !drag_edge_touching_) && - ((Settings::Instance().launcher_position() == LauncherPosition::LEFT && - mouse_position_.y <= (parent_->GetGeometry().height - icon_size_.CP(cv_) - 2 * SPACE_BETWEEN_ICONS.CP(cv_))) || - (Settings::Instance().launcher_position() == LauncherPosition::BOTTOM && - mouse_position_.x <= (parent_->GetGeometry().width - icon_size_.CP(cv_) - 2 * SPACE_BETWEEN_ICONS.CP(cv_))))) + ((launcher_position == LauncherPosition::LEFT && + mouse_position_.y <= (parent_->GetGeometry().height - icon_size_.CP(cv_) - 2 * SPACE_BETWEEN_ICONS.CP(cv_))) || + (launcher_position == LauncherPosition::BOTTOM && + mouse_position_.x <= (parent_->GetGeometry().width - icon_size_.CP(cv_) - 2 * SPACE_BETWEEN_ICONS.CP(cv_))))) { if (dnd_hovered_icon_) { @@ -2896,8 +2868,9 @@ void Launcher::ProcessDndMove(int x, int y, std::list<char*> mimes) animation::StartOrReverse(dnd_hide_animation_, animation::Direction::FORWARD); drag_edge_touching_ = true; } - else if ((Settings::Instance().launcher_position() == LauncherPosition::LEFT && mouse_position_.x != 0 && drag_edge_touching_) || - (Settings::Instance().launcher_position() == LauncherPosition::BOTTOM && mouse_position_.y != 0 && drag_edge_touching_)) + else if (drag_edge_touching_ && + ((launcher_position == LauncherPosition::LEFT && mouse_position_.x != 0) || + (launcher_position == LauncherPosition::BOTTOM && mouse_position_.y != 0))) { animation::StartOrReverse(dnd_hide_animation_, animation::Direction::BACKWARD); drag_edge_touching_ = false; diff --git a/launcher/LauncherController.cpp b/launcher/LauncherController.cpp index 1accbcc11..e74b0fa90 100644 --- a/launcher/LauncherController.cpp +++ b/launcher/LauncherController.cpp @@ -32,13 +32,11 @@ #include "DesktopLauncherIcon.h" #include "VolumeLauncherIcon.h" #include "FavoriteStore.h" -#include "HudLauncherIcon.h" #include "LauncherController.h" #include "LauncherControllerPrivate.h" #include "SoftwareCenterLauncherIcon.h" #include "ExpoLauncherIcon.h" #include "TrashLauncherIcon.h" -#include "BFBLauncherIcon.h" #include "unity-shared/IconRenderer.h" #include "unity-shared/UScreen.h" #include "unity-shared/UBusMessages.h" @@ -109,6 +107,8 @@ Controller::Impl::Impl(Controller* parent, XdndManager::Ptr const& xdnd_manager, : parent_(parent) , model_(std::make_shared<LauncherModel>()) , xdnd_manager_(xdnd_manager) + , bfb_icon_(new BFBLauncherIcon()) + , hud_icon_(new HudLauncherIcon()) , expo_icon_(new ExpoLauncherIcon()) , desktop_icon_(new DesktopLauncherIcon()) , edge_barriers_(edge_barriers) @@ -132,20 +132,28 @@ Controller::Impl::Impl(Controller* parent, XdndManager::Ptr const& xdnd_manager, remote_model_.entry_added.connect(sigc::mem_fun(this, &Impl::OnLauncherEntryRemoteAdded)); remote_model_.entry_removed.connect(sigc::mem_fun(this, &Impl::OnLauncherEntryRemoteRemoved)); - LauncherHideMode hide_mode = parent_->options()->hide_mode; - BFBLauncherIcon* bfb = new BFBLauncherIcon(hide_mode); - RegisterIcon(AbstractLauncherIcon::Ptr(bfb)); + auto hide_mode = parent_->options()->hide_mode(); + bfb_icon_->SetHideMode(hide_mode); + RegisterIcon(AbstractLauncherIcon::Ptr(bfb_icon_)); - HudLauncherIcon* hud = new HudLauncherIcon(hide_mode); - RegisterIcon(AbstractLauncherIcon::Ptr(hud)); - hud_icon_ = hud; + hud_icon_->SetHideMode(hide_mode); + RegisterIcon(AbstractLauncherIcon::Ptr(hud_icon_)); TrashLauncherIcon* trash = new TrashLauncherIcon(); RegisterIcon(AbstractLauncherIcon::Ptr(trash)); - parent_->options()->hide_mode.changed.connect([bfb, hud](LauncherHideMode mode) { - bfb->SetHideMode(mode); - hud->SetHideMode(mode); + parent_->options()->hide_mode.changed.connect([this] (LauncherHideMode mode) { + bfb_icon_->SetHideMode(mode); + hud_icon_->SetHideMode(mode); + }); + + parent_->multiple_launchers.changed.connect([this] (bool value) { + UScreen* uscreen = UScreen::GetDefault(); + auto monitors = uscreen->GetMonitors(); + int primary = uscreen->GetPrimaryMonitor(); + EnsureLaunchers(primary, monitors); + parent_->options()->show_for_all = !value; + hud_icon_->SetSingleLauncher(!value, primary); }); WindowManager& wm = WindowManager::Default(); @@ -1066,16 +1074,7 @@ Controller::Controller(XdndManager::Ptr const& xdnd_manager, ui::EdgeBarrierCont : options(std::make_shared<Options>()) , multiple_launchers(true) , pimpl(new Impl(this, xdnd_manager, edge_barriers)) -{ - multiple_launchers.changed.connect([this] (bool value) { - UScreen* uscreen = UScreen::GetDefault(); - auto monitors = uscreen->GetMonitors(); - int primary = uscreen->GetPrimaryMonitor(); - pimpl->EnsureLaunchers(primary, monitors); - options()->show_for_all = !value; - pimpl->hud_icon_->SetSingleLauncher(!value, primary); - }); -} +{} Controller::~Controller() {} diff --git a/launcher/LauncherControllerPrivate.h b/launcher/LauncherControllerPrivate.h index 30a0886b9..02d639d80 100644 --- a/launcher/LauncherControllerPrivate.h +++ b/launcher/LauncherControllerPrivate.h @@ -36,10 +36,11 @@ #include "LauncherEntryRemote.h" #include "LauncherEntryRemoteModel.h" #include "LauncherModel.h" +#include "BFBLauncherIcon.h" +#include "HudLauncherIcon.h" #include "SoftwareCenterLauncherIcon.h" #include "unity-shared/UBusWrapper.h" #include "XdndManager.h" -#include "HudLauncherIcon.h" namespace unity { @@ -124,9 +125,10 @@ public: XdndManager::Ptr xdnd_manager_; DeviceLauncherSection device_section_; LauncherEntryRemoteModel remote_model_; + BFBLauncherIcon* bfb_icon_; + HudLauncherIcon* hud_icon_; AbstractLauncherIcon::Ptr expo_icon_; AbstractLauncherIcon::Ptr desktop_icon_; - HudLauncherIcon* hud_icon_; #ifdef USE_X11 ui::EdgeBarrierController::Ptr edge_barriers_; @@ -148,7 +150,7 @@ public: connection::Wrapper launcher_key_press_connection_; connection::Wrapper launcher_event_outside_connection_; - connection::Wrapper launcher_key_nav_terminate_; + connection::Wrapper launcher_key_nav_terminate_; connection::Wrapper average_color_connection_; }; diff --git a/tests/test_bfb_launcher_icon.cpp b/tests/test_bfb_launcher_icon.cpp index e4e0cb3f7..cd9519b9f 100644 --- a/tests/test_bfb_launcher_icon.cpp +++ b/tests/test_bfb_launcher_icon.cpp @@ -31,7 +31,7 @@ class MockBFBLauncherIcon : public BFBLauncherIcon { public: MockBFBLauncherIcon() - : BFBLauncherIcon(LauncherHideMode::LAUNCHER_HIDE_NEVER) + : BFBLauncherIcon() {} }; diff --git a/tests/test_hud_launcher_icon.cpp b/tests/test_hud_launcher_icon.cpp index 26b8aa978..a9b88936e 100644 --- a/tests/test_hud_launcher_icon.cpp +++ b/tests/test_hud_launcher_icon.cpp @@ -32,7 +32,7 @@ class MockHudLauncherIcon : public HudLauncherIcon { public: MockHudLauncherIcon() - : HudLauncherIcon(LauncherHideMode::LAUNCHER_HIDE_NEVER) + : HudLauncherIcon() {} }; diff --git a/unity-shared/IconRenderer.cpp b/unity-shared/IconRenderer.cpp index b4c925aaf..78374dd99 100644 --- a/unity-shared/IconRenderer.cpp +++ b/unity-shared/IconRenderer.cpp @@ -1042,7 +1042,10 @@ void IconRenderer::RenderIndicators(nux::GraphicsEngine& GfxContext, nux::Geometry const& geo) { int markerCenter = 0; - if (Settings::Instance().launcher_position() == LauncherPosition::LEFT) + bool switcher_mode = (pip_style != OUTSIDE_TILE); + bool left_markers = (switcher_mode || Settings::Instance().launcher_position() == LauncherPosition::LEFT); + + if (left_markers) { markerCenter = (int) arg.render_center.y; markerCenter -= (int)(arg.rotation.x / (2 * M_PI) * icon_size); @@ -1058,7 +1061,7 @@ void IconRenderer::RenderIndicators(nux::GraphicsEngine& GfxContext, if (running > 0) { int markerX = 0; - if (Settings::Instance().launcher_position() == LauncherPosition::LEFT) + if (left_markers) { if (pip_style == OUTSIDE_TILE) { @@ -1089,7 +1092,7 @@ void IconRenderer::RenderIndicators(nux::GraphicsEngine& GfxContext, if (!arg.running_on_viewport) { markers[0] = markerCenter; - if (Settings::Instance().launcher_position() == LauncherPosition::LEFT) + if (left_markers) texture = local_textures_->arrow_empty_ltr; else texture = local_textures_->arrow_empty_btt; @@ -1097,7 +1100,7 @@ void IconRenderer::RenderIndicators(nux::GraphicsEngine& GfxContext, else if (running == 1) { markers[0] = markerCenter; - if (Settings::Instance().launcher_position() == LauncherPosition::LEFT) + if (left_markers) texture = local_textures_->arrow_ltr; else texture = local_textures_->arrow_btt; @@ -1105,7 +1108,7 @@ void IconRenderer::RenderIndicators(nux::GraphicsEngine& GfxContext, else if (running == 2) { int texture_size = 0; - if (Settings::Instance().launcher_position() == LauncherPosition::LEFT) + if (left_markers) { texture = local_textures_->pip_ltr; texture_size = texture->GetHeight(); @@ -1124,7 +1127,7 @@ void IconRenderer::RenderIndicators(nux::GraphicsEngine& GfxContext, else { int texture_size = 0; - if (Settings::Instance().launcher_position() == LauncherPosition::LEFT) + if (left_markers) { texture = local_textures_->pip_ltr; texture_size = texture->GetHeight(); @@ -1143,7 +1146,7 @@ void IconRenderer::RenderIndicators(nux::GraphicsEngine& GfxContext, } int markerY = 0; - if (Settings::Instance().launcher_position() == LauncherPosition::BOTTOM) + if (!left_markers) { if (pip_style == OUTSIDE_TILE) { @@ -1163,22 +1166,18 @@ void IconRenderer::RenderIndicators(nux::GraphicsEngine& GfxContext, if (center == -100) break; - if (Settings::Instance().launcher_position() == LauncherPosition::LEFT) - GfxContext.QRP_1Tex(markerX, - center - std::round(texture->GetHeight() / 2.0f), - texture->GetWidth(), - texture->GetHeight(), - texture->GetDeviceTexture(), - texxform, - color); + if (left_markers) + markerY = center - std::round(texture->GetHeight() / 2.0f); else - GfxContext.QRP_1Tex(center - std::round(texture->GetWidth() / 2.0f), - markerY, - texture->GetWidth(), - texture->GetHeight(), - texture->GetDeviceTexture(), - texxform, - color); + markerX = center - std::round(texture->GetWidth() / 2.0f); + + GfxContext.QRP_1Tex(markerX, + markerY, + texture->GetWidth(), + texture->GetHeight(), + texture->GetDeviceTexture(), + texxform, + color); } } @@ -1187,7 +1186,7 @@ void IconRenderer::RenderIndicators(nux::GraphicsEngine& GfxContext, nux::TexCoordXForm texxform; nux::Color color = nux::color::LightGrey * alpha; - if (Settings::Instance().launcher_position() == LauncherPosition::LEFT) + if (left_markers) { auto const& arrow_rtl = local_textures_->arrow_rtl; GfxContext.QRP_1Tex((geo.x + geo.width) - arrow_rtl->GetWidth(), diff --git a/unity-shared/UnitySettings.cpp b/unity-shared/UnitySettings.cpp index a6fc7aa4f..df7ffe494 100644 --- a/unity-shared/UnitySettings.cpp +++ b/unity-shared/UnitySettings.cpp @@ -207,7 +207,7 @@ public: void CacheLauncherPosition() { - cached_launcher_position_ = static_cast<LauncherPosition>(g_settings_get_enum(usettings_, LAUNCHER_POSITION.c_str())); + cached_launcher_position_ = static_cast<LauncherPosition>(g_settings_get_enum(usettings_, LAUNCHER_POSITION.c_str())); } void UpdateLimSetting() @@ -235,13 +235,13 @@ public: LauncherPosition GetLauncherPosition() const { - return cached_launcher_position_; + return cached_launcher_position_; } bool SetLauncherPosition(LauncherPosition launcherPosition) { - g_settings_set_enum(usettings_, LAUNCHER_POSITION.c_str(), static_cast<int>(launcherPosition)); - return false; + g_settings_set_enum(usettings_, LAUNCHER_POSITION.c_str(), static_cast<int>(launcherPosition)); + return false; } int GetFontSize() const @@ -447,7 +447,7 @@ void Settings::SetLauncherSize(int launcher_size, int monitor) { if (monitor < 0 || monitor >= (int)monitors::MAX) { - LOG_ERROR(logger) << "Invalid monitor index: " << monitor << ". Not updating laucher size."; + LOG_ERROR(logger) << "Invalid monitor index: " << monitor << ". Not updating launcher size."; } else { diff --git a/unity-shared/UnitySettings.h b/unity-shared/UnitySettings.h index 1741d3bae..f9784ae0e 100644 --- a/unity-shared/UnitySettings.h +++ b/unity-shared/UnitySettings.h @@ -37,8 +37,8 @@ enum class FormFactor enum class LauncherPosition { - LEFT = 0, - BOTTOM + LEFT = 0, + BOTTOM }; class Settings |
