| 928 | } |
| 929 | |
| 930 | void TabControl::updateBarNew() |
| 931 | { |
| 932 | if (mHeaderPlace == nullptr) |
| 933 | return; |
| 934 | |
| 935 | // подстраховка |
| 936 | if (mHeaderPlace->getWidth() < 1) |
| 937 | return; |
| 938 | |
| 939 | int widthControls = 0; |
| 940 | if (mControls != nullptr) |
| 941 | widthControls = mControls->getWidth(); |
| 942 | |
| 943 | if ((mHeaderPlace->getWidth() < mWidthBar) && (1 < mItemsInfo.size()) && |
| 944 | (mHeaderPlace->getWidth() >= widthControls)) |
| 945 | { |
| 946 | if (!mButtonShow) |
| 947 | { |
| 948 | mButtonShow = true; |
| 949 | |
| 950 | if (nullptr != mControls) |
| 951 | mControls->setVisible(true); |
| 952 | } |
| 953 | |
| 954 | if (mControls != nullptr) |
| 955 | mControls->setCoord( |
| 956 | mHeaderPlace->getWidth() - mControls->getWidth(), |
| 957 | 0, |
| 958 | mControls->getWidth(), |
| 959 | mHeaderPlace->getHeight()); |
| 960 | } |
| 961 | else |
| 962 | { |
| 963 | if (mButtonShow) |
| 964 | { |
| 965 | mButtonShow = false; |
| 966 | |
| 967 | if (nullptr != mControls) |
| 968 | mControls->setVisible(false); |
| 969 | } |
| 970 | |
| 971 | widthControls = 0; |
| 972 | } |
| 973 | |
| 974 | // проверяем правильность стартового индекса |
| 975 | if (mStartIndex > 0) |
| 976 | { |
| 977 | // считаем длинну видимых кнопок |
| 978 | int width = 0; |
| 979 | for (size_t pos = mStartIndex; pos < mItemsInfo.size(); pos++) |
| 980 | width += mItemsInfo[pos].width; |
| 981 | |
| 982 | // уменьшаем индекс до тех пор пока кнопка до индекста полностью не влезет в бар |
| 983 | while ((mStartIndex > 0) && |
| 984 | ((width + mItemsInfo[mStartIndex - 1].width) <= (mHeaderPlace->getWidth() - widthControls))) |
| 985 | { |
| 986 | mStartIndex--; |
| 987 | width += mItemsInfo[mStartIndex].width; |
nothing calls this directly
no test coverage detected