-
Notifications
You must be signed in to change notification settings - Fork 8
Advanced text input options #25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 13 commits
eb1278f
116154b
c959aa0
ff9486d
aa6623b
5566608
5d3d4b3
0f5a10e
aa1c87d
6b0a2d8
5821267
7978db9
9f93270
5aca9c2
f37e3fd
9f3b843
704c6b1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
// Copyright 2023 Samsung Electronics Co., Ltd. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "flutter/shell/platform/tizen/nui_autofill_popup.h" | ||
|
||
#include <dali-toolkit/dali-toolkit.h> | ||
#include <dali-toolkit/devel-api/controls/table-view/table-view.h> | ||
#include <dali-toolkit/public-api/controls/text-controls/text-label.h> | ||
|
||
#include "flutter/shell/platform/tizen/tizen_autofill.h" | ||
|
||
namespace flutter { | ||
swift-kim marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
bool NuiAutofillPopup::Touched(Dali::Actor actor, | ||
const Dali::TouchEvent& event) { | ||
const Dali::PointState::Type state = event.GetState(0); | ||
if (Dali::PointState::DOWN == state) { | ||
std::string text = | ||
actor.GetProperty(Dali::Actor::Property::NAME).Get<std::string>(); | ||
on_commit_(text); | ||
Hide(); | ||
} | ||
return true; | ||
} | ||
|
||
void NuiAutofillPopup::Hide() { | ||
// TODO(Swanseo0) : There is a phenomenon where white traces remain for a | ||
// while when popup disappears. | ||
popup_.SetDisplayState(Dali::Toolkit::Popup::HIDDEN); | ||
} | ||
|
||
void NuiAutofillPopup::Hidden() { | ||
popup_.Unparent(); | ||
popup_.Reset(); | ||
} | ||
|
||
void NuiAutofillPopup::OutsideTouched() { | ||
Hide(); | ||
} | ||
|
||
void NuiAutofillPopup::PrepareAutofill() { | ||
popup_ = Dali::Toolkit::Popup::New(); | ||
popup_.SetProperty(Dali::Actor::Property::NAME, "popup"); | ||
popup_.SetProperty(Dali::Actor::Property::PARENT_ORIGIN, | ||
Dali::ParentOrigin::TOP_LEFT); | ||
popup_.SetProperty(Dali::Actor::Property::ANCHOR_POINT, | ||
Dali::AnchorPoint::TOP_LEFT); | ||
popup_.SetProperty(Dali::Toolkit::Popup::Property::TAIL_VISIBILITY, false); | ||
popup_.SetBackgroundColor(Dali::Color::WHITE_SMOKE); | ||
popup_.OutsideTouchedSignal().Connect(this, | ||
&NuiAutofillPopup::OutsideTouched); | ||
popup_.HiddenSignal().Connect(this, &NuiAutofillPopup::Hidden); | ||
swift-kim marked this conversation as resolved.
Show resolved
Hide resolved
|
||
popup_.SetProperty(Dali::Toolkit::Popup::Property::BACKING_ENABLED, false); | ||
popup_.SetProperty(Dali::Toolkit::Popup::Property::AUTO_HIDE_DELAY, 2500); | ||
JSUYA marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
void NuiAutofillPopup::PopupAutofill(Dali::Actor* actor) { | ||
swift-kim marked this conversation as resolved.
Show resolved
Hide resolved
|
||
const std::vector<std::unique_ptr<AutofillItem>>& items = | ||
TizenAutofill::GetInstance().GetAutofillItems(); | ||
if (items.size() > 0) { | ||
swift-kim marked this conversation as resolved.
Show resolved
Hide resolved
|
||
PrepareAutofill(); | ||
Dali::Toolkit::TableView content = | ||
Dali::Toolkit::TableView::New(items.size(), 1); | ||
content.SetResizePolicy(Dali::ResizePolicy::FILL_TO_PARENT, | ||
Dali::Dimension::ALL_DIMENSIONS); | ||
content.SetProperty(Dali::Actor::Property::PADDING, | ||
Dali::Vector4(10, 10, 0, 0)); | ||
for (uint32_t i = 0; i < items.size(); ++i) { | ||
Dali::Toolkit::TextLabel label = | ||
Dali::Toolkit::TextLabel::New(items[i]->label_); | ||
label.SetProperty(Dali::Actor::Property::NAME, items[i]->value_); | ||
label.SetResizePolicy(Dali::ResizePolicy::DIMENSION_DEPENDENCY, | ||
Dali::Dimension::HEIGHT); | ||
label.SetProperty(Dali::Toolkit::TextLabel::Property::TEXT_COLOR, | ||
Dali::Color::WHITE_SMOKE); | ||
label.SetProperty(Dali::Toolkit::TextLabel::Property::POINT_SIZE, 7.0f); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Q. Are there any default values for these properties? It'd be nice if we could avoid using magic numbers. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The default There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does "white background" and "7.0f font size" look good for both tv and common (rpi) profiles? +) NUI popup may differ from Dali popup. It might be better to set it equal to that value. |
||
label.TouchedSignal().Connect(this, &NuiAutofillPopup::Touched); | ||
content.AddChild(label, Dali::Toolkit::TableView::CellPosition(i, 0)); | ||
content.SetFitHeight(i); | ||
} | ||
popup_.SetProperty(Dali::Actor::Property::SIZE, | ||
Dali::Vector2(140.0f, 35.0f * items.size())); | ||
JSUYA marked this conversation as resolved.
Show resolved
Hide resolved
|
||
popup_.SetContent(content); | ||
popup_.SetDisplayState(Dali::Toolkit::Popup::SHOWN); | ||
actor->Add(popup_); | ||
} | ||
} | ||
|
||
} // namespace flutter |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// Copyright 2023 Samsung Electronics Co., Ltd. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#ifndef EMBEDDER_NUI_AUTOFILL_POPUP_H_ | ||
#define EMBEDDER_NUI_AUTOFILL_POPUP_H_ | ||
|
||
#include <dali-toolkit/devel-api/controls/popup/popup.h> | ||
|
||
#include <functional> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing includes? #include <dali/public-api/dali-core.h>
#include <string> Please consult me or @bbrto21 on how to organize includes in the implementation file ( |
||
|
||
namespace flutter { | ||
|
||
using OnCommit = std::function<void(std::string str)>; | ||
swift-kim marked this conversation as resolved.
Show resolved
Hide resolved
|
||
using OnRendering = std::function<void()>; | ||
swift-kim marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
class NuiAutofillPopup : public Dali::ConnectionTracker { | ||
swift-kim marked this conversation as resolved.
Show resolved
Hide resolved
|
||
public: | ||
void Hide(); | ||
|
||
void Hidden(); | ||
|
||
void OutsideTouched(); | ||
|
||
void PrepareAutofill(); | ||
|
||
void PopupAutofill(Dali::Actor* actor); | ||
|
||
void SetOnCommit(OnCommit callback) { on_commit_ = callback; } | ||
|
||
bool Touched(Dali::Actor actor, const Dali::TouchEvent& event); | ||
swift-kim marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
private: | ||
Dali::Toolkit::Popup popup_; | ||
OnCommit on_commit_; | ||
}; | ||
|
||
} // namespace flutter | ||
|
||
#endif |
Uh oh!
There was an error while loading. Please reload this page.