summaryrefslogtreecommitdiff
path: root/unity-shared
diff options
authorBrandon Schaefer <brandon.schaefer@canonical.com>2013-01-28 15:57:38 -0800
committerBrandon Schaefer <brandon.schaefer@canonical.com>2013-01-28 15:57:38 -0800
commitc40a09f7382b29b5a19ab29ed87459af7e38b285 (patch)
tree3190816e3131abd88b30ade1c618c0003c014cd4 /unity-shared
parentbbdf3c6f929cab813e117bc5945c56615ac381e5 (diff)
* The main reason, is the DashView has to take up the PanelHeight, so when the
launcher icons are resized, part of the window buttons get cut off from mouse events. * Created a class OverlayWindowButtons which will sit in the DashView/HudView to handle mouse events for the window buttons. * TODO: We need to refactor the PanelMenuView to extract window button logic (dealing with overlays). Fixes LP: #1101310 (bzr r3080.1.2)
Diffstat (limited to 'unity-shared')
-rw-r--r--unity-shared/CMakeLists.txt1
-rw-r--r--unity-shared/OverlayWindowButtons.cpp76
-rw-r--r--unity-shared/OverlayWindowButtons.h53
3 files changed, 130 insertions, 0 deletions
diff --git a/unity-shared/CMakeLists.txt b/unity-shared/CMakeLists.txt
index 32559e729..ead1ec981 100644
--- a/unity-shared/CMakeLists.txt
+++ b/unity-shared/CMakeLists.txt
@@ -39,6 +39,7 @@ set (UNITY_SHARED_SOURCES
LayoutSystem.cpp
LineSeparator.cpp
OverlayRenderer.cpp
+ OverlayWindowButtons.cpp
PanelStyle.cpp
PlacesVScrollBar.cpp
PlacesOverlayVScrollBar.cpp
diff --git a/unity-shared/OverlayWindowButtons.cpp b/unity-shared/OverlayWindowButtons.cpp
new file mode 100644
index 000000000..3be37af81
--- /dev/null
+++ b/unity-shared/OverlayWindowButtons.cpp
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2013 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 <http://www.gnu.org/licenses/>.
+ *
+ * Authored by: Brandon Schaefer <brandon.schaefer@canonical.com>
+ *
+ */
+
+#include "OverlayWindowButtons.h"
+#include "PanelStyle.h"
+#include "UScreen.h"
+
+const int MAIN_LEFT_PADDING = 4;
+const int MENUBAR_PADDING = 4;
+
+namespace unity
+{
+
+OverlayWindowButtons::OverlayWindowButtons()
+ : nux::BaseWindow("OverlayWindowButtons")
+ , window_buttons_(new WindowButtons())
+{
+ UpdateGeometry();
+ SetBackgroundColor(nux::color::Transparent);
+}
+
+void OverlayWindowButtons::UpdateGeometry()
+{
+ int monitor = unity::UScreen::GetDefault()->GetMonitorWithMouse();
+ nux::Geometry const& geo = unity::UScreen::GetDefault()->GetMonitorGeometry(monitor);
+
+ SetX(geo.x + MAIN_LEFT_PADDING);
+ SetY(geo.y + MENUBAR_PADDING);
+ SetHeight(panel::Style::Instance().panel_height);
+
+ window_buttons_->monitor = monitor;
+}
+
+void OverlayWindowButtons::AboutToShow()
+{
+ UpdateGeometry();
+ ShowWindow(true);
+ PushToFront();
+ QueueDraw();
+}
+
+void OverlayWindowButtons::AboutToHide()
+{
+ ShowWindow(false);
+ PushToBack();
+ QueueDraw();
+}
+
+nux::Area* OverlayWindowButtons::FindAreaUnderMouse(nux::Point const& mouse_position,
+ nux::NuxEventType event_type)
+{
+ return window_buttons_->FindAreaUnderMouse(mouse_position, event_type);
+}
+
+void OverlayWindowButtons::Draw(nux::GraphicsEngine& gfx_context, bool force_draw)
+{
+ window_buttons_->ProcessDraw(gfx_context, true);
+}
+
+} // namespace unity
diff --git a/unity-shared/OverlayWindowButtons.h b/unity-shared/OverlayWindowButtons.h
new file mode 100644
index 000000000..6a1901bdc
--- /dev/null
+++ b/unity-shared/OverlayWindowButtons.h
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2013 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 <http://www.gnu.org/licenses/>.
+ *
+ * Authored by: Brandon Schaefer <brandon.schaefer@canonical.com>
+ *
+ */
+
+#ifndef OVERLAY_WINDOW_BUTTONS
+#define OVERLAY_WINDOW_BUTTONS
+
+#include "Nux/Nux.h"
+#include "Nux/BaseWindow.h"
+
+#include "WindowButtons.h"
+
+namespace unity
+{
+
+class OverlayWindowButtons : public nux::BaseWindow
+{
+public:
+ OverlayWindowButtons();
+
+ void AboutToShow();
+ void AboutToHide();
+
+ nux::Area* FindAreaUnderMouse(nux::Point const& mouse_position,
+ nux::NuxEventType event_type);
+
+protected:
+ void Draw(nux::GraphicsEngine& gfx_context, bool force_draw);
+
+private:
+ void UpdateGeometry();
+
+ nux::ObjectPtr<WindowButtons> window_buttons_;
+};
+
+} // namespace unity
+
+#endif // OVERLAY_WINDOW_BUTTONS