Commit db045466 authored by Tibor Goldschwendt's avatar Tibor Goldschwendt Committed by Commit Bot

[vr] Add UI to switch between regular and incognito in tabs view

Bug: 840511, 838937
Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel;luci.chromium.try:linux_optional_gpu_tests_rel;luci.chromium.try:mac_optional_gpu_tests_rel;luci.chromium.try:win_optional_gpu_tests_rel;master.tryserver.chromium.linux:linux_vr
Change-Id: I4b688d12e0f08ce265c5796df2d96d473b4591c8
Reviewed-on: https://chromium-review.googlesource.com/1048831
Commit-Queue: Tibor Goldschwendt <tiborg@chromium.org>
Reviewed-by: default avatarChristopher Grant <cjgrant@chromium.org>
Cr-Commit-Position: refs/heads/master@{#557879}
parent 23d25bfb
...@@ -10831,6 +10831,12 @@ Please help our engineers fix this problem. Tell us what happened right before y ...@@ -10831,6 +10831,12 @@ Please help our engineers fix this problem. Tell us what happened right before y
<message name="IDS_VR_MENU_SEND_FEEDBACK" desc="Menu item for sending feedback. [CHAR-LIMIT=27]"> <message name="IDS_VR_MENU_SEND_FEEDBACK" desc="Menu item for sending feedback. [CHAR-LIMIT=27]">
Send feedback Send feedback
</message> </message>
<message name="IDS_VR_TABS_BUTTON_REGULAR" desc="Text on button for selecting regular tabs">
Tabs
</message>
<message name="IDS_VR_TABS_BUTTON_INCOGNITO" desc="Text on button for selecting incognito tabs">
Incognito
</message>
</if> </if>
<message name="IDS_CONFIRM_FILE_UPLOAD_TITLE" desc="Title of dialog for confirming that many files are about to be uploaded / given to the site. [ICU Syntax]"> <message name="IDS_CONFIRM_FILE_UPLOAD_TITLE" desc="Title of dialog for confirming that many files are about to be uploaded / given to the site. [ICU Syntax]">
......
...@@ -118,6 +118,13 @@ void InitializeColorSchemes() { ...@@ -118,6 +118,13 @@ void InitializeColorSchemes() {
normal_scheme.tab_item_background = normal_scheme.omnibox_background; normal_scheme.tab_item_background = normal_scheme.omnibox_background;
normal_scheme.tab_item_text = normal_scheme.url_bar_text; normal_scheme.tab_item_text = normal_scheme.url_bar_text;
normal_scheme.tab_mode_button_selected = normal_scheme.disc_button_colors;
normal_scheme.tab_mode_button_selected.foreground = MakeWhite(100);
normal_scheme.tab_mode_button_selected.background = MakeColor(0x4286F4, 100);
normal_scheme.tab_mode_button_selected.background_hover =
MakeColor(0x4B89ED, 100);
normal_scheme.tab_mode_button_selected.background_down =
MakeColor(0x5F7DAD, 100);
normal_scheme.dimmer_inner = 0xCC0D0D0D; normal_scheme.dimmer_inner = 0xCC0D0D0D;
normal_scheme.dimmer_outer = 0xE6000000; normal_scheme.dimmer_outer = 0xE6000000;
...@@ -301,7 +308,6 @@ void ColorScheme::UpdateForComponent(const base::Version& component_version) { ...@@ -301,7 +308,6 @@ void ColorScheme::UpdateForComponent(const base::Version& component_version) {
normal_scheme.url_bar_background = MakeColor(0xEEEEEE, 87); normal_scheme.url_bar_background = MakeColor(0xEEEEEE, 87);
normal_scheme.omnibox_background = MakeColor(0xEEEEEE, 100); normal_scheme.omnibox_background = MakeColor(0xEEEEEE, 100);
normal_scheme.tab_item_background = normal_scheme.omnibox_background; normal_scheme.tab_item_background = normal_scheme.omnibox_background;
normal_scheme.tab_item_text = normal_scheme.url_bar_text;
ColorScheme& incognito_scheme = g_incognito_scheme.Get(); ColorScheme& incognito_scheme = g_incognito_scheme.Get();
incognito_scheme.disc_button_colors.background = MakeColor(0x263238, 100); incognito_scheme.disc_button_colors.background = MakeColor(0x263238, 100);
...@@ -310,7 +316,6 @@ void ColorScheme::UpdateForComponent(const base::Version& component_version) { ...@@ -310,7 +316,6 @@ void ColorScheme::UpdateForComponent(const base::Version& component_version) {
incognito_scheme.url_bar_background = MakeColor(0x263238, 87); incognito_scheme.url_bar_background = MakeColor(0x263238, 87);
incognito_scheme.omnibox_background = MakeColor(0x263238, 100); incognito_scheme.omnibox_background = MakeColor(0x263238, 100);
incognito_scheme.tab_item_background = incognito_scheme.omnibox_background; incognito_scheme.tab_item_background = incognito_scheme.omnibox_background;
incognito_scheme.tab_item_text = incognito_scheme.url_bar_text;
} }
} }
......
...@@ -93,6 +93,7 @@ struct ColorScheme { ...@@ -93,6 +93,7 @@ struct ColorScheme {
SkColor tab_item_background; SkColor tab_item_background;
SkColor tab_item_text; SkColor tab_item_text;
ButtonColors tab_mode_button_selected;
ButtonColors indicator; ButtonColors indicator;
......
...@@ -58,6 +58,7 @@ struct Model { ...@@ -58,6 +58,7 @@ struct Model {
bool standalone_vr_device = false; bool standalone_vr_device = false;
std::vector<TabModel> regular_tabs; std::vector<TabModel> regular_tabs;
std::vector<TabModel> incognito_tabs; std::vector<TabModel> incognito_tabs;
bool incognito_tabs_view_selected = false;
bool create_tabs_view = false; bool create_tabs_view = false;
// WebVR state. // WebVR state.
......
...@@ -114,6 +114,7 @@ void Ui::SetToolbarState(const ToolbarState& state) { ...@@ -114,6 +114,7 @@ void Ui::SetToolbarState(const ToolbarState& state) {
void Ui::SetIncognito(bool enabled) { void Ui::SetIncognito(bool enabled) {
model_->incognito = enabled; model_->incognito = enabled;
model_->incognito_tabs_view_selected = enabled;
} }
void Ui::SetLoading(bool loading) { void Ui::SetLoading(bool loading) {
......
...@@ -285,9 +285,10 @@ static constexpr float kOverflowMenuItemHeight = 0.080f; ...@@ -285,9 +285,10 @@ static constexpr float kOverflowMenuItemHeight = 0.080f;
static constexpr float kOverflowMenuItemXPadding = 0.024f; static constexpr float kOverflowMenuItemXPadding = 0.024f;
static constexpr float kTabsViewDistance = 2.4f; static constexpr float kTabsViewDistance = 2.4f;
static constexpr float kTabsViewRootMarginDMM = 0.1f;
static constexpr size_t kTabsViewRowCount = 2ul; static constexpr size_t kTabsViewRowCount = 2ul;
static constexpr size_t kTabsViewColumnCount = 3ul; static constexpr size_t kTabsViewColumnCount = 3ul;
static constexpr float kTabsViewMarginDMM = 0.05f; static constexpr float kTabsViewGridMarginDMM = 0.05f;
static constexpr float kTabItemWidthDMM = 0.2f; static constexpr float kTabItemWidthDMM = 0.2f;
static constexpr float kTabItemHeightDMM = 0.15f; static constexpr float kTabItemHeightDMM = 0.15f;
static constexpr float kTabItemCornerRadiusDMM = 0.01f; static constexpr float kTabItemCornerRadiusDMM = 0.01f;
...@@ -295,9 +296,12 @@ static constexpr float kTabItemTextSizeDMM = 0.07f; ...@@ -295,9 +296,12 @@ static constexpr float kTabItemTextSizeDMM = 0.07f;
static constexpr float kTabsViewActivePageOpacity = 1.0f; static constexpr float kTabsViewActivePageOpacity = 1.0f;
static constexpr float kTabsViewInactivePageOpacity = 0.2f; static constexpr float kTabsViewInactivePageOpacity = 0.2f;
static constexpr float kTabsViewHiddenPageOpacity = 0.0f; static constexpr float kTabsViewHiddenPageOpacity = 0.0f;
static constexpr float kTabsViewCloseButtonVerticalOffsetDMM = -0.4f; static constexpr float kTabsViewCloseButtonVerticalOffsetDMM = -0.5f;
static constexpr float kTabsViewCloseButtonDepthOffset = -0.35f; static constexpr float kTabsViewCloseButtonDepthOffset = -0.35f;
static constexpr float kTabsViewVerticalOffsetDMM = -0.1f; static constexpr float kTabsViewVerticalOffsetDMM = -0.1f;
static constexpr float kTabsViewModeButtonWidthDMM = 0.25f;
static constexpr float kTabsViewModeButtonHeightDMM = 0.075f;
static constexpr float kTabsViewModeButtonTextSizeDMM = 0.03f;
} // namespace vr } // namespace vr
......
...@@ -887,8 +887,8 @@ std::unique_ptr<UiElement> CreateTabsView(Model* model, ...@@ -887,8 +887,8 @@ std::unique_ptr<UiElement> CreateTabsView(Model* model,
auto tabs_scroll_view = Create<PagedScrollView>( auto tabs_scroll_view = Create<PagedScrollView>(
kNone, kPhaseNone, kNone, kPhaseNone,
kTabsViewColumnCount * kTabItemWidthDMM + kTabsViewColumnCount * kTabItemWidthDMM +
(kTabsViewColumnCount - 1) * kTabsViewMarginDMM); (kTabsViewColumnCount - 1) * kTabsViewGridMarginDMM);
tabs_scroll_view->set_margin(kTabsViewMarginDMM); tabs_scroll_view->set_margin(kTabsViewGridMarginDMM);
tabs_scroll_view->set_scrollable(true); tabs_scroll_view->set_scrollable(true);
tabs_scroll_view->set_bounds_contain_children(true); tabs_scroll_view->set_bounds_contain_children(true);
tabs_scroll_view->SetTransitionedProperties({SCROLL_OFFSET}); tabs_scroll_view->SetTransitionedProperties({SCROLL_OFFSET});
...@@ -896,7 +896,7 @@ std::unique_ptr<UiElement> CreateTabsView(Model* model, ...@@ -896,7 +896,7 @@ std::unique_ptr<UiElement> CreateTabsView(Model* model,
auto tabs_layout = Create<PagedGridLayout>( auto tabs_layout = Create<PagedGridLayout>(
kNone, kPhaseNone, kTabsViewRowCount, kTabsViewColumnCount, kNone, kPhaseNone, kTabsViewRowCount, kTabsViewColumnCount,
gfx::SizeF(kTabItemWidthDMM, kTabItemHeightDMM)); gfx::SizeF(kTabItemWidthDMM, kTabItemHeightDMM));
tabs_layout->set_margin(kTabsViewMarginDMM); tabs_layout->set_margin(kTabsViewGridMarginDMM);
tabs_layout->set_hit_testable(true); tabs_layout->set_hit_testable(true);
tabs_layout->set_bounds_contain_children(false); tabs_layout->set_bounds_contain_children(false);
tabs_layout->AddBinding(VR_BIND( tabs_layout->AddBinding(VR_BIND(
...@@ -917,6 +917,49 @@ std::unique_ptr<UiElement> CreateTabsView(Model* model, ...@@ -917,6 +917,49 @@ std::unique_ptr<UiElement> CreateTabsView(Model* model,
return tabs_scroll_view; return tabs_scroll_view;
} }
std::unique_ptr<UiElement> CreateTabModeButton(Model* model,
AudioDelegate* audio_delegate,
bool select_incognito) {
auto button = Create<TextButton>(
kNone, kPhaseForeground, kTabsViewModeButtonTextSizeDMM, audio_delegate);
button->set_click_handler(base::BindRepeating(
[](Model* model, bool select_incognito) {
model->incognito_tabs_view_selected = select_incognito;
},
base::Unretained(model), select_incognito));
button->background()->SetSize(kTabsViewModeButtonWidthDMM,
kTabsViewModeButtonHeightDMM);
button->background()->set_padding(0.0f, 0.0f);
button->background()->set_bounds_contain_children(false);
float radius = 0.5f * kTabsViewModeButtonHeightDMM;
button->SetCornerRadii(select_incognito
? CornerRadii({0, radius, 0, radius})
: CornerRadii({radius, 0, radius, 0}));
button->set_hover_offset(0);
// TODO(https://crbug.com/787654): Uppercasing should be conditional.
button->SetText(base::i18n::ToUpper(l10n_util::GetStringUTF16(
select_incognito ? IDS_VR_TABS_BUTTON_INCOGNITO
: IDS_VR_TABS_BUTTON_REGULAR)));
button->AddBinding(std::make_unique<Binding<std::pair<bool, bool>>>(
VR_BIND_LAMBDA(
[](Model* model, bool select_incognito) {
return std::make_pair(
model->incognito,
select_incognito == model->incognito_tabs_view_selected);
},
base::Unretained(model), select_incognito),
VR_BIND_LAMBDA(
[](Button* view, Model* model, const std::pair<bool, bool>& value) {
// Change color if selected.
view->SetButtonColors(
value.second ? model->color_scheme().tab_mode_button_selected
: model->color_scheme().disc_button_colors);
},
base::Unretained(button.get()), base::Unretained(model))));
return button;
}
} // namespace } // namespace
UiSceneCreator::UiSceneCreator(UiBrowserInterface* browser, UiSceneCreator::UiSceneCreator(UiBrowserInterface* browser,
...@@ -3093,21 +3136,31 @@ void UiSceneCreator::CreateTabsViews() { ...@@ -3093,21 +3136,31 @@ void UiSceneCreator::CreateTabsViews() {
Create<LinearLayout>(kNone, kPhaseNone, LinearLayout::kDown); Create<LinearLayout>(kNone, kPhaseNone, LinearLayout::kDown);
tabs_view_root->SetTranslate(0, kTabsViewVerticalOffsetDMM, 0); tabs_view_root->SetTranslate(0, kTabsViewVerticalOffsetDMM, 0);
tabs_view_root->set_bounds_contain_children(true); tabs_view_root->set_bounds_contain_children(true);
tabs_view_root->set_margin(kTabsViewMarginDMM); tabs_view_root->set_margin(kTabsViewRootMarginDMM);
tabs_view_root->SetVisible(false); tabs_view_root->SetVisible(false);
VR_BIND_VISIBILITY(tabs_view_root, VR_BIND_VISIBILITY(tabs_view_root,
model->get_last_opaque_mode() == kModeTabsView); model->get_last_opaque_mode() == kModeTabsView);
auto regular_tabs_view = auto regular_tabs_view =
CreateTabsView(model_, scene_, audio_delegate_, browser_, false); CreateTabsView(model_, scene_, audio_delegate_, browser_, false);
VR_BIND_VISIBILITY(regular_tabs_view, !model->incognito); VR_BIND_VISIBILITY(regular_tabs_view, !model->incognito_tabs_view_selected);
tabs_view_root->AddChild(std::move(regular_tabs_view)); tabs_view_root->AddChild(std::move(regular_tabs_view));
auto incognito_tabs_view = auto incognito_tabs_view =
CreateTabsView(model_, scene_, audio_delegate_, browser_, true); CreateTabsView(model_, scene_, audio_delegate_, browser_, true);
VR_BIND_VISIBILITY(incognito_tabs_view, model->incognito); VR_BIND_VISIBILITY(incognito_tabs_view, model->incognito_tabs_view_selected);
tabs_view_root->AddChild(std::move(incognito_tabs_view)); tabs_view_root->AddChild(std::move(incognito_tabs_view));
auto mode_switcher_layout =
Create<LinearLayout>(kNone, kPhaseNone, LinearLayout::kRight);
mode_switcher_layout->set_bounds_contain_children(true);
mode_switcher_layout->AddChild(
CreateTabModeButton(model_, audio_delegate_, false));
mode_switcher_layout->AddChild(
CreateTabModeButton(model_, audio_delegate_, true));
tabs_view_root->AddChild(std::move(mode_switcher_layout));
auto button_scaler = Create<ScaledDepthAdjuster>( auto button_scaler = Create<ScaledDepthAdjuster>(
kNone, kPhaseNone, kTabsViewCloseButtonDepthOffset); kNone, kPhaseNone, kTabsViewCloseButtonDepthOffset);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment