* Set the number of elements in this matrix. * @note Updates the number of elements/capacity of the real scrollbar. * @param count The number of elements. */
| 1972 | * @param count The number of elements. |
| 1973 | */ |
| 1974 | void NWidgetMatrix::SetCount(int count) |
| 1975 | { |
| 1976 | this->count = count; |
| 1977 | |
| 1978 | if (this->sb == nullptr || this->widgets_x == 0) return; |
| 1979 | |
| 1980 | /* We need to get the number of pixels the matrix is high/wide. |
| 1981 | * So, determine the number of rows/columns based on the number of |
| 1982 | * columns/rows (one is constant/unscrollable). |
| 1983 | * Then multiply that by the height of a widget, and add the pre |
| 1984 | * and post spacing "offsets". */ |
| 1985 | count = CeilDiv(count, this->sb->IsVertical() ? this->widgets_x : this->widgets_y); |
| 1986 | count *= (this->sb->IsVertical() ? this->children.front()->smallest_y : this->children.front()->smallest_x) + this->pip_inter; |
| 1987 | if (count > 0) count -= this->pip_inter; // We counted an inter too much in the multiplication above |
| 1988 | count += this->pip_pre + this->pip_post; |
| 1989 | this->sb->SetCount(count); |
| 1990 | this->sb->SetCapacity(this->sb->IsVertical() ? this->current_y : this->current_x); |
| 1991 | this->sb->SetStepSize(this->sb->IsVertical() ? this->widget_h : this->widget_w); |
| 1992 | } |
| 1993 | |
| 1994 | /** |
| 1995 | * Assign a scrollbar to this matrix. |
no test coverage detected