25
25
#include "LockScreenSettings.h"
26
26
#include "panel/PanelIndicatorsView.h"
27
#include "unity-shared/InputMonitor.h"
27
#include "unity-shared/CairoTexture.h"
28
28
#include "unity-shared/StaticCairoText.h"
29
29
#include "unity-shared/PanelStyle.h"
30
30
#include "unity-shared/RawPixel.h"
40
40
const RawPixel PADDING = 5_em;
41
const nux::Color BG_COLOR(0.1, 0.1, 0.1, 0.4);
44
43
using namespace indicator;
86
86
hostname->SetScale(scale);
87
87
static_cast<nux::HLayout*>(GetLayout())->SetLeftAndRightPadding(PADDING.CP(scale), 0);
88
88
indicators_view_->SetMonitor(monitor);
94
void Panel::UpdateSize()
94
void Panel::BuildTexture()
96
96
int height = panel::Style::Instance().PanelHeight(monitor);
97
nux::CairoGraphics context(CAIRO_FORMAT_ARGB32, 1, height);
98
auto* cr = context.GetInternalContext();
99
cairo_set_source_rgb(cr, 0.1, 0.1, 0.1);
100
cairo_paint_with_alpha(cr, 0.4);
101
bg_texture_ = texture_ptr_from_cairo_graphics(context);
97
103
view_layout_->SetMinimumHeight(height);
98
104
view_layout_->SetMaximumHeight(height);
186
192
nux::GetWindowCompositor().GrabKeyboardAdd(static_cast<nux::BaseWindow*>(GetTopLevelViewWindow()));
189
auto& im = input::Monitor::Get();
190
auto const& event_cb = sigc::mem_fun(this, &Panel::OnEntryEvent);
194
if (im.RegisterClient(input::Events::POINTER, event_cb))
195
indicators_view_->ActivateEntry(entry_id);
199
im.UnregisterClient(event_cb);
200
this->active = active;
204
void Panel::OnEntryEvent(XEvent const& e)
206
if (e.type == MotionNotify && GetAbsoluteGeometry().IsPointInside(e.xmotion.x, e.xmotion.y))
207
indicators_view_->ActivateEntryAt(e.xmotion.x, e.xmotion.y);
195
if (active && !track_menu_pointer_timeout_)
197
track_menu_pointer_timeout_.reset(new glib::Timeout(16));
198
track_menu_pointer_timeout_->Run([this] {
199
nux::Point const& mouse = nux::GetGraphicsDisplay()->GetMouseScreenCoord();
200
if (tracked_pointer_pos_ != mouse)
202
if (GetAbsoluteGeometry().IsPointInside(mouse.x, mouse.y))
203
indicators_view_->ActivateEntryAt(mouse.x, mouse.y);
205
tracked_pointer_pos_ = mouse;
213
track_menu_pointer_timeout_.reset();
214
tracked_pointer_pos_ = {-1, -1};
215
this->active = false;
210
219
void Panel::Draw(nux::GraphicsEngine& graphics_engine, bool force_draw)
218
227
graphics_engine.PushClippingRectangle(geo);
219
228
nux::GetPainter().PaintBackground(graphics_engine, geo);
221
graphics_engine.QRP_Color(geo.x, geo.y, geo.width, geo.height, BG_COLOR);
230
nux::TexCoordXForm texxform;
231
texxform.SetWrap(nux::TEXWRAP_REPEAT, nux::TEXWRAP_CLAMP);
232
graphics_engine.QRP_1Tex(geo.x, geo.y, geo.width, geo.height,
233
bg_texture_->GetDeviceTexture(), texxform,
222
236
view_layout_->ProcessDraw(graphics_engine, force_draw);
224
238
graphics_engine.PopClippingRectangle();