add 'min-length' panel property
This commit is contained in:
parent
8e8fed2aa2
commit
0ce5e23a2a
@ -65,6 +65,7 @@ Buttons and panels are also containers.
|
|||||||
Buttons are also panels.
|
Buttons are also panels.
|
||||||
|
|
||||||
- `max-length` - maximal length of panel stretching before scrolling (if scrollable = true). Type: number
|
- `max-length` - maximal length of panel stretching before scrolling (if scrollable = true). Type: number
|
||||||
|
- `min-length` - minimal length of panel. Type: number
|
||||||
- `orientation` - panel orientation: horizontal/vertical.
|
- `orientation` - panel orientation: horizontal/vertical.
|
||||||
|
|
||||||
# Common elements
|
# Common elements
|
||||||
|
|||||||
@ -67,6 +67,7 @@
|
|||||||
|
|
||||||
В число панелей также входят кнопки.
|
В число панелей также входят кнопки.
|
||||||
- `max-length` - максимальная длина, на которую растягивается панель до начала скроллинга (если scrollable = true). Тип: число
|
- `max-length` - максимальная длина, на которую растягивается панель до начала скроллинга (если scrollable = true). Тип: число
|
||||||
|
- `min-length` - минимальная длина панели. Тип: число
|
||||||
- `orientation` - ориентация панели: horizontal/vertical.
|
- `orientation` - ориентация панели: horizontal/vertical.
|
||||||
|
|
||||||
# Основные элементы
|
# Основные элементы
|
||||||
|
|||||||
@ -23,6 +23,14 @@ int Panel::getMaxLength() const {
|
|||||||
return maxLength;
|
return maxLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Panel::setMinLength(int value) {
|
||||||
|
minLength = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
int Panel::getMinLength() const {
|
||||||
|
return minLength;
|
||||||
|
}
|
||||||
|
|
||||||
void Panel::setPadding(glm::vec4 padding) {
|
void Panel::setPadding(glm::vec4 padding) {
|
||||||
this->padding = padding;
|
this->padding = padding;
|
||||||
refresh();
|
refresh();
|
||||||
@ -34,9 +42,11 @@ glm::vec4 Panel::getPadding() const {
|
|||||||
|
|
||||||
void Panel::cropToContent() {
|
void Panel::cropToContent() {
|
||||||
if (maxLength > 0.0f) {
|
if (maxLength > 0.0f) {
|
||||||
setSize(glm::vec2(getSize().x, glm::min(maxLength, actualLength)));
|
setSize(glm::vec2(
|
||||||
|
getSize().x, glm::max(minLength, glm::min(maxLength, actualLength))
|
||||||
|
));
|
||||||
} else {
|
} else {
|
||||||
setSize(glm::vec2(getSize().x, actualLength));
|
setSize(glm::vec2(getSize().x, glm::max(minLength, actualLength)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -9,6 +9,7 @@ namespace gui {
|
|||||||
Orientation orientation = Orientation::vertical;
|
Orientation orientation = Orientation::vertical;
|
||||||
glm::vec4 padding {2.0f};
|
glm::vec4 padding {2.0f};
|
||||||
float interval = 2.0f;
|
float interval = 2.0f;
|
||||||
|
int minLength = 0;
|
||||||
int maxLength = 0;
|
int maxLength = 0;
|
||||||
public:
|
public:
|
||||||
Panel(
|
Panel(
|
||||||
@ -31,6 +32,9 @@ namespace gui {
|
|||||||
virtual void setMaxLength(int value);
|
virtual void setMaxLength(int value);
|
||||||
int getMaxLength() const;
|
int getMaxLength() const;
|
||||||
|
|
||||||
|
virtual void setMinLength(int value);
|
||||||
|
int getMinLength() const;
|
||||||
|
|
||||||
virtual void setPadding(glm::vec4 padding);
|
virtual void setPadding(glm::vec4 padding);
|
||||||
glm::vec4 getPadding() const;
|
glm::vec4 getPadding() const;
|
||||||
};
|
};
|
||||||
|
|||||||
@ -289,12 +289,12 @@ const std::string& UINode::getId() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void UINode::reposition() {
|
void UINode::reposition() {
|
||||||
if (positionfunc) {
|
|
||||||
setPos(positionfunc());
|
|
||||||
}
|
|
||||||
if (sizefunc) {
|
if (sizefunc) {
|
||||||
setSize(sizefunc());
|
setSize(sizefunc());
|
||||||
}
|
}
|
||||||
|
if (positionfunc) {
|
||||||
|
setPos(positionfunc());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void UINode::setGravity(Gravity gravity) {
|
void UINode::setGravity(Gravity gravity) {
|
||||||
|
|||||||
@ -220,6 +220,9 @@ static void _readPanel(UiXmlReader& reader, const xml::xmlelement& element, Pane
|
|||||||
if (element.has("max-length")) {
|
if (element.has("max-length")) {
|
||||||
panel.setMaxLength(element.attr("max-length").asInt());
|
panel.setMaxLength(element.attr("max-length").asInt());
|
||||||
}
|
}
|
||||||
|
if (element.has("min-length")) {
|
||||||
|
panel.setMinLength(element.attr("min-length").asInt());
|
||||||
|
}
|
||||||
if (element.has("orientation")) {
|
if (element.has("orientation")) {
|
||||||
auto &oname = element.attr("orientation").getText();
|
auto &oname = element.attr("orientation").getText();
|
||||||
if (oname == "horizontal") {
|
if (oname == "horizontal") {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user