Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
arc: Add display overlay with input mapping view
Display overlay is added as exo/surface overlay. Once the window is unregistered, the display overlay is removed too. The UIs still need to be polished according to the UX requirement when it's ready. This is simple version and the overlay structure. And then it can add other components like menu and education dialog. Since display overlay is added on exo/surface, rewrote some unit_tests depending on exo::test::ExoTestBase and added class to create test window with exo/surface. DisplayOverlayControllerTest*/TouchInjectorTest* Bug: b:188452744 Test: unit_tests--gtest_filter=ArcInputOverlayManagerTest*/ Change-Id: I8620cf054fe5025282b34099236971184cf2826d Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3273312 Reviewed-by: Yuichiro Hanada <yhanada@chromium.org> Auto-Submit: Cici Ruan <cuicuiruan@google.com> Commit-Queue: Cici Ruan <cuicuiruan@google.com> Cr-Commit-Position: refs/heads/main@{#948633}
- Loading branch information
Cici Ruan
authored and
Chromium LUCI CQ
committed
Dec 6, 2021
1 parent
0d1001c
commit 5241024
Showing
19 changed files
with
626 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
chrome/browser/ash/arc/input_overlay/actions/action_label.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// Copyright 2021 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "chrome/browser/ash/arc/input_overlay/actions/action_label.h" | ||
|
||
#include "third_party/skia/include/core/SkColor.h" | ||
#include "ui/gfx/color_palette.h" | ||
#include "ui/views/background.h" | ||
|
||
namespace arc { | ||
namespace input_overlay { | ||
|
||
constexpr int kWidthPadding = 10; | ||
constexpr int kMinimumLabelWidth = 20; | ||
|
||
ActionLabel::ActionLabel() : views::Label() {} | ||
ActionLabel::ActionLabel(const std::u16string& text) : views::Label(text) { | ||
SetDefaultViewMode(); | ||
} | ||
|
||
ActionLabel::~ActionLabel() = default; | ||
|
||
void ActionLabel::SetDefaultViewMode() { | ||
// TODO(cuicuiruan): Replace it with required color once UI/UX specs are | ||
// confirmed. | ||
SetBackground(views::CreateSolidBackground(gfx::kGoogleGrey400)); | ||
} | ||
|
||
void ActionLabel::SetPositionFromCenterPosition(gfx::PointF& center_position) { | ||
auto size = GetPreferredSize(); | ||
SetSize(size); | ||
int left = std::max(0, (int)(center_position.x() - size.width() / 2)); | ||
int top = std::max(0, (int)(center_position.y() - size.height() / 2)); | ||
// SetPosition function needs the top-left position. | ||
SetPosition(gfx::Point(left, top)); | ||
} | ||
|
||
gfx::Size ActionLabel::CalculatePreferredSize() const { | ||
auto size = Label::CalculatePreferredSize(); | ||
size.set_width(size.width() + kWidthPadding); | ||
if (size.width() < kMinimumLabelWidth) | ||
size.set_width(kMinimumLabelWidth); | ||
return size; | ||
} | ||
|
||
} // namespace input_overlay | ||
} // namespace arc |
34 changes: 34 additions & 0 deletions
34
chrome/browser/ash/arc/input_overlay/actions/action_label.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Copyright 2021 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#ifndef CHROME_BROWSER_ASH_ARC_INPUT_OVERLAY_ACTIONS_ACTION_LABEL_H_ | ||
#define CHROME_BROWSER_ASH_ARC_INPUT_OVERLAY_ACTIONS_ACTION_LABEL_H_ | ||
|
||
#include "ui/views/controls/label.h" | ||
|
||
namespace arc { | ||
namespace input_overlay { | ||
// ActionLabel is the basic UI label for the action. It can set default view | ||
// mode and edit mode. | ||
class ActionLabel : public views::Label { | ||
public: | ||
ActionLabel(); | ||
explicit ActionLabel(const std::u16string& text); | ||
|
||
ActionLabel(const ActionLabel&) = delete; | ||
ActionLabel& operator=(const ActionLabel&) = delete; | ||
~ActionLabel() override; | ||
|
||
// Set it with default view mode. | ||
void SetDefaultViewMode(); | ||
// Set position from its center position. | ||
void SetPositionFromCenterPosition(gfx::PointF& center_position); | ||
|
||
// views::View: | ||
gfx::Size CalculatePreferredSize() const override; | ||
}; | ||
} // namespace input_overlay | ||
} // namespace arc | ||
|
||
#endif // CHROME_BROWSER_ASH_ARC_INPUT_OVERLAY_ACTIONS_ACTION_LABEL_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.