Merge lp:~mandel/unity/add-text-entry into lp:unity

Proposed by Manuel de la Peña
Status: Merged
Approved by: Nick Dedekind
Approved revision: no longer in the source branch.
Merged at revision: 2849
Proposed branch: lp:~mandel/unity/add-text-entry
Merge into: lp:unity
Diff against target: 489 lines (+469/-0)
3 files modified
unity-shared/CMakeLists.txt (+1/-0)
unity-shared/TextInput.cpp (+366/-0)
unity-shared/TextInput.h (+102/-0)
To merge this branch: bzr merge lp:~mandel/unity/add-text-entry
Reviewer Review Type Date Requested Status
Nick Dedekind (community) Approve
PS Jenkins bot continuous-integration Pending
Review via email: mp+128504@code.launchpad.net

Commit message

- Add a text entry ui element that follows the design from the search bar so that previews can get input form the users (lp: #1063735).

Description of the change

- Add a text entry ui element that follows the design from the search bar so that previews can get input form the users (lp: #1063735).

To post a comment you must log in.
Revision history for this message
Nick Dedekind (nick-dedekind) wrote :

Havent finished looking at it, but here are a few points I have so far.

53 +const int LIVE_SEARCH_TIMEOUT = 40;
55 +const int SPACE_BETWEEN_SPINNER_AND_TEXT = 5;
58 +const int SEARCH_ENTRY_RIGHT_BORDER = 10;

This isn't a search bar, and there is no spinner.

120 +TextInput::TextInput(NUX_FILE_LINE_DECL)
121 + : View(NUX_FILE_LINE_PARAM)
122 + , input_hint("")
123 + , last_width_(-1)
124 + , last_height_(-1)
125 +{
126 + Init();
127 +}
128 +
129 +TextInput::TextInput(bool show_filter_hint_, NUX_FILE_LINE_DECL)
130 + : View(NUX_FILE_LINE_PARAM)
131 + , input_hint("")
132 + , last_width_(-1)
133 + , last_height_(-1)

Not initialising the show_filter_hint_ member

174 + OnFontChanged(gtk_settings_get_default())

If you're not going to have a connection to the gtk font change signal, then it probably shouldn't be called OnFontChanged. Also, why no connection to gtk font update signal?

review: Needs Fixing
Revision history for this message
Manuel de la Peña (mandel) wrote :

> Havent finished looking at it, but here are a few points I have so far.
>
> 53 +const int LIVE_SEARCH_TIMEOUT = 40;
> 55 +const int SPACE_BETWEEN_SPINNER_AND_TEXT = 5;
> 58 +const int SEARCH_ENTRY_RIGHT_BORDER = 10;
>

Nice catch, I started based on the search bar and forgot to clean up those.

> This isn't a search bar, and there is no spinner.
>
> 120 +TextInput::TextInput(NUX_FILE_LINE_DECL)
> 121 + : View(NUX_FILE_LINE_PARAM)
> 122 + , input_hint("")
> 123 + , last_width_(-1)
> 124 + , last_height_(-1)
> 125 +{
> 126 + Init();
> 127 +}
> 128 +
> 129 +TextInput::TextInput(bool show_filter_hint_, NUX_FILE_LINE_DECL)
> 130 + : View(NUX_FILE_LINE_PARAM)
> 131 + , input_hint("")
> 132 + , last_width_(-1)
> 133 + , last_height_(-1)
>
> Not initialising the show_filter_hint_ member
>

Doing it.

> 174 + OnFontChanged(gtk_settings_get_default())
>
> If you're not going to have a connection to the gtk font change signal, then
> it probably shouldn't be called OnFontChanged. Also, why no connection to gtk
> font update signal?

Mistake in my part, connecting to the gtk signal is the way to go

Revision history for this message
Manuel de la Peña (mandel) wrote :

> > Havent finished looking at it, but here are a few points I have so far.
> >
> > 53 +const int LIVE_SEARCH_TIMEOUT = 40;
> > 55 +const int SPACE_BETWEEN_SPINNER_AND_TEXT = 5;
> > 58 +const int SEARCH_ENTRY_RIGHT_BORDER = 10;
> >
>
> Nice catch, I started based on the search bar and forgot to clean up those.
>
> > This isn't a search bar, and there is no spinner.
> >
> > 120 +TextInput::TextInput(NUX_FILE_LINE_DECL)
> > 121 + : View(NUX_FILE_LINE_PARAM)
> > 122 + , input_hint("")
> > 123 + , last_width_(-1)
> > 124 + , last_height_(-1)
> > 125 +{
> > 126 + Init();
> > 127 +}
> > 128 +
> > 129 +TextInput::TextInput(bool show_filter_hint_, NUX_FILE_LINE_DECL)
> > 130 + : View(NUX_FILE_LINE_PARAM)
> > 131 + , input_hint("")
> > 132 + , last_width_(-1)
> > 133 + , last_height_(-1)
> >
> > Not initialising the show_filter_hint_ member
> >
>
> Doing it.
>
> > 174 + OnFontChanged(gtk_settings_get_default())
> >
> > If you're not going to have a connection to the gtk font change signal, then
> > it probably shouldn't be called OnFontChanged. Also, why no connection to
> gtk
> > font update signal?
>
> Mistake in my part, connecting to the gtk signal is the way to go

Everything has been fixed in the latest version.

Revision history for this message
Andrea Azzarone (azzar1) wrote :

In this way there is a lot of code duplication in SearchBar and TextInput. In some ways we can avoid this. What do you think?

Revision history for this message
Manuel de la Peña (mandel) wrote :

> In this way there is a lot of code duplication in SearchBar and TextInput. In
> some ways we can avoid this. What do you think?

I'm more than happy to re-factor the code, but is that something that all agree with? Bare in mind that there is a number of important differences between the two of them:

* timer for the searches
* spinner
* search icon (the magnifier)

We can surely make the text entry be flexible enough to be able to be hooked with signals that can be used for the searches and the timer. I'm not that sure about the changes to be done in the layout to accommodate the spinner and the icon.

Revision history for this message
Omer Akram (om26er) wrote :

19 + * Copyright (C) 2010-2011 Canonical Ltd
400 + * Copyright (C) 2010 Canonical Ltd

wrong years ?

33 + * Authored by: Manuel de la Pena

please add <email address hidden> as well.

Revision history for this message
Manuel de la Peña (mandel) wrote :

> 19 + * Copyright (C) 2010-2011 Canonical Ltd
> 400 + * Copyright (C) 2010 Canonical Ltd
>
> wrong years ?
>
> 33 + * Authored by: Manuel de la Pena
>
> please add <email address hidden> as well.
Fix, sorry I yy the headers.

Revision history for this message
Andrea Azzarone (azzar1) wrote :

> > In this way there is a lot of code duplication in SearchBar and TextInput.
> In
> > some ways we can avoid this. What do you think?
>
> I'm more than happy to re-factor the code, but is that something that all
> agree with? Bare in mind that there is a number of important differences
> between the two of them:
>
> * timer for the searches
> * spinner
> * search icon (the magnifier)
>
> We can surely make the text entry be flexible enough to be able to be hooked
> with signals that can be used for the searches and the timer. I'm not that
> sure about the changes to be done in the layout to accommodate the spinner and
> the icon.

Ok never mind ;) Will be done later.

Revision history for this message
Nick Dedekind (nick-dedekind) wrote :

Still a reference to SPACE_BETWEEN_SPINNER_AND_TEXT

203 + gchar* tmp = g_markup_escape_text(input_hint().c_str(), -1);
204 +
205 + hint_->SetText(tmp);
206 +
207 + g_free(tmp);

not wrong, but you should use glib::String since we have it.

review: Needs Fixing
Revision history for this message
Nick Dedekind (nick-dedekind) wrote :

137 + entry_layout_ = new nux::HLayout(NUX_TRACKER_LOCATION);

only one item in this layout, so you shouldnt actually need it.

Revision history for this message
Nick Dedekind (nick-dedekind) wrote :

LGTM.

review: Approve
Revision history for this message
Didier Roche-Tolomelli (didrocks) wrote :

I don't see any test on it?

Revision history for this message
Manuel de la Peña (mandel) wrote :

Indeed, I really don't know how to test this thing... if you point me to an example I can always take a look and add them in a following branch.

Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

Manuel, just give a look to the tests we alredy have in the tests subfolder (also give a look to test_im_text_entry.cpp, it should be good as a base); I think you sould basically try to test any new method you've added.

Revision history for this message
Didier Roche-Tolomelli (didrocks) wrote :

You can ask to other unity-team members for how to use unit tests. I think that mmrazik and his team will be able to help you as well (there are quite a lot of tests in the unity trunk itself.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'unity-shared/CMakeLists.txt'
--- unity-shared/CMakeLists.txt 2012-10-11 11:04:13 +0000
+++ unity-shared/CMakeLists.txt 2012-10-17 10:34:19 +0000
@@ -53,6 +53,7 @@
53 SearchBarSpinner.cpp53 SearchBarSpinner.cpp
54 StaticCairoText.cpp54 StaticCairoText.cpp
55 TextureCache.cpp55 TextureCache.cpp
56 TextInput.cpp
56 TextureThumbnailProvider.cpp57 TextureThumbnailProvider.cpp
57 ThumbnailGenerator.cpp58 ThumbnailGenerator.cpp
58 Timer.cpp59 Timer.cpp
5960
=== added file 'unity-shared/TextInput.cpp'
--- unity-shared/TextInput.cpp 1970-01-01 00:00:00 +0000
+++ unity-shared/TextInput.cpp 2012-10-17 10:34:19 +0000
@@ -0,0 +1,366 @@
1// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
2/*
3 * Copyright (C) 2012 Canonical Ltd
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more detais.
13 *
14 * You shoud have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 *
17 * Authored by: Manuel de la Pena <manuel.delapena@canonical.com>
18 */
19
20#include "config.h"
21
22#include <Nux/Nux.h>
23#include <Nux/HLayout.h>
24#include <Nux/VLayout.h>
25#include <NuxCore/Logger.h>
26
27#include <UnityCore/Variant.h>
28
29#include <glib/gi18n-lib.h>
30
31#include "TextInput.h"
32#include "CairoTexture.h"
33
34namespace
35{
36const float kExpandDefaultIconOpacity = 1.0f;
37
38const int SPACE_BETWEEN_ENTRY_AND_HIGHLIGHT = 10;
39const int LEFT_INTERNAL_PADDING = 6;
40const int TEXT_INPUT_RIGHT_BORDER = 10;
41
42const int HIGHLIGHT_HEIGHT = 24;
43
44// Fonts
45const std::string HINT_LABEL_FONT_SIZE = "12px";
46const std::string HINT_LABEL_FONT_STYLE = "Italic";
47const std::string HINT_LABEL_DEFAULT_FONT = "Ubuntu " + HINT_LABEL_FONT_STYLE + " " + HINT_LABEL_FONT_SIZE;
48
49const std::string PANGO_ENTRY_DEFAULT_FONT_FAMILY = "Ubuntu";
50const int PANGO_ENTRY_FONT_SIZE = 14;
51
52}
53
54namespace
55{
56
57nux::logging::Logger logger("unity");
58
59class ExpanderView : public nux::View
60{
61public:
62 ExpanderView(NUX_FILE_LINE_DECL)
63 : nux::View(NUX_FILE_LINE_PARAM)
64 {
65 SetAcceptKeyNavFocusOnMouseDown(false);
66 SetAcceptKeyNavFocusOnMouseEnter(true);
67 }
68
69protected:
70 void Draw(nux::GraphicsEngine& graphics_engine, bool force_draw)
71 {}
72
73 void DrawContent(nux::GraphicsEngine& graphics_engine, bool force_draw)
74 {
75 if (GetLayout())
76 GetLayout()->ProcessDraw(graphics_engine, force_draw);
77 }
78
79 bool AcceptKeyNavFocus()
80 {
81 return true;
82 }
83
84 nux::Area* FindAreaUnderMouse(const nux::Point& mouse_position, nux::NuxEventType event_type)
85 {
86 bool mouse_inside = TestMousePointerInclusionFilterMouseWheel(mouse_position, event_type);
87
88 if (mouse_inside == false)
89 return nullptr;
90
91 return this;
92 }
93};
94
95}
96
97namespace unity
98{
99
100NUX_IMPLEMENT_OBJECT_TYPE(TextInput);
101
102TextInput::TextInput(NUX_FILE_LINE_DECL)
103 : View(NUX_FILE_LINE_PARAM)
104 , input_hint("")
105 , last_width_(-1)
106 , last_height_(-1)
107{
108 Init();
109}
110
111void TextInput::Init()
112{
113 bg_layer_.reset(new nux::ColorLayer(nux::Color(0xff595853), true));
114
115 layout_ = new nux::HLayout(NUX_TRACKER_LOCATION);
116 layout_->SetLeftAndRightPadding(LEFT_INTERNAL_PADDING, TEXT_INPUT_RIGHT_BORDER);
117 layout_->SetSpaceBetweenChildren(SPACE_BETWEEN_ENTRY_AND_HIGHLIGHT);
118 SetLayout(layout_);
119
120 nux::HLayout* hint_layout = new nux::HLayout(NUX_TRACKER_LOCATION);
121
122 hint_ = new nux::StaticCairoText(" ");
123 hint_->SetTextColor(nux::Color(1.0f, 1.0f, 1.0f, 0.5f));
124 hint_->SetFont(HINT_LABEL_DEFAULT_FONT.c_str());
125 hint_layout->AddView(hint_, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL);
126
127 pango_entry_ = new IMTextEntry();
128 pango_entry_->SetFontFamily(PANGO_ENTRY_DEFAULT_FONT_FAMILY.c_str());
129 pango_entry_->SetFontSize(PANGO_ENTRY_FONT_SIZE);
130 pango_entry_->cursor_moved.connect([&](int i) { QueueDraw(); });
131 pango_entry_->mouse_down.connect(sigc::mem_fun(this, &TextInput::OnMouseButtonDown));
132 pango_entry_->end_key_focus.connect(sigc::mem_fun(this, &TextInput::OnEndKeyFocus));
133
134 layered_layout_ = new nux::LayeredLayout();
135 layered_layout_->AddLayout(hint_layout);
136 layered_layout_->AddLayer(pango_entry_);
137 layered_layout_->SetPaintAll(true);
138 layered_layout_->SetActiveLayerN(1);
139 layout_->AddView(layered_layout_, 1, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FIX);
140
141 sig_manager_.Add<void, GtkSettings*, GParamSpec*>(gtk_settings_get_default(),
142 "notify::gtk-font-name", sigc::mem_fun(this, &TextInput::OnFontChanged));
143 OnFontChanged(gtk_settings_get_default());
144
145 input_string.SetGetterFunction(sigc::mem_fun(this, &TextInput::get_input_string));
146 input_string.SetSetterFunction(sigc::mem_fun(this, &TextInput::set_input_string));
147 im_active.SetGetterFunction(sigc::mem_fun(this, &TextInput::get_im_active));
148 im_preedit.SetGetterFunction(sigc::mem_fun(this, &TextInput::get_im_preedit));
149 input_hint.changed.connect([&](std::string const& s) { OnInputHintChanged(); });
150
151}
152
153void TextInput::OnFontChanged(GtkSettings* settings, GParamSpec* pspec)
154{
155 glib::String font_name;
156 PangoFontDescription* desc;
157 std::ostringstream font_desc;
158
159 g_object_get(settings, "gtk-font-name", &font_name, NULL);
160
161 desc = pango_font_description_from_string(font_name.Value());
162 if (desc)
163 {
164 pango_entry_->SetFontFamily(pango_font_description_get_family(desc));
165 pango_entry_->SetFontSize(PANGO_ENTRY_FONT_SIZE);
166 pango_entry_->SetFontOptions(gdk_screen_get_font_options(gdk_screen_get_default()));
167
168 font_desc << pango_font_description_get_family(desc) << " " << HINT_LABEL_FONT_STYLE << " " << HINT_LABEL_FONT_SIZE;
169 hint_->SetFont(font_desc.str().c_str());
170
171 font_desc.str("");
172 font_desc.clear();
173
174 pango_font_description_free(desc);
175 }
176}
177
178void TextInput::OnInputHintChanged()
179{
180 glib::String tmp(g_markup_escape_text(input_hint().c_str(), -1));
181 hint_->SetText(tmp);
182}
183
184void TextInput::Draw(nux::GraphicsEngine& GfxContext, bool force_draw)
185{
186 nux::Geometry const& base = GetGeometry();
187
188 UpdateBackground(false);
189
190 GfxContext.PushClippingRectangle(base);
191 nux::GetPainter().PaintBackground(GfxContext, base);
192
193 bg_layer_->SetGeometry(nux::Geometry(base.x, base.y, last_width_, last_height_));
194 nux::GetPainter().RenderSinglePaintLayer(GfxContext,
195 bg_layer_->GetGeometry(),
196 bg_layer_.get());
197
198 GfxContext.PopClippingRectangle();
199}
200
201void TextInput::DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw)
202{
203 nux::Geometry const& geo = GetGeometry();
204
205 GfxContext.PushClippingRectangle(geo);
206
207 if (highlight_layer_ && ShouldBeHighlighted() && !IsFullRedraw())
208 {
209 nux::GetPainter().PushLayer(GfxContext, highlight_layer_->GetGeometry(), highlight_layer_.get());
210 }
211
212
213 if (!IsFullRedraw())
214 {
215 gPainter.PushLayer(GfxContext, bg_layer_->GetGeometry(), bg_layer_.get());
216 }
217 else
218 {
219 nux::GetPainter().PushPaintLayerStack();
220 }
221
222 layout_->ProcessDraw(GfxContext, force_draw);
223
224 if (!IsFullRedraw())
225 {
226 gPainter.PopBackground();
227 }
228 else
229 {
230 nux::GetPainter().PopPaintLayerStack();
231 }
232
233 GfxContext.PopClippingRectangle();
234}
235
236void TextInput::UpdateBackground(bool force)
237{
238 int RADIUS = 5;
239 nux::Geometry geo(GetGeometry());
240 geo.width = layered_layout_->GetAbsoluteX() +
241 layered_layout_->GetAbsoluteWidth() -
242 GetAbsoluteX() +
243 TEXT_INPUT_RIGHT_BORDER;
244
245 LOG_DEBUG(logger) << "height: "
246 << geo.height << " - "
247 << layered_layout_->GetGeometry().height << " - "
248 << pango_entry_->GetGeometry().height;
249
250 if (geo.width == last_width_
251 && geo.height == last_height_
252 && force == false)
253 return;
254
255 last_width_ = geo.width;
256 last_height_ = geo.height;
257
258 nux::CairoGraphics cairo_graphics(CAIRO_FORMAT_ARGB32, last_width_, last_height_);
259 cairo_t* cr = cairo_graphics.GetContext();
260
261 cairo_graphics.DrawRoundedRectangle(cr,
262 1.0f,
263 0.5, 0.5,
264 RADIUS,
265 last_width_ - 1, last_height_ - 1,
266 false);
267
268 cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
269 cairo_set_source_rgba(cr, 0.0f, 0.0f, 0.0f, 0.35f);
270 cairo_fill_preserve(cr);
271 cairo_set_line_width(cr, 1);
272 cairo_set_source_rgba(cr, 1.0f, 1.0f, 1.0f, 0.7f);
273 cairo_stroke(cr);
274
275 cairo_destroy(cr);
276 nux::BaseTexture* texture2D = texture_from_cairo_graphics(cairo_graphics);
277
278 nux::TexCoordXForm texxform;
279 texxform.SetTexCoordType(nux::TexCoordXForm::OFFSET_COORD);
280 texxform.SetWrap(nux::TEXWRAP_REPEAT, nux::TEXWRAP_REPEAT);
281
282 nux::ROPConfig rop;
283 rop.Blend = true;
284 rop.SrcBlend = GL_ONE;
285 rop.DstBlend = GL_ONE_MINUS_SRC_ALPHA;
286
287 bg_layer_.reset(new nux::TextureLayer(texture2D->GetDeviceTexture(),
288 texxform,
289 nux::color::White,
290 true,
291 rop));
292
293 texture2D->UnReference();
294}
295
296void TextInput::OnMouseButtonDown(int x, int y, unsigned long button, unsigned long key)
297{
298 hint_->SetVisible(false);
299}
300
301void TextInput::OnEndKeyFocus()
302{
303 hint_->SetVisible(input_string().empty());
304}
305
306
307nux::TextEntry* TextInput::text_entry() const
308{
309 return pango_entry_;
310}
311
312std::string TextInput::get_input_string() const
313{
314 return pango_entry_->GetText();
315}
316
317bool TextInput::set_input_string(std::string const& string)
318{
319 pango_entry_->SetText(string.c_str());
320 return true;
321}
322
323bool TextInput::get_im_active() const
324{
325 return pango_entry_->im_active();
326}
327
328bool TextInput::get_im_preedit() const
329{
330 return pango_entry_->im_preedit();
331}
332
333//
334// Highlight
335//
336bool TextInput::ShouldBeHighlighted()
337{
338 return true;
339}
340
341//
342// Key navigation
343//
344bool TextInput::AcceptKeyNavFocus()
345{
346 return false;
347}
348
349//
350// Introspection
351//
352std::string TextInput::GetName() const
353{
354 return "TextInput";
355}
356
357void TextInput::AddProperties(GVariantBuilder* builder)
358{
359 unity::variant::BuilderWrapper(builder)
360 .add(GetAbsoluteGeometry())
361 .add("has_focus", pango_entry_->HasKeyFocus())
362 .add("input_string", pango_entry_->GetText())
363 .add("im_active", pango_entry_->im_active());
364}
365
366} // namespace unity
0367
=== added file 'unity-shared/TextInput.h'
--- unity-shared/TextInput.h 1970-01-01 00:00:00 +0000
+++ unity-shared/TextInput.h 2012-10-17 10:34:19 +0000
@@ -0,0 +1,102 @@
1// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
2/*
3 * Copyright (C) 2012 Canonical Ltd
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 *
17 * Authored by: Manuel de la Pena <manuel.delapena@canonical.com>
18 */
19
20#ifndef TEXTINPUT_H
21#define TEXTINPUT_H
22
23#include <gtk/gtk.h>
24#include <NuxCore/Property.h>
25#include <Nux/LayeredLayout.h>
26#include <Nux/VLayout.h>
27#include <Nux/TextEntry.h>
28#include <UnityCore/GLibSignal.h>
29#include <UnityCore/GLibSource.h>
30
31#include "unity-shared/IconTexture.h"
32#include "unity-shared/IMTextEntry.h"
33#include "unity-shared/Introspectable.h"
34#include "unity-shared/StaticCairoText.h"
35
36namespace nux
37{
38class AbstractPaintLayer;
39class LinearLayout;
40}
41
42namespace unity
43{
44
45class TextInput : public unity::debug::Introspectable, public nux::View
46{
47 NUX_DECLARE_OBJECT_TYPE(TextInput, nux::View);
48public:
49 typedef nux::ObjectPtr<TextInput> Ptr;
50 TextInput(NUX_FILE_LINE_PROTO);
51 TextInput(bool show_filter_hint, NUX_FILE_LINE_PROTO);
52
53 nux::TextEntry* text_entry() const;
54
55 nux::RWProperty<std::string> input_string;
56 nux::Property<std::string> input_hint;
57 nux::ROProperty<bool> im_active;
58 nux::ROProperty<bool> im_preedit;
59
60private:
61
62 void Init();
63
64 void OnFontChanged(GtkSettings* settings, GParamSpec* pspec=NULL);
65 void OnInputHintChanged();
66
67 void Draw(nux::GraphicsEngine& GfxContext, bool force_draw);
68 void DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw);
69
70 void OnMouseButtonDown(int x, int y, unsigned long button_flags, unsigned long key_flags);
71 void OnEndKeyFocus();
72
73 void UpdateBackground(bool force);
74
75 std::string get_input_string() const;
76 bool set_input_string(std::string const& string);
77 bool get_im_active() const;
78 bool get_im_preedit() const;
79
80 std::string GetName() const;
81 void AddProperties(GVariantBuilder* builder);
82 bool AcceptKeyNavFocus();
83
84private:
85 bool ShouldBeHighlighted();
86
87 std::unique_ptr<nux::AbstractPaintLayer> bg_layer_;
88 std::unique_ptr<nux::AbstractPaintLayer> highlight_layer_;
89 nux::HLayout* layout_;
90 nux::LayeredLayout* layered_layout_;
91 nux::StaticCairoText* hint_;
92 IMTextEntry* pango_entry_;
93
94 int last_width_;
95 int last_height_;
96
97 glib::SignalManager sig_manager_;
98};
99
100}
101
102#endif