From db3ed81513f0cbe14cb24fe479de297b26cca6ec Mon Sep 17 00:00:00 2001 From: beholder Date: Tue, 7 Nov 2017 13:45:27 +0300 Subject: [PATCH] adjust to changed requirements: 1. The keyboard collapse button is moved to the lower right, replacing the keys there 2. The button next to m is a hyphen instead of a underscore, it turns to a underscore when the user clicks on shift 3. The input text at the top occupies the full width and is center aligned, when you start typing the text moves in both directions the left and the right --- interface/resources/fonts/hifi-glyphs.ttf | Bin 30784 -> 31232 bytes interface/resources/qml/controls-uit/Key.qml | 1 + .../resources/qml/controls-uit/Keyboard.qml | 120 +++--------------- libraries/ui/src/ui/OffscreenQmlSurface.cpp | 4 + 4 files changed, 24 insertions(+), 101 deletions(-) diff --git a/interface/resources/fonts/hifi-glyphs.ttf b/interface/resources/fonts/hifi-glyphs.ttf index 3db48602b1eb845238497d2f3750fa7d281ccfbc..4cc5a0fe4f098a287c1df067c8bff37695f96d34 100644 GIT binary patch delta 802 zcmYjPO-vI}5dNk=lmNR(TfuH?y6rZQ(hzJ5t)>v;U-eJ~fe_RvE~V1Y)-Ducn~31S zXcQB}swWP5@J5ZMUQ9Tk(VIpNN(}MPgE8PmWAp$qt?5FvlQ-{uGjF~xGs!IfpxIwE z0|LNc7HaeagZ*9UTZM-}<_iGJ@uSCrc!3Ha^BMr(-Ph{rUJ6M74FVVlCq$`#_~T78`Ub5Y_&1FvHhyD8}rnuoujj`$cO1PxpE8Sr9J^D z&7rtOkpYcBtso0DbOJyXDxpG2@oL_gcNL3@wk?l;82kl=QHfVTj#GQon)Wpy7pmAj zcE|z&C+P!4p@t6CsD%LyFvEr>xX=nO{0QJ6g6P6IBruLCWH60uxQ;o@J0LVPRF%x=XM(dq_x=_JE_g*wR!6IQoa0L=bUNqdUh&|0kV=`pec?M z%w~t#>?i|yJ;Ue=TXhUm_s42&wpyJ$->e)b&#(ReB);&*WVf3rV6u}?SY(U_mIAE7 zz#idwr^0k?)2!AlJ;My_h@SGa$2Lvn#&KLzSX)*7fNL{`np&oGn^DBMq0wj acwCfH5qa}6Pq$?*&DE?nX4iK%Wc@Fk$FR}> delta 432 zcmYL^%`0pH7{-6^oHGX*-PHKVoqT11ntaA6w{&AHeAd0bA{-2p3@2yGna!oUWTShm z#D6e~&W5tEw6L&Xqq~@HT}demHd3QGl(*jAr=GW8&$IC)XOFUu0C{YnFc=R1?6YzX ztHG)Q0^OZmVUE$jQi1Y;A9albr@hM{qrmWNOgG~DSG(Z31kcQZZW`${3aq^X*$YdF z`P=;8ouKu?qCXnZ=Y045L%?64B^r&a>uSBEK>R>eG#0nYj*1>Y4naznR%Z2*sa79& zn?Z_Wx@B-DlOUl?pk+N4d2GEH24fn;F;>j@`Hr;@tA6nQcgqP(Z;xzGeQAFt*F$Em zZ?)w6^=QdI^3A&?<9xNh%b3(Sd(tF58CUt(fQvyUP+S#2m5xk5vU%tIO4X#(F1aGb zhr<2UICCnMM#UM`3KpHb)m+JHAViQhyUeUr8$!W0yU*N_E$5$ED9%g#K($X2<+5qt LBuadrIkn^)$9!hA diff --git a/interface/resources/qml/controls-uit/Key.qml b/interface/resources/qml/controls-uit/Key.qml index 586a9c0225..ebdfff36c0 100644 --- a/interface/resources/qml/controls-uit/Key.qml +++ b/interface/resources/qml/controls-uit/Key.qml @@ -11,6 +11,7 @@ Item { property bool toggle: false // does this button have the toggle behaivor? property bool toggled: false // is this button currently toggled? property alias mouseArea: mouseArea1 + property alias fontFamily: letter.font.family; function resetToggledMode(mode) { toggled = mode; diff --git a/interface/resources/qml/controls-uit/Keyboard.qml b/interface/resources/qml/controls-uit/Keyboard.qml index 7f73538c19..5974ffe7bc 100644 --- a/interface/resources/qml/controls-uit/Keyboard.qml +++ b/interface/resources/qml/controls-uit/Keyboard.qml @@ -56,6 +56,8 @@ Rectangle { return ">"; } else if (str === "/") { return "?"; + } else if (str === "-") { + return "_"; } else { return str.toUpperCase(str); } @@ -68,6 +70,8 @@ Rectangle { return "."; } else if (str === "?") { return "/"; + } else if (str === "_") { + return "-"; } else { return str.toLowerCase(str); } @@ -86,7 +90,7 @@ Rectangle { onShiftModeChanged: { forEachKey(function (key) { - if (/[a-z]/i.test(key.glyph)) { + if (/[a-z-_]/i.test(key.glyph)) { if (shiftMode) { key.glyph = keyboardBase.toUpper(key.glyph); } else { @@ -125,11 +129,11 @@ Rectangle { font.family: font.name font.pixelSize: 20 verticalAlignment: Text.AlignVCenter - horizontalAlignment: Text.AlignLeft + horizontalAlignment: Text.AlignHCenter color: "#00B4EF"; anchors.left: parent.left anchors.leftMargin: 10 - anchors.right: lowerKeyboard.left + anchors.right: parent.right anchors.top: parent.top anchors.bottom: parent.bottom @@ -149,98 +153,6 @@ Rectangle { anchors.fill: parent } } - - Item { - id: lowerKeyboard - anchors.right: parent.right - anchors.rightMargin: keyboardRect.width - (key_Backspace.x + key_Backspace.width + key_Backspace.contentPadding) - width: key_Backspace.width * 2 - height: parent.height - - Rectangle { - id: roundedRect - color: "#121212" - radius: 6 - border.color: "#00000000" - anchors.fill: parent - anchors.margins: 4 - - MouseArea { - id: mouseArea - anchors.fill: parent - hoverEnabled: true - - onClicked: { - webEntity.lowerKeyboard(); - } - - onEntered: { - roundedRect.state = "mouseOver"; - } - - onExited: { - roundedRect.state = ""; - } - - onPressed: { - roundedRect.state = "mouseClicked"; - } - - onReleased: { - if (containsMouse) { - roundedRect.state = "mouseOver"; - } else { - roundedRect.state = ""; - } - } - } - - states: [ - State { - name: "mouseOver" - PropertyChanges { - target: roundedRect - color: "#121212" - border.width: 2 - border.color: "#00b4ef" - } - }, - State { - name: "mouseClicked" - PropertyChanges { - target: roundedRect - border.width: 2 - border.color: "#00b4ef" - } - PropertyChanges { - target: colorOverlay - color: '#00B4EF' - } - }, - State { - name: "mouseDepressed" - PropertyChanges { - target: roundedRect - color: "#0578b1" - border.width: 0 - } - } - ] - - Image { - id: buttonImage - anchors.centerIn: parent - source: "../../images/lowerKeyboard.png" // "file:///D:/AI/hifi-elderorb-vs2/interface/resources/images/lowerKeyboard.png"; - } - - ColorOverlay { - id: colorOverlay - anchors.fill: buttonImage - source: buttonImage - color: 'white' - } - } - } } Rectangle { @@ -253,6 +165,8 @@ Rectangle { anchors.bottom: parent.bottom anchors.bottomMargin: 0 + FontLoader { id: hiFiGlyphs; source: pathToFonts + "fonts/hifi-glyphs.ttf"; } + Column { id: columnAlpha width: keyboardWidth @@ -275,7 +189,7 @@ Rectangle { Key { width: 43; glyph: "i"; } Key { width: 43; glyph: "o"; } Key { width: 43; glyph: "p"; } - Key { width: 43; glyph: "←"; id: key_Backspace } + Key { width: 43; glyph: "←"; } } Row { @@ -316,7 +230,7 @@ Rectangle { Key { width: 43; glyph: "b"; } Key { width: 43; glyph: "n"; } Key { width: 43; glyph: "m"; } - Key { width: 43; glyph: "_"; } + Key { width: 43; glyph: "-"; } Key { width: 43; glyph: "/"; } Key { width: 43; glyph: "?"; } } @@ -335,8 +249,10 @@ Rectangle { Key { width: 231; glyph: " "; } Key { width: 43; glyph: ","; } Key { width: 43; glyph: "."; } - Key { width: 43; glyph: "\u276C"; } - Key { width: 43; glyph: "\u276D"; } + Key { + fontFamily: hiFiGlyphs.name; + width: 86; glyph: "\ue02b"; + } } } @@ -423,8 +339,10 @@ Rectangle { Key { width: 231; glyph: " "; } Key { width: 43; glyph: ","; } Key { width: 43; glyph: "."; } - Key { width: 43; glyph: "\u276C"; } - Key { width: 43; glyph: "\u276D"; } + Key { + fontFamily: hiFiGlyphs.name; + width: 86; glyph: "\ue02b"; + } } } } diff --git a/libraries/ui/src/ui/OffscreenQmlSurface.cpp b/libraries/ui/src/ui/OffscreenQmlSurface.cpp index 8333e87799..24e1006083 100644 --- a/libraries/ui/src/ui/OffscreenQmlSurface.cpp +++ b/libraries/ui/src/ui/OffscreenQmlSurface.cpp @@ -1038,6 +1038,7 @@ static const uint8_t BACKSPACE_SYMBOL[] = { 0xE2, 0x86, 0x90, 0x00 }; static const uint8_t LEFT_ARROW[] = { 0xE2, 0x9D, 0xAC, 0x00 }; static const uint8_t RIGHT_ARROW[] = { 0xE2, 0x9D, 0xAD, 0x00 }; static const uint8_t RETURN_SYMBOL[] = { 0xE2, 0x8F, 0x8E, 0x00 }; +static const uint8_t COLLAPSE_KEYBOARD[] = { 0xEE, 0x80, 0xAB, 0x00 }; static const char PUNCTUATION_STRING[] = "123"; static const char ALPHABET_STRING[] = "abc"; @@ -1061,6 +1062,9 @@ void OffscreenQmlSurface::synthesizeKeyPress(QString key, QObject* targetOverrid if (equals(utf8Key, SHIFT_ARROW) || equals(utf8Key, NUMERIC_SHIFT_ARROW) || equals(utf8Key, (uint8_t*)PUNCTUATION_STRING) || equals(utf8Key, (uint8_t*)ALPHABET_STRING)) { return; // ignore + } else if (equals(utf8Key, COLLAPSE_KEYBOARD)) { + lowerKeyboard(); + return; } else if (equals(utf8Key, BACKSPACE_SYMBOL)) { scanCode = Qt::Key_Backspace; keyString = "\x08";