mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-11 14:01:49 +00:00
Merge pull request #733 from MihailRis/zindex-attr
z-index property access
This commit is contained in:
commit
515d0e3812
5 changed files with 63 additions and 43 deletions
|
|
@ -34,25 +34,26 @@ Access to nested elements is performed by index (starting from one).
|
||||||
|
|
||||||
Properties that apply to all elements:
|
Properties that apply to all elements:
|
||||||
|
|
||||||
| Name | Type | Read | Write | Description |
|
| Name | Type | Read | Write | Description |
|
||||||
| ------------- | ------- | ---- | ----- | ------------------------------------------- |
|
| ------------- | ------- | ---- | ----- | ------------------------------------------------ |
|
||||||
| id | string | yes | *no* | element id |
|
| id | string | yes | *no* | element id |
|
||||||
| exists | bool | yes | *no* | checks if element exists |
|
| exists | bool | yes | *no* | checks if element exists |
|
||||||
| pos | vec2 | yes | yes | element position inside a container |
|
| pos | vec2 | yes | yes | element position inside a container |
|
||||||
| wpos | vec2 | yes | yes | element position inside the window |
|
| wpos | vec2 | yes | yes | element position inside the window |
|
||||||
| size | vec2 | yes | yes | element size |
|
| size | vec2 | yes | yes | element size |
|
||||||
| interactive | bool | yes | yes | ability to interact with the element |
|
| interactive | bool | yes | yes | ability to interact with the element |
|
||||||
| enabled | bool | yes | yes | visually indicated version of *interactive* |
|
| enabled | bool | yes | yes | visually indicated version of *interactive* |
|
||||||
| visible | bool | yes | yes | element visibility |
|
| visible | bool | yes | yes | element visibility |
|
||||||
| focused | bool | yes | yes | focus on element |
|
| focused | bool | yes | yes | focus on element |
|
||||||
| color | rgba | yes | yes | element color |
|
| color | rgba | yes | yes | element color |
|
||||||
| hoverColor | rgba | yes | yes | hover color |
|
| hoverColor | rgba | yes | yes | hover color |
|
||||||
| pressedColor | rgba | yes | yes | color when pressed |
|
| pressedColor | rgba | yes | yes | color when pressed |
|
||||||
| tooltip | string | yes | yes | tooltip text |
|
| tooltip | string | yes | yes | tooltip text |
|
||||||
| tooltipDelay | float | yes | yes | tooltip delay |
|
| tooltipDelay | float | yes | yes | tooltip delay |
|
||||||
| contentOffset | vec2 | yes | *no* | element content offset |
|
| contentOffset | vec2 | yes | *no* | element content offset |
|
||||||
| cursor | string | yes | yes | cursor displayed on hover |
|
| cursor | string | yes | yes | cursor displayed on hover |
|
||||||
| parent | Element | yes | *no* | parent element or nil |
|
| parent | Element | yes | *no* | parent element or nil |
|
||||||
|
| zIndex | bool | yes | *no* | z-index value. In panel, it determines the order |
|
||||||
|
|
||||||
Common element methods:
|
Common element methods:
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -34,25 +34,26 @@ document["worlds-panel"]:clear()
|
||||||
|
|
||||||
Свойства, относящиеся ко всем элементам:
|
Свойства, относящиеся ко всем элементам:
|
||||||
|
|
||||||
| Название | Тип | Чтение | Запись | Описание |
|
| Название | Тип | Чтение | Запись | Описание |
|
||||||
| ------------- | ------- | ------ | ------ | ----------------------------------------- |
|
| ------------- | ------- | ------ | ------ | ---------------------------------------------- |
|
||||||
| id | string | да | *нет* | идентификатор элемента |
|
| id | string | да | *нет* | идентификатор элемента |
|
||||||
| exists | bool | да | *нет* | проверяет, существует ли элемент |
|
| exists | bool | да | *нет* | проверяет, существует ли элемент |
|
||||||
| pos | vec2 | да | да | позиция элемента внутри контейнера |
|
| pos | vec2 | да | да | позиция элемента внутри контейнера |
|
||||||
| wpos | vec2 | да | да | позиция элемента в окне |
|
| wpos | vec2 | да | да | позиция элемента в окне |
|
||||||
| size | vec2 | да | да | размер элемента |
|
| size | vec2 | да | да | размер элемента |
|
||||||
| interactive | bool | да | да | возможность взаимодействия с элементом |
|
| interactive | bool | да | да | возможность взаимодействия с элементом |
|
||||||
| enabled | bool | да | да | визуально обозначаемая версия interactive |
|
| enabled | bool | да | да | визуально обозначаемая версия interactive |
|
||||||
| visible | bool | да | да | видимость элемента |
|
| visible | bool | да | да | видимость элемента |
|
||||||
| focused | bool | да | да | фокус на элементе |
|
| focused | bool | да | да | фокус на элементе |
|
||||||
| color | rgba | да | да | цвет элемента |
|
| color | rgba | да | да | цвет элемента |
|
||||||
| hoverColor | rgba | да | да | цвет при наведении |
|
| hoverColor | rgba | да | да | цвет при наведении |
|
||||||
| pressedColor | rgba | да | да | цвет при нажатии |
|
| pressedColor | rgba | да | да | цвет при нажатии |
|
||||||
| tooltip | string | да | да | текст всплывающей подсказки |
|
| tooltip | string | да | да | текст всплывающей подсказки |
|
||||||
| tooltipDelay | float | да | да | задержка всплывающей подсказки |
|
| tooltipDelay | float | да | да | задержка всплывающей подсказки |
|
||||||
| contentOffset | vec2 | да | *нет* | смещение содержимого |
|
| contentOffset | vec2 | да | *нет* | смещение содержимого |
|
||||||
| cursor | string | да | да | курсор, отображаемый при наведении |
|
| cursor | string | да | да | курсор, отображаемый при наведении |
|
||||||
| parent | Element | да | *нет* | родительский элемент или nil |
|
| parent | Element | да | *нет* | родительский элемент или nil |
|
||||||
|
| zIndex | bool | да | *нет* | значение z-индекса. В panel определяет порядок |
|
||||||
|
|
||||||
Общие методы элементов:
|
Общие методы элементов:
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -135,9 +135,10 @@ void GUI::actMouse(float delta, const CursorState& cursor) {
|
||||||
if (this->hover && this->hover != hover) {
|
if (this->hover && this->hover != hover) {
|
||||||
this->hover->setMouseEnter(false);
|
this->hover->setMouseEnter(false);
|
||||||
}
|
}
|
||||||
if (hover && hover != this->hover) {
|
if (hover) {
|
||||||
hover->setMouseEnter(true);
|
if (hover != this->hover) {
|
||||||
|
hover->setMouseEnter(true);
|
||||||
|
}
|
||||||
int scroll = input.getScroll();
|
int scroll = input.getScroll();
|
||||||
if (scroll) {
|
if (scroll) {
|
||||||
hover->scrolled(scroll);
|
hover->scrolled(scroll);
|
||||||
|
|
@ -269,7 +270,6 @@ void GUI::draw(const DrawContext& pctx, const Assets& assets) {
|
||||||
auto& page = menu->getCurrent();
|
auto& page = menu->getCurrent();
|
||||||
if (page.panel) {
|
if (page.panel) {
|
||||||
menu->setSize(page.panel->getSize());
|
menu->setSize(page.panel->getSize());
|
||||||
page.panel->refresh();
|
|
||||||
if (auto panel = std::dynamic_pointer_cast<gui::Panel>(page.panel)) {
|
if (auto panel = std::dynamic_pointer_cast<gui::Panel>(page.panel)) {
|
||||||
panel->cropToContent();
|
panel->cropToContent();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,7 @@ void Panel::remove(UINode* node) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Panel::refresh() {
|
void Panel::refresh() {
|
||||||
UINode::refresh();
|
Container::refresh();
|
||||||
|
|
||||||
float x = padding.x;
|
float x = padding.x;
|
||||||
float y = padding.y;
|
float y = padding.y;
|
||||||
|
|
|
||||||
|
|
@ -577,6 +577,13 @@ static int p_get_options(UINode* node, lua::State* L) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int p_get_zindex(UINode* node, lua::State* L) {
|
||||||
|
if (node == nullptr) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return lua::pushinteger(L, node->getZIndex());
|
||||||
|
}
|
||||||
|
|
||||||
static int p_is_exists(UINode* node, lua::State* L) {
|
static int p_is_exists(UINode* node, lua::State* L) {
|
||||||
return lua::pushboolean(L, node != nullptr);
|
return lua::pushboolean(L, node != nullptr);
|
||||||
}
|
}
|
||||||
|
|
@ -677,6 +684,7 @@ static int l_gui_getattr(lua::State* L) {
|
||||||
{"parent", p_get_parent},
|
{"parent", p_get_parent},
|
||||||
{"region", p_get_region},
|
{"region", p_get_region},
|
||||||
{"options", p_get_options},
|
{"options", p_get_options},
|
||||||
|
{"zIndex", p_get_zindex},
|
||||||
};
|
};
|
||||||
auto func = getters.find(attr);
|
auto func = getters.find(attr);
|
||||||
if (func != getters.end()) {
|
if (func != getters.end()) {
|
||||||
|
|
@ -813,6 +821,15 @@ static void p_set_options(UINode* node, lua::State* L, int idx) {
|
||||||
selectbox->setOptions(std::move(options));
|
selectbox->setOptions(std::move(options));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
static void p_set_zindex(UINode* node, lua::State* L, int idx) {
|
||||||
|
if (node == nullptr) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
node->setZIndex(lua::tointeger(L, idx));
|
||||||
|
if (auto parent = node->getParent()) {
|
||||||
|
parent->setMustRefresh();
|
||||||
|
}
|
||||||
|
}
|
||||||
static void p_set_value(UINode* node, lua::State* L, int idx) {
|
static void p_set_value(UINode* node, lua::State* L, int idx) {
|
||||||
if (auto bar = dynamic_cast<TrackBar*>(node)) {
|
if (auto bar = dynamic_cast<TrackBar*>(node)) {
|
||||||
bar->setValue(lua::tonumber(L, idx));
|
bar->setValue(lua::tonumber(L, idx));
|
||||||
|
|
@ -961,6 +978,7 @@ static int l_gui_setattr(lua::State* L) {
|
||||||
{"focused", p_set_focused},
|
{"focused", p_set_focused},
|
||||||
{"region", p_set_region},
|
{"region", p_set_region},
|
||||||
{"options", p_set_options},
|
{"options", p_set_options},
|
||||||
|
{"zIndex", p_set_zindex},
|
||||||
};
|
};
|
||||||
auto func = setters.find(attr);
|
auto func = setters.find(attr);
|
||||||
if (func != setters.end()) {
|
if (func != setters.end()) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue