mirror of
https://github.com/whoahq/whoa.git
synced 2026-03-05 15:42:17 +03:00
feat(ui): implement CSimpleFrame_SetAttribute
This commit is contained in:
parent
c201da76cd
commit
66fd4a6564
@ -95,6 +95,10 @@ void CSimpleFrame::AddFrameRegion(CSimpleRegion* region, uint32_t drawlayer) {
|
|||||||
this->NotifyDrawLayerChanged(drawlayer);
|
this->NotifyDrawLayerChanged(drawlayer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t CSimpleFrame::AttributeChangesAllowed() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void CSimpleFrame::DisableDrawLayer(uint32_t drawlayer) {
|
void CSimpleFrame::DisableDrawLayer(uint32_t drawlayer) {
|
||||||
this->m_drawenabled[drawlayer] = 0;
|
this->m_drawenabled[drawlayer] = 0;
|
||||||
this->NotifyDrawLayerChanged(drawlayer);
|
this->NotifyDrawLayerChanged(drawlayer);
|
||||||
|
|||||||
@ -128,6 +128,7 @@ class CSimpleFrame : public CScriptRegion {
|
|||||||
// Member functions
|
// Member functions
|
||||||
CSimpleFrame(CSimpleFrame* parent);
|
CSimpleFrame(CSimpleFrame* parent);
|
||||||
void AddFrameRegion(CSimpleRegion* region, uint32_t drawlayer);
|
void AddFrameRegion(CSimpleRegion* region, uint32_t drawlayer);
|
||||||
|
int32_t AttributeChangesAllowed();
|
||||||
void DisableDrawLayer(uint32_t drawlayer);
|
void DisableDrawLayer(uint32_t drawlayer);
|
||||||
void DisableEvent(CSimpleEventType eventType);
|
void DisableEvent(CSimpleEventType eventType);
|
||||||
void EnableDrawLayer(uint32_t drawlayer);
|
void EnableDrawLayer(uint32_t drawlayer);
|
||||||
|
|||||||
@ -209,7 +209,38 @@ int32_t CSimpleFrame_GetAttribute(lua_State* L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int32_t CSimpleFrame_SetAttribute(lua_State* L) {
|
int32_t CSimpleFrame_SetAttribute(lua_State* L) {
|
||||||
WHOA_UNIMPLEMENTED(0);
|
auto type = CSimpleFrame::GetObjectType();
|
||||||
|
auto frame = static_cast<CSimpleFrame*>(FrameScript_GetObjectThis(L, type));
|
||||||
|
|
||||||
|
if (!frame->ProtectedFunctionsAllowed() && !frame->AttributeChangesAllowed()) {
|
||||||
|
// TODO disallowed logic
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
lua_settop(L, 3);
|
||||||
|
|
||||||
|
if (!lua_isstring(L, 2) || lua_type(L, 3) == LUA_TNONE) {
|
||||||
|
luaL_error(L, "Usage: %s:SetAttribute(\"name\", value)", frame->GetDisplayName());
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto attrName = lua_tostring(L, 2);
|
||||||
|
int32_t luaRef;
|
||||||
|
|
||||||
|
if (frame->GetAttribute(attrName, luaRef)) {
|
||||||
|
luaL_unref(L, LUA_REGISTRYINDEX, luaRef);
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO taint management
|
||||||
|
|
||||||
|
luaRef = luaL_ref(L, LUA_REGISTRYINDEX);
|
||||||
|
|
||||||
|
// TODO taint management
|
||||||
|
|
||||||
|
frame->SetAttribute(attrName, luaRef);
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t CSimpleFrame_GetEffectiveScale(lua_State* L) {
|
int32_t CSimpleFrame_GetEffectiveScale(lua_State* L) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user