Files
LNXSDK/leenkx/blender/lnx/logicnode/krom/LN_webview_set_dimensions.py
2026-07-13 15:44:52 -07:00

48 lines
1.9 KiB
Python

from lnx.logicnode.lnx_nodes import *
class WebviewSetDimensionsNode(LnxLogicTreeNode):
"""Sets dimensions of the given WebView for resize, move, or setting bounds"""
bl_idname = 'LNWebviewSetDimensionsNode'
bl_label = 'Webview Set Dimensions'
lnx_category = 'Krom Runtime'
lnx_section = 'webview'
lnx_version = 1
def update_sockets(self, context):
remove_list = []
for i in range(2, len(self.inputs)):
remove_list.append(self.inputs[i])
for i in remove_list:
self.inputs.remove(i)
if self.property0 == 'resize':
self.add_input('LnxIntSocket', 'Width', default_value=800)
self.add_input('LnxIntSocket', 'Height', default_value=600)
elif self.property0 == 'move':
self.add_input('LnxIntSocket', 'X', default_value=0)
self.add_input('LnxIntSocket', 'Y', default_value=0)
else:
self.add_input('LnxIntSocket', 'X', default_value=0)
self.add_input('LnxIntSocket', 'Y', default_value=0)
self.add_input('LnxIntSocket', 'Width', default_value=800)
self.add_input('LnxIntSocket', 'Height', default_value=600)
property0: HaxeEnumProperty(
'property0',
items=[('resize', 'Resize', 'Set width and height'),
('move', 'Move', 'Set X and Y position'),
('set_bounds', 'Set Bounds', 'Set X, Y, width and height')],
name='Mode', default='resize', update=update_sockets)
def lnx_init(self, context):
self.add_input('LnxNodeSocketAction', 'In')
self.add_input('LnxIntSocket', 'ID')
self.add_input('LnxIntSocket', 'Width', default_value=800)
self.add_input('LnxIntSocket', 'Height', default_value=600)
self.add_output('LnxNodeSocketAction', 'Out')
def draw_buttons(self, context, layout):
layout.prop(self, 'property0')