summaryrefslogtreecommitdiff
path: root/unity-shared
diff options
Diffstat (limited to 'unity-shared')
-rw-r--r--unity-shared/SearchBarSpinner.cpp63
-rw-r--r--unity-shared/SearchBarSpinner.h2
2 files changed, 41 insertions, 24 deletions
diff --git a/unity-shared/SearchBarSpinner.cpp b/unity-shared/SearchBarSpinner.cpp
index 8263ee71e..adfbb489e 100644
--- a/unity-shared/SearchBarSpinner.cpp
+++ b/unity-shared/SearchBarSpinner.cpp
@@ -22,6 +22,7 @@
#include <Nux/VLayout.h>
#include "unity-shared/DashStyle.h"
+#include "unity-shared/RawPixel.h"
namespace unity
{
@@ -29,10 +30,11 @@ namespace unity
NUX_IMPLEMENT_OBJECT_TYPE(SearchBarSpinner);
SearchBarSpinner::SearchBarSpinner()
- : nux::View(NUX_TRACKER_LOCATION),
- state_(STATE_READY),
- search_timeout_(-1),
- rotation_(0.0f)
+ : nux::View(NUX_TRACKER_LOCATION)
+ , scale(1.0)
+ , state_(STATE_READY)
+ , search_timeout_(-1)
+ , rotation_(0.0f)
{
dash::Style& style = dash::Style::Instance();
@@ -43,6 +45,11 @@ SearchBarSpinner::SearchBarSpinner()
rotate_.Identity();
rotate_.Rotate_z(0.0);
+
+ scale.changed.connect([this] (double scale) {
+ SetMinMaxSize(RawPixel(magnify_->GetWidth()).CP(scale), RawPixel(magnify_->GetHeight()).CP(scale));
+ QueueDraw();
+ });
}
void
@@ -55,10 +62,9 @@ SearchBarSpinner::Draw(nux::GraphicsEngine& GfxContext, bool force_draw)
nux::GetPainter().PaintBackground(GfxContext, geo);
- texxform.SetTexCoordType(nux::TexCoordXForm::OFFSET_COORD);
- texxform.SetWrap(nux::TEXWRAP_REPEAT, nux::TEXWRAP_REPEAT);
- texxform.min_filter = nux::TEXFILTER_LINEAR;
- texxform.mag_filter = nux::TEXFILTER_LINEAR;
+ texxform.SetTexCoordType(nux::TexCoordXForm::OFFSET_SCALE_COORD);
+ texxform.SetWrap(nux::TEXWRAP_CLAMP_TO_BORDER, nux::TEXWRAP_CLAMP_TO_BORDER);
+ texxform.SetFilter(nux::TEXFILTER_LINEAR, nux::TEXFILTER_LINEAR);
unsigned int current_alpha_blend;
unsigned int current_src_blend_factor;
@@ -68,20 +74,25 @@ SearchBarSpinner::Draw(nux::GraphicsEngine& GfxContext, bool force_draw)
if (state_ == STATE_READY)
{
- GfxContext.QRP_1Tex(geo.x + ((geo.width - magnify_->GetWidth()) / 2),
- geo.y + ((geo.height - magnify_->GetHeight()) / 2),
- magnify_->GetWidth(),
- magnify_->GetHeight(),
+ nux::Size magnifier_size(RawPixel(magnify_->GetWidth()).CP(scale),
+ RawPixel(magnify_->GetHeight()).CP(scale));
+
+ GfxContext.QRP_1Tex(geo.x + ((geo.width - magnifier_size.width) / 2),
+ geo.y + ((geo.height - magnifier_size.height) / 2),
+ magnifier_size.width,
+ magnifier_size.height,
magnify_->GetDeviceTexture(),
texxform,
nux::color::White);
}
else if (state_ == STATE_SEARCHING)
{
- nux::Geometry spin_geo(geo.x + ((geo.width - spin_->GetWidth()) / 2),
- geo.y + ((geo.height - spin_->GetHeight()) / 2),
- spin_->GetWidth(),
- spin_->GetHeight());
+ nux::Size spin_size(RawPixel(spin_->GetWidth()).CP(scale),
+ RawPixel(spin_->GetHeight()).CP(scale));
+ nux::Geometry spin_geo(geo.x + ((geo.width - spin_size.width) / 2),
+ geo.y + ((geo.height - spin_size.height) / 2),
+ spin_size.width,
+ spin_size.height);
// Geometry (== Rect) uses integers which were rounded above,
// hence an extra 0.5 offset for odd sizes is needed
// because pure floating point is not being used.
@@ -110,18 +121,22 @@ SearchBarSpinner::Draw(nux::GraphicsEngine& GfxContext, bool force_draw)
}
else
{
- GfxContext.QRP_1Tex(geo.x + ((geo.width - circle_->GetWidth()) / 2),
- geo.y + ((geo.height - circle_->GetHeight()) / 2),
- circle_->GetWidth(),
- circle_->GetHeight(),
+ nux::Size circle_size(RawPixel(circle_->GetWidth()).CP(scale),
+ RawPixel(circle_->GetHeight()).CP(scale));
+ GfxContext.QRP_1Tex(geo.x + ((geo.width - circle_size.width) / 2),
+ geo.y + ((geo.height - circle_size.height) / 2),
+ circle_size.width,
+ circle_size.height,
circle_->GetDeviceTexture(),
texxform,
nux::color::White);
- GfxContext.QRP_1Tex(geo.x + ((geo.width - close_->GetWidth()) / 2),
- geo.y + ((geo.height - close_->GetHeight()) / 2),
- close_->GetWidth(),
- close_->GetHeight(),
+ nux::Size close_size(RawPixel(close_->GetWidth()).CP(scale),
+ RawPixel(close_->GetHeight()).CP(scale));
+ GfxContext.QRP_1Tex(geo.x + ((geo.width - close_size.width) / 2),
+ geo.y + ((geo.height - close_size.height) / 2),
+ close_size.width,
+ close_size.height,
close_->GetDeviceTexture(),
texxform,
nux::color::White);
diff --git a/unity-shared/SearchBarSpinner.h b/unity-shared/SearchBarSpinner.h
index a7f35fc84..3db855912 100644
--- a/unity-shared/SearchBarSpinner.h
+++ b/unity-shared/SearchBarSpinner.h
@@ -44,6 +44,8 @@ class SearchBarSpinner : public unity::debug::Introspectable, public nux::View
public:
SearchBarSpinner();
+ nux::Property<double> scale;
+
void Draw(nux::GraphicsEngine& GfxContext, bool force_draw);
void DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw);