diff options
| author | Marco Trevisan (Treviño) <mail@3v1n0.net> | 2014-07-28 23:40:26 +0200 |
|---|---|---|
| committer | Marco Trevisan (Treviño) <mail@3v1n0.net> | 2014-07-28 23:40:26 +0200 |
| commit | 41aa0a4967197d0a47696f314fb5e17c16eb0bb7 (patch) | |
| tree | 2d0361c05abd647ab32b9f2a05e0303f82df8f54 /unity-shared | |
| parent | e3141e562bc301e4449da315a987b39f160cce88 (diff) | |
TextInput: only show tooltip after a timeout
The wait value is hardcoded to match the Gdk and unity tooltips value (bzr r3844.10.21)
Diffstat (limited to 'unity-shared')
| -rw-r--r-- | unity-shared/TextInput.cpp | 18 | ||||
| -rw-r--r-- | unity-shared/TextInput.h | 2 |
2 files changed, 13 insertions, 7 deletions
diff --git a/unity-shared/TextInput.cpp b/unity-shared/TextInput.cpp index f93b8b8fe..2f2ea42af 100644 --- a/unity-shared/TextInput.cpp +++ b/unity-shared/TextInput.cpp @@ -45,6 +45,7 @@ namespace unity namespace { const int BORDER_RADIUS = 5; +const int TOOLTIP_WAIT = 500; const RawPixel SPACE_BETWEEN_ENTRY_AND_HIGHLIGHT = 10_em; const RawPixel LEFT_INTERNAL_PADDING = 6_em; const RawPixel TEXT_INPUT_RIGHT_BORDER = 10_em; @@ -65,12 +66,8 @@ const int HINT_LABEL_FONT_SIZE = 11; const std::string PANGO_ENTRY_DEFAULT_FONT_FAMILY = "Ubuntu"; const RawPixel PANGO_ENTRY_FONT_SIZE = 14_em; -} - nux::logging::Logger logger("unity.textinput"); -NUX_IMPLEMENT_OBJECT_TYPE(TextInput); - std::shared_ptr<nux::AbstractPaintLayer> CreateWarningLayer(nux::BaseTexture* texture) { // Create the texture layer @@ -89,6 +86,9 @@ std::shared_ptr<nux::AbstractPaintLayer> CreateWarningLayer(nux::BaseTexture* te return std::make_shared<nux::TextureLayer>(texture->GetDeviceTexture(), texxform, nux::color::White, true, rop); } +} + +NUX_IMPLEMENT_OBJECT_TYPE(TextInput); TextInput::TextInput(NUX_FILE_LINE_DECL) : View(NUX_FILE_LINE_PARAM) @@ -182,11 +182,15 @@ TextInput::TextInput(NUX_FILE_LINE_DECL) input_hint.changed.connect([this](std::string const& s) { OnInputHintChanged(); }); warning_->mouse_enter.connect([this] (int x, int y, int button, int key_flags) { - QueueDraw(); + tooltip_timeout_.reset(new glib::Timeout(TOOLTIP_WAIT, [this] { + tooltip_timeout_.reset(); + QueueDraw(); + return false; + })); }); warning_->mouse_leave.connect([this] (int x, int y, int button, int key_flags) { - QueueDraw(); + tooltip_timeout_ ? tooltip_timeout_.reset() : QueueDraw(); }); } @@ -388,7 +392,7 @@ void TextInput::DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw) layout_->ProcessDraw(GfxContext, force_draw); - if (caps_lock_on && warning_->IsMouseInside()) + if (caps_lock_on && warning_->IsMouseInside() && !tooltip_timeout_) PaintWarningTooltip(GfxContext); if (!IsFullRedraw()) diff --git a/unity-shared/TextInput.h b/unity-shared/TextInput.h index aa8784450..303c6eb7e 100644 --- a/unity-shared/TextInput.h +++ b/unity-shared/TextInput.h @@ -22,6 +22,7 @@ #include <Nux/Nux.h> #include <UnityCore/GLibSignal.h> +#include <UnityCore/GLibSource.h> #include "Introspectable.h" #include "IMTextEntry.h" @@ -123,6 +124,7 @@ private: IconTexture* activator_; nux::ObjectPtr<nux::BaseTexture> warning_tooltip_; + glib::Source::UniquePtr tooltip_timeout_; glib::SignalManager sig_manager_; }; |
