From 9ba0984f21881bc6b54b5c7ba233044fe0a03770 Mon Sep 17 00:00:00 2001 From: Lukas Kalinowski Date: Fri, 17 Mar 2023 16:46:01 +0100 Subject: [PATCH] Added custom changes. See ChangeLog_rus.txt --- ChangeLog_rus.txt | 20 +++++++++++++++++++ MyGUIEngine/include/MyGUI_ComboBox.h | 7 +++++++ MyGUIEngine/include/MyGUI_ListBox.h | 4 ++++ MyGUIEngine/include/MyGUI_Widget.h | 6 ++++++ MyGUIEngine/src/MyGUI_ComboBox.cpp | 27 +++++++++++++++++++++----- MyGUIEngine/src/MyGUI_InputManager.cpp | 2 +- MyGUIEngine/src/MyGUI_ListBox.cpp | 24 +++++++++++++++++++++-- MyGUIEngine/src/MyGUI_ScrollBar.cpp | 1 + MyGUIEngine/src/MyGUI_Widget.cpp | 18 ++++++++++++++--- 9 files changed, 98 insertions(+), 11 deletions(-) diff --git a/ChangeLog_rus.txt b/ChangeLog_rus.txt index 9cc8339e1a..58e3745e71 100644 --- a/ChangeLog_rus.txt +++ b/ChangeLog_rus.txt @@ -378,3 +378,23 @@ - Demo_ScrollView - демонстрация прокручиваемого поля - Demo_Themes - демонстрация различных тем - Demo_StaticImage - демонстрация простейшего вьювера ImageSet + +-----Changelog 2023------ +MyGUI_ComboBox: +- set/getItemHeight +- void setAutoHideList(bool autoHide); - Manually control whether to close the list + +MyGUI_InputManager: +- Changed double click threshold from 0.25 seconds to 0.5 seconds. Else it was often not possible to trigger an double click, but two times a single click has been triggered. + +MyGUI_ListBox: +- set/getItemHeight + +MyGUI_ScrollBar: +- Fixed mouse release: Additional Rising mouse release, so that it also can be used outside this scrollbar. + +MyGUI_Widget: +- Added x, y pixel threshold, because else lost focus is triggered in each input field to early and its not possible to adapt values properly +- Usage: void Widget::setMouseHitThreshold(int xLeftThreshold, int xRightThreshold, int yLeftThreshold, int yRightThreshold) +E.g. MyGUI::EditBox* edit; + edit->setMouseHitThreshold(6, 6, 3, 3); diff --git a/MyGUIEngine/include/MyGUI_ComboBox.h b/MyGUIEngine/include/MyGUI_ComboBox.h index 14b65b7077..2c0286ac43 100644 --- a/MyGUIEngine/include/MyGUI_ComboBox.h +++ b/MyGUIEngine/include/MyGUI_ComboBox.h @@ -37,6 +37,11 @@ namespace MyGUI //------------------------------------------------------------------------------// // манипуляции айтемами + //////// Lax 26.10.2020 ///////////////// + void setItemHeight(int itemHeight); + + ListBox* getList(void) const; + //////// Lax 26.10.2020 ///////////////// //! Get number of items size_t getItemCount() const; @@ -138,6 +143,7 @@ namespace MyGUI //! Get direction, where drop down list appears. FlowDirection getFlowDirection() const; + void setAutoHideList(bool autoHide); /*events:*/ /** Event : Enter pressed in combo mode or item selected in drop down list and combo mode drop enabled (see void ComboBox::setComboModeDrop(bool _value)).\n @@ -196,6 +202,7 @@ namespace MyGUI ListBox* mList; bool mListShow; + bool mAutoHideList; int mMaxListLength; size_t mItemIndex; bool mModeDrop; diff --git a/MyGUIEngine/include/MyGUI_ListBox.h b/MyGUIEngine/include/MyGUI_ListBox.h index 7bdf903e5a..a7c1683a92 100644 --- a/MyGUIEngine/include/MyGUI_ListBox.h +++ b/MyGUIEngine/include/MyGUI_ListBox.h @@ -32,6 +32,8 @@ namespace MyGUI MYGUI_RTTI_DERIVED( ListBox ) public: + friend class ComboBox; + ListBox(); //------------------------------------------------------------------------------// @@ -41,6 +43,7 @@ namespace MyGUI Methods used to manipulate items. */ //@{ + void setItemHeight(int itemHeight); //! Get number of items size_t getItemCount() const; @@ -308,6 +311,7 @@ namespace MyGUI bool mActivateOnClick; // Require a full mouse click rather than only mouse press to activate an item int mHeightLine; // высота одной строки + int mItemHeight; int mTopIndex; // индекс самого верхнего элемента int mOffsetTop; // текущее смещение int mRangeIndex; // размерность скрола diff --git a/MyGUIEngine/include/MyGUI_Widget.h b/MyGUIEngine/include/MyGUI_Widget.h index 9dd426e024..2c98d4fa67 100644 --- a/MyGUIEngine/include/MyGUI_Widget.h +++ b/MyGUIEngine/include/MyGUI_Widget.h @@ -308,6 +308,8 @@ namespace MyGUI // перерисовывает детей void _updateChilds(); + void setMouseHitThreshold(int xLeftThreshold, int xRightThreshold, int yLeftThreshold, int yRightThreshold); + protected: // все создание только через фабрику ~Widget() override = default; @@ -421,6 +423,10 @@ namespace MyGUI Align mAlign; int mDepth; + int mXLeftThreshold; + int mXRightThreshold; + int mYLeftThreshold; + int mYRightThreshold; }; } // namespace MyGUI diff --git a/MyGUIEngine/src/MyGUI_ComboBox.cpp b/MyGUIEngine/src/MyGUI_ComboBox.cpp index 14a6eb3261..c49ee7d2a5 100644 --- a/MyGUIEngine/src/MyGUI_ComboBox.cpp +++ b/MyGUIEngine/src/MyGUI_ComboBox.cpp @@ -27,6 +27,7 @@ namespace MyGUI mButton(nullptr), mList(nullptr), mListShow(false), + mAutoHideList(true), mMaxListLength(-1), mItemIndex(ITEM_NONE), mModeDrop(false), @@ -88,6 +89,7 @@ namespace MyGUI void ComboBox::shutdownOverride() { + mList->shutdownOverride(); mList = nullptr; mButton = nullptr; @@ -123,7 +125,8 @@ namespace MyGUI return; } - hideList(); + if (true == mAutoHideList) + hideList(); } void ComboBox::notifyListSelectAccept(ListBox* _widget, size_t _position) @@ -269,8 +272,6 @@ namespace MyGUI if (mList->getItemCount() == 0) return; - if (mListShow) - return; mListShow = true; IntCoord coord = calculateListPosition(); @@ -297,8 +298,6 @@ namespace MyGUI void ComboBox::hideList() { - if (!mListShow) - return; mListShow = false; if (mShowSmooth) @@ -313,6 +312,11 @@ namespace MyGUI } } + void ComboBox::setAutoHideList(bool autoHide) + { + mAutoHideList = autoHide; + } + void ComboBox::setIndexSelected(size_t _index) { MYGUI_ASSERT_RANGE_AND_NONE(_index, mList->getItemCount(), "ComboBox::setIndexSelected"); @@ -472,6 +476,19 @@ namespace MyGUI eventChangeProperty(this, _key, _value); } + void ComboBox::setItemHeight(int itemHeight) + { + if (nullptr != mList) + { + mList->setItemHeight(itemHeight); + } + } + + ListBox* ComboBox::getList(void) const + { + return mList; + } + size_t ComboBox::getItemCount() const { return mList->getItemCount(); diff --git a/MyGUIEngine/src/MyGUI_InputManager.cpp b/MyGUIEngine/src/MyGUI_InputManager.cpp index 89d5637d28..2fa11cdec2 100644 --- a/MyGUIEngine/src/MyGUI_InputManager.cpp +++ b/MyGUIEngine/src/MyGUI_InputManager.cpp @@ -16,7 +16,7 @@ namespace MyGUI { // In seconds - const float INPUT_TIME_DOUBLE_CLICK = 0.25f; + const float INPUT_TIME_DOUBLE_CLICK = 0.5f; const float INPUT_DELAY_FIRST_KEY = 0.4f; const float INPUT_INTERVAL_KEY = 0.05f; diff --git a/MyGUIEngine/src/MyGUI_ListBox.cpp b/MyGUIEngine/src/MyGUI_ListBox.cpp index c207de6561..0c79763887 100644 --- a/MyGUIEngine/src/MyGUI_ListBox.cpp +++ b/MyGUIEngine/src/MyGUI_ListBox.cpp @@ -41,9 +41,15 @@ namespace MyGUI if (isUserString("SkinLine")) mSkinLine = getUserString("SkinLine"); + if (-1 == mItemHeight) + { if (isUserString("HeightLine")) mHeightLine = utility::parseInt(getUserString("HeightLine")); - + } + else + { + mHeightLine = mItemHeight; + } if (mHeightLine < 1) mHeightLine = 1; @@ -61,6 +67,7 @@ namespace MyGUI { mWidgetScroll->eventScrollChangePosition += newDelegate(this, &ListBox::notifyScrollChangePosition); mWidgetScroll->setScrollPage((size_t)mHeightLine); + mWidgetScroll->setScrollViewPage((size_t)mHeightLine); } updateScroll(); @@ -69,6 +76,14 @@ namespace MyGUI void ListBox::shutdownOverride() { + for (size_t i = 0; i < mWidgetLines.size(); i++) + { + MyGUI::Button* button = mWidgetLines[i]; + getClientWidget()->_destroyChildWidget(button); + } + mWidgetLines.clear(); + mItemsInfo.clear(); + _resetContainer(true); mWidgetScroll = nullptr; Base::shutdownOverride(); @@ -903,7 +918,12 @@ namespace MyGUI int ListBox::getOptimalHeight() const { - return (int)((mCoord.height - _getClientWidget()->getHeight()) + (mItemsInfo.size() * mHeightLine)); + return (int)((mCoord.height - getClientWidget()->getHeight()) + (mItemsInfo.size() * mHeightLine)); + } + + void ListBox::setItemHeight(int itemHeight) + { + mItemHeight = itemHeight; } size_t ListBox::getItemCount() const diff --git a/MyGUIEngine/src/MyGUI_ScrollBar.cpp b/MyGUIEngine/src/MyGUI_ScrollBar.cpp index 9674228747..110214b024 100644 --- a/MyGUIEngine/src/MyGUI_ScrollBar.cpp +++ b/MyGUIEngine/src/MyGUI_ScrollBar.cpp @@ -327,6 +327,7 @@ namespace MyGUI { updateTrack(); MyGUI::ControllerManager::getInstance().removeItem(_sender); + this->_riseMouseButtonReleased(_left, _top, _id); } void ScrollBar::notifyMouseDrag(Widget* _sender, int _left, int _top, MouseButton _id) diff --git a/MyGUIEngine/src/MyGUI_Widget.cpp b/MyGUIEngine/src/MyGUI_Widget.cpp index d1ca5e969a..57c39190cc 100644 --- a/MyGUIEngine/src/MyGUI_Widget.cpp +++ b/MyGUIEngine/src/MyGUI_Widget.cpp @@ -41,7 +41,11 @@ namespace MyGUI mContainer(nullptr), mAlign(Align::Default), mVisible(true), - mDepth(0) + mDepth(0), + mXLeftThreshold(0), + mXRightThreshold(0), + mYLeftThreshold(0), + mYRightThreshold(0) { } @@ -469,7 +473,7 @@ namespace MyGUI || (!getNeedMouseFocus() && !getInheritsPick()) || !_checkPoint(_left, _top) // если есть маска, проверяем еще и по маске - || !isMaskPickInside(IntPoint(_left - mCoord.left, _top - mCoord.top), mCoord) + || !isMaskPickInside(IntPoint(_left - mCoord.left - mXLeftThreshold, _top - mCoord.top - mYLeftThreshold), mCoord) ) return nullptr; @@ -1034,7 +1038,7 @@ namespace MyGUI bool Widget::_checkPoint(int _left, int _top) const { - return ! ((_getViewLeft() > _left) || (_getViewTop() > _top) || (_getViewRight() < _left) || (_getViewBottom() < _top)); + return ! ((_getViewLeft() > _left - mXLeftThreshold) || (_getViewTop() > _top - mYLeftThreshold) || (_getViewRight() < _left + mXRightThreshold) || (_getViewBottom() < _top + mYRightThreshold)); } void Widget::_linkChildWidget(Widget* _widget) @@ -1387,6 +1391,14 @@ namespace MyGUI mWidgetChild.push_back(_widget); } + void Widget::setMouseHitThreshold(int xLeftThreshold, int xRightThreshold, int yLeftThreshold, int yRightThreshold) + { + this->mXLeftThreshold = xLeftThreshold; + this->mXRightThreshold = xRightThreshold; + this->mYLeftThreshold = yLeftThreshold; + this->mYRightThreshold = yRightThreshold; + } + void Widget::_updateChilds() { for (VectorWidgetPtr::iterator widget = mWidgetChild.begin(); widget != mWidgetChild.end(); ++widget)