Changeset 78682 in vbox for trunk/src/VBox
- Timestamp:
- May 23, 2019 9:30:36 AM (6 years ago)
- svn:sync-xref-src-repo-rev:
- 130758
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/softkeyboard
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/softkeyboard/UISoftKeyboard.cpp
r78680 r78682 169 169 UISoftKeyboardRow(QWidget *pParent = 0); 170 170 void updateLayout(); 171 void setKeepAspectRatio(bool fKeepAspectRatio); 172 173 void setUnscaledWidth(int iWidth); 174 int unscaledWidth() const; 175 176 void setUnscaledHeight(int iWidth); 177 int unscaledHeight() const; 178 179 void addKey(UISoftKeyboardKey *pKey); 180 181 private: 182 171 183 int m_iWidth; 172 184 int m_iHeight; 173 185 QVector<UISoftKeyboardKey*> m_keys; 186 bool m_fKeepAspectRatio; 174 187 }; 175 188 … … 491 504 , m_iWidth(0) 492 505 , m_iHeight(0) 493 494 { 506 , m_fKeepAspectRatio(false) 507 { 508 } 509 510 void UISoftKeyboardRow::setKeepAspectRatio(bool fKeepAspectRatio) 511 { 512 m_fKeepAspectRatio = fKeepAspectRatio; 513 } 514 515 void UISoftKeyboardRow::setUnscaledWidth(int iWidth) 516 { 517 m_iWidth = iWidth; 518 } 519 520 int UISoftKeyboardRow::unscaledWidth() const 521 { 522 return m_iWidth; 523 } 524 525 void UISoftKeyboardRow::setUnscaledHeight(int iHeight) 526 { 527 m_iHeight = iHeight; 528 } 529 530 int UISoftKeyboardRow::unscaledHeight() const 531 { 532 return m_iHeight; 533 } 534 535 void UISoftKeyboardRow::addKey(UISoftKeyboardKey *pKey) 536 { 537 m_keys.append(pKey); 495 538 } 496 539 … … 500 543 return; 501 544 502 float fMultiplier = height() / (float)m_iHeight; 545 546 float fMultiplier = 1; 547 if (m_fKeepAspectRatio) 548 fMultiplier = height() / (float)m_iHeight; 549 else 550 fMultiplier = width() / (float)m_iWidth; 503 551 int iX = 0; 504 552 for (int i = 0; i < m_keys.size(); ++i) … … 538 586 , m_iTotalRowHeight(0) 539 587 , m_iMaxRowWidth(0) 588 , m_fKeepAspectRatio(false) 540 589 { 541 590 prepareObjects(); … … 678 727 UISoftKeyboardRow *pNewRow = new UISoftKeyboardRow(m_pContainerWidget); 679 728 m_rows.push_back(pNewRow); 680 pNewRow->m_iHeight = layout.m_rows[i].m_iHeight; 729 pNewRow->setUnscaledHeight(layout.m_rows[i].m_iHeight); 730 pNewRow->setKeepAspectRatio(m_fKeepAspectRatio); 681 731 m_iTotalRowHeight += layout.m_rows[i].m_iHeight; 682 pNewRow->m_iWidth = 0;732 int iRowWidth = 0; 683 733 for (int j = 0; j < layout.m_rows[i].m_keys.size(); ++j) 684 734 { 685 735 const SoftKeyboardKey &key = layout.m_rows[i].m_keys[j]; 686 pNewRow->m_iWidth += key.m_iWidth;687 pNewRow->m_iWidth += key.m_iSpaceAfter;736 iRowWidth += key.m_iWidth; 737 iRowWidth += key.m_iSpaceAfter; 688 738 UISoftKeyboardKey *pKey = new UISoftKeyboardKey(pNewRow); 689 739 if (!pKey) … … 692 742 connect(pKey, &UISoftKeyboardKey::released, this, &UISoftKeyboard::sltHandleKeyRelease); 693 743 connect(pKey, &UISoftKeyboardKey::sigStateChanged, this, &UISoftKeyboard::sltHandleModifierStateChange); 694 pNewRow-> m_keys.append(pKey);744 pNewRow->addKey(pKey); 695 745 pKey->setText(key.m_strLabel); 696 746 pKey->setWidth(key.m_iWidth); … … 701 751 pKey->hide(); 702 752 } 703 m_iMaxRowWidth = qMax(m_iMaxRowWidth, pNewRow->m_iWidth); 753 pNewRow->setUnscaledWidth(iRowWidth); 754 m_iMaxRowWidth = qMax(m_iMaxRowWidth, pNewRow->unscaledWidth()); 704 755 } 705 756 } … … 713 764 if (containerSize.width() == 0 || containerSize.height() == 0) 714 765 return; 715 float fMultiplier = containerSize.width() / (float) m_iMaxRowWidth; 766 767 float fMultiplierX = containerSize.width() / (float) m_iMaxRowWidth; 768 float fMultiplierY = containerSize.height() / (float) m_iTotalRowHeight; 769 float fMultiplier = fMultiplierX; 716 770 717 771 if (fMultiplier * m_iTotalRowHeight > containerSize.height()) 718 fMultiplier = containerSize.height() / (float) m_iTotalRowHeight;772 fMultiplier = fMultiplierY; 719 773 720 774 int y = 0; … … 726 780 if (!pRow) 727 781 continue; 728 pRow->setGeometry(0, y, fMultiplier * pRow->m_iWidth, fMultiplier * pRow->m_iHeight); 729 pRow->setVisible(true); 730 y += fMultiplier * pRow->m_iHeight; 731 totalWidth += fMultiplier * pRow->m_iWidth; 732 totalHeight += fMultiplier * pRow->m_iHeight; 782 if(m_fKeepAspectRatio) 783 { 784 pRow->setGeometry(0, y, fMultiplier * pRow->unscaledWidth(), fMultiplier * pRow->unscaledHeight()); 785 pRow->setVisible(true); 786 y += fMultiplier * pRow->unscaledHeight(); 787 totalWidth += fMultiplier * pRow->unscaledWidth(); 788 totalHeight += fMultiplier * pRow->unscaledHeight(); 789 } 790 else 791 { 792 pRow->setGeometry(0, y, fMultiplierX * pRow->unscaledWidth(), fMultiplierY * pRow->unscaledHeight()); 793 pRow->setVisible(true); 794 y += fMultiplierY * pRow->unscaledHeight(); 795 totalWidth += fMultiplierX * pRow->unscaledWidth(); 796 totalHeight += fMultiplierY * pRow->unscaledHeight(); 797 } 733 798 pRow->updateLayout(); 734 799 } 800 if (m_rows.size() > 0) 801 printf("row 0 width %d\n", m_rows[0]->size().width()); 735 802 } 736 803 -
trunk/src/VBox/Frontends/VirtualBox/src/softkeyboard/UISoftKeyboard.h
r78661 r78682 85 85 int m_iMaxRowWidth; 86 86 QVector<UISoftKeyboardKey*> m_pressedModifiers; 87 bool m_fKeepAspectRatio; 87 88 }; 88 89
Note:
See TracChangeset
for help on using the changeset viewer.