Android-cuttlefish cvd tool
layout.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2021 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#pragma once
18
19#include <teeui/button.h>
20#include <teeui/label.h>
22#include <teeui/utils.h>
23
24#include "fonts.h"
25
27
28namespace teeui {
29
30DECLARE_PARAMETER(RightEdgeOfScreen);
31DECLARE_PARAMETER(BottomOfScreen);
32DECLARE_PARAMETER(DefaultFontSize); // dps(14) regular and dps(18) magnified
33DECLARE_PARAMETER(BodyFontSize); // dps(16) regular and dps(20) magnified
37
38CONSTANT(BorderWidth, dps(24));
39
43
45
47
48NEW_PARAMETER_SET(ConfUIParameters, RightEdgeOfScreen, BottomOfScreen,
49 DefaultFontSize, BodyFontSize, ShieldColor, ColorText,
50 ColorBG, ColorButton);
51
52CONSTANT(IconShieldDistanceFromTop, dps(100));
53CONSTANT(LabelBorderZone, dps(4));
54CONSTANT(RightLabelEdge, RightEdgeOfScreen() - BorderWidth);
55CONSTANT(LabelWidth, RightLabelEdge - BorderWidth);
56CONSTANT(ButtonHeight, dps(72));
57CONSTANT(ButtonPositionX, 0);
58CONSTANT(ButtonPositionY, BottomOfScreen() - ButtonHeight);
59CONSTANT(ButtonWidth, dps(130));
60CONSTANT(ButtonLabelDistance, dps(12));
61
62BEGIN_ELEMENT(IconShield, teeui::Label)
67Position(BorderWidth, IconShieldDistanceFromTop);
69 "A"); // ShieldTTF has just one glyph at the code point for capital A
70TextColor(ShieldColor());
74
75BEGIN_ELEMENT(LabelTitle, teeui::Label)
79Dimension(LabelWidth, HeightFromLines);
80Position(BorderWidth, BOTTOM_EDGE_OF(IconShield) + dps(16));
81DefaultText("Android Protected Confirmation");
84TextColor(ColorText());
87
89Dimension(ButtonWidth, ButtonHeight - BorderWidth);
90Position(RightEdgeOfScreen() - ButtonWidth - BorderWidth,
91 ButtonPositionY + ButtonLabelDistance);
93ButtonColor(ColorButton());
99
100BEGIN_ELEMENT(LabelOK, teeui::Label)
101FontSize(BodyFontSize());
102LineHeight(BodyFontSize() * pxs(1.4));
104Dimension(ButtonWidth - (LabelBorderZone * dps(2)),
105 ButtonHeight - BorderWidth - (LabelBorderZone * dps(2)));
106Position(RightEdgeOfScreen() - ButtonWidth - BorderWidth + LabelBorderZone,
107 ButtonPositionY + ButtonLabelDistance + LabelBorderZone);
108DefaultText("Confirm");
112TextColor(ColorBG());
115
116BEGIN_ELEMENT(LabelCancel, teeui::Label)
117FontSize(BodyFontSize());
118LineHeight(BodyFontSize() * pxs(1.4));
120Dimension(ButtonWidth - (LabelBorderZone * dps(2)),
121 ButtonHeight - BorderWidth - (LabelBorderZone * dps(2)));
122Position(BorderWidth + LabelBorderZone,
123 ButtonPositionY + ButtonLabelDistance + LabelBorderZone);
124DefaultText("Cancel");
128TextColor(ColorButton());
131
132BEGIN_ELEMENT(LabelHint, teeui::Label)
133FontSize(DefaultFontSize());
134LineHeight(DefaultFontSize() * pxs(1.5));
136Dimension(LabelWidth, HeightFromLines);
137Position(BorderWidth, ButtonPositionY - dim_h - dps(48));
139 "This confirmation provides an extra layer of security for the action "
140 "you're "
141 "about to take.");
143TextColor(ColorText());
144Font(DefaultFont);
147
148BEGIN_ELEMENT(LabelBody, teeui::Label)
149FontSize(BodyFontSize());
150LineHeight(BodyFontSize() * pxs(1.4));
152Position(BorderWidth, BOTTOM_EDGE_OF(LabelTitle) + dps(16));
153Dimension(LabelWidth, LabelHint::pos_y - pos_y - dps(24));
155 "12345678901234567890123456789012345678901234567890123456789012345678901234"
156 "567890123456"
157 "78901234567890");
158TextColor(ColorText());
161
162NEW_LAYOUT(ConfUILayout, IconShield, LabelTitle, LabelHint, LabelBody, IconOk,
163 LabelOK, LabelCancel);
164
165} // namespace teeui
#define ConvexObjectCount(n)
Definition: button.h:127
Definition: button.h:69
Definition: utils.h:332
Definition: label.h:107
unsigned char Shield[]
unsigned char RobotoRegular[]
unsigned char RobotoMedium[]
unsigned int RobotoMedium_length
unsigned int Shield_length
unsigned int RobotoRegular_length
#define FONT(name)
Definition: label.h:162
#define HeightFromLines
Definition: label.h:145
TranslationId
Definition: ConfirmationUITranslations.h:34
Definition: layout.h:28
VerticallyCentered
Definition: layout.h:83
HorizontalTextAlignment(Alignment::CENTER)
NEW_PARAMETER_SET(ConfUIParameters, RightEdgeOfScreen, BottomOfScreen, DefaultFontSize, BodyFontSize, ShieldColor, ColorText, ColorBG, ColorButton)
END_ELEMENT()
Font(FONT(Shield))
TextID(TEXT_ID(TranslationId::TITLE))
VerticalTextAlignment(Alignment::CENTER)
RoundBottomLeft
Definition: layout.h:95
Dimension(LabelWidth, HeightFromLines)
RoundTopLeft
Definition: layout.h:94
TextColor(ShieldColor())
DECLARE_PARAMETER(RightEdgeOfScreen)
Alignment
Definition: label.h:28
ButtonColor(ColorButton())
NEW_LAYOUT(ConfUILayout, IconShield, LabelTitle, LabelHint, LabelBody, IconOk, LabelOK, LabelCancel)
FontSize(dps(24))
uint32_t Color
Definition: utils.h:594
Position(BorderWidth, IconShieldDistanceFromTop)
RoundBottomRight
Definition: layout.h:97
CornerRadius(dps(4))
DefaultText("A")
DECLARE_FONT_BUFFER(RobotoMedium, RobotoMedium, RobotoMedium_length)
LineHeight(dps(24))
NumberOfLines(1)
DECLARE_TYPED_PARAMETER(ShieldColor, ::teeui::Color)
CONSTANT(BorderWidth, dps(24))
Coordinate< dp > dps
Definition: utils.h:527
RoundTopRight
Definition: layout.h:96
#define TEXT_ID(textId)
Definition: utils.h:1010
#define BOTTOM_EDGE_OF(name)
Definition: utils.h:994
#define BEGIN_ELEMENT(name, type,...)
Definition: utils.h:978