Skip to content

Commit

Permalink
Scenes
Browse files Browse the repository at this point in the history
* New widget type: scaled device
  • Loading branch information
sergejey committed Mar 14, 2023
1 parent ced2d7b commit 616d48f
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 5 deletions.
44 changes: 44 additions & 0 deletions modules/scenes/widget_types.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
array('VALUE' => '44'),
array('VALUE' => '52'),
array('VALUE' => '65'),
array('VALUE' => '72'),
array('VALUE' => '86'),
array('VALUE' => '95'),
array('VALUE' => '112'),
)
),
'text_align' => array('DESCRIPTION' => LANG_WIDGET_TEXT_ALIGNMENT,
Expand Down Expand Up @@ -79,6 +83,46 @@
'DEFAULT_WIDTH' => 200,
'DEFAULT_HEIGHT' => 200,
'TEMPLATE' => 'file:image_block.html'
),
'device_scaled' => array(
'TITLE' => LANG_DEVICE.' (scaled)',
'DESCRIPTION' => LANG_DEVICE,
'PROPERTIES' => array(
'device_id'=>array(
'DESCRIPTION'=>LANG_DEVICE,
'_CONFIG_TYPE'=>'select',
'_CONFIG_OPTIONS'=>function () {
$options = SQLSelect("SELECT ID as VALUE, TITLE FROM devices ORDER BY TITLE");
return $options;
}),
'widget_background' => array('DESCRIPTION' => LANG_WIDGET_TEXT_BLOCK_BACKGROUND_COLOR,
'DEFAULT_VALUE' => '#000000', '_CONFIG_TYPE' => 'color'),
'background_opacity' => array('DESCRIPTION' => LANG_WIDGET_TEXT_BLOCK_BACKGROUND_OPACITY,
'DEFAULT_VALUE' => '0.5',
'_CONFIG_TYPE' => 'select',
'_CONFIG_OPTIONS' => array(
array('VALUE' => '0', 'TITLE' => '0'),
array('VALUE' => '0.1', 'TITLE' => '10'),
array('VALUE' => '0.2', 'TITLE' => '20'),
array('VALUE' => '0.3', 'TITLE' => '30'),
array('VALUE' => '0.4', 'TITLE' => '40'),
array('VALUE' => '0.5', 'TITLE' => '50'),
array('VALUE' => '0.6', 'TITLE' => '60'),
array('VALUE' => '0.7', 'TITLE' => '70'),
array('VALUE' => '0.8', 'TITLE' => '80'),
array('VALUE' => '0.9', 'TITLE' => '90'),
array('VALUE' => '1', 'TITLE' => '100')
)
),
'widget_background_rgba' => array('FUNCTION' => function ($data) {
list($r, $g, $b) = sscanf($data['widget_background'], "#%02x%02x%02x");
return "$r, $g, $b, " . $data['background_opacity'];
})
),
'RESIZABLE' => true,
'DEFAULT_WIDTH' => 260,
'DEFAULT_HEIGHT' => 60,
'TEMPLATE' => 'file:device_block.html'
)
);

Expand Down
5 changes: 4 additions & 1 deletion modules/scenes/widgets.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,15 @@
if (is_array($property_data['_CONFIG_OPTIONS'])) {
foreach($property_data['_CONFIG_OPTIONS'] as $opt) {
if (!isset($opt['TITLE'])) $opt['TITLE']=$opt['VALUE'];
if ($opt['VALUE']==$new_prop['VALUE']) $opt['SELECTED']=1;
$options[]=$opt;
}
} elseif (is_callable($property_data['_CONFIG_OPTIONS'])) {
$options = $property_data['_CONFIG_OPTIONS']();
}
$total = count($options);
for($i=0;$i<$total;$i++) {
if ($options[$i]['VALUE']==$new_prop['VALUE']) $options[$i]['SELECTED']=1;
}
$new_prop['OPTIONS']=$options;
}
$properties[]=$new_prop;
Expand Down
7 changes: 3 additions & 4 deletions templates/scenes/scenes_edit_widgets.html
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,13 @@
</div>
<hr>
<h4><#LANG_ADD_WIDGET#></h4>
<div>
<div class="row">
[#begin WIDGET_TYPES#]
<div class="col-md-4">
<div class="col-md-3" style="padding-bottom:10px">
<div><b>[#TITLE#]</b>
<br/>
[#DESCRIPTION#]</div>
&nbsp;
<div>
<div style="padding-top:5px">
<a href="?id=<#ID#>&view_mode=<#VIEW_MODE#>&tab=<#TAB#>&mode=add_widget&type=[#TYPE#]&top=<#TOP#>&left=<#LEFT#>" class="btn btn-default"><#LANG_ADD#></a>
</div>
</div>
Expand Down

0 comments on commit 616d48f

Please sign in to comment.