Skip to content

Commit 616d48f

Browse files
committed
Scenes
* New widget type: scaled device
1 parent ced2d7b commit 616d48f

File tree

3 files changed

+51
-5
lines changed

3 files changed

+51
-5
lines changed

modules/scenes/widget_types.inc.php

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@
2424
array('VALUE' => '44'),
2525
array('VALUE' => '52'),
2626
array('VALUE' => '65'),
27+
array('VALUE' => '72'),
28+
array('VALUE' => '86'),
29+
array('VALUE' => '95'),
30+
array('VALUE' => '112'),
2731
)
2832
),
2933
'text_align' => array('DESCRIPTION' => LANG_WIDGET_TEXT_ALIGNMENT,
@@ -79,6 +83,46 @@
7983
'DEFAULT_WIDTH' => 200,
8084
'DEFAULT_HEIGHT' => 200,
8185
'TEMPLATE' => 'file:image_block.html'
86+
),
87+
'device_scaled' => array(
88+
'TITLE' => LANG_DEVICE.' (scaled)',
89+
'DESCRIPTION' => LANG_DEVICE,
90+
'PROPERTIES' => array(
91+
'device_id'=>array(
92+
'DESCRIPTION'=>LANG_DEVICE,
93+
'_CONFIG_TYPE'=>'select',
94+
'_CONFIG_OPTIONS'=>function () {
95+
$options = SQLSelect("SELECT ID as VALUE, TITLE FROM devices ORDER BY TITLE");
96+
return $options;
97+
}),
98+
'widget_background' => array('DESCRIPTION' => LANG_WIDGET_TEXT_BLOCK_BACKGROUND_COLOR,
99+
'DEFAULT_VALUE' => '#000000', '_CONFIG_TYPE' => 'color'),
100+
'background_opacity' => array('DESCRIPTION' => LANG_WIDGET_TEXT_BLOCK_BACKGROUND_OPACITY,
101+
'DEFAULT_VALUE' => '0.5',
102+
'_CONFIG_TYPE' => 'select',
103+
'_CONFIG_OPTIONS' => array(
104+
array('VALUE' => '0', 'TITLE' => '0'),
105+
array('VALUE' => '0.1', 'TITLE' => '10'),
106+
array('VALUE' => '0.2', 'TITLE' => '20'),
107+
array('VALUE' => '0.3', 'TITLE' => '30'),
108+
array('VALUE' => '0.4', 'TITLE' => '40'),
109+
array('VALUE' => '0.5', 'TITLE' => '50'),
110+
array('VALUE' => '0.6', 'TITLE' => '60'),
111+
array('VALUE' => '0.7', 'TITLE' => '70'),
112+
array('VALUE' => '0.8', 'TITLE' => '80'),
113+
array('VALUE' => '0.9', 'TITLE' => '90'),
114+
array('VALUE' => '1', 'TITLE' => '100')
115+
)
116+
),
117+
'widget_background_rgba' => array('FUNCTION' => function ($data) {
118+
list($r, $g, $b) = sscanf($data['widget_background'], "#%02x%02x%02x");
119+
return "$r, $g, $b, " . $data['background_opacity'];
120+
})
121+
),
122+
'RESIZABLE' => true,
123+
'DEFAULT_WIDTH' => 260,
124+
'DEFAULT_HEIGHT' => 60,
125+
'TEMPLATE' => 'file:device_block.html'
82126
)
83127
);
84128

modules/scenes/widgets.inc.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,15 @@
4141
if (is_array($property_data['_CONFIG_OPTIONS'])) {
4242
foreach($property_data['_CONFIG_OPTIONS'] as $opt) {
4343
if (!isset($opt['TITLE'])) $opt['TITLE']=$opt['VALUE'];
44-
if ($opt['VALUE']==$new_prop['VALUE']) $opt['SELECTED']=1;
4544
$options[]=$opt;
4645
}
4746
} elseif (is_callable($property_data['_CONFIG_OPTIONS'])) {
4847
$options = $property_data['_CONFIG_OPTIONS']();
4948
}
49+
$total = count($options);
50+
for($i=0;$i<$total;$i++) {
51+
if ($options[$i]['VALUE']==$new_prop['VALUE']) $options[$i]['SELECTED']=1;
52+
}
5053
$new_prop['OPTIONS']=$options;
5154
}
5255
$properties[]=$new_prop;

templates/scenes/scenes_edit_widgets.html

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,14 +87,13 @@
8787
</div>
8888
<hr>
8989
<h4><#LANG_ADD_WIDGET#></h4>
90-
<div>
90+
<div class="row">
9191
[#begin WIDGET_TYPES#]
92-
<div class="col-md-4">
92+
<div class="col-md-3" style="padding-bottom:10px">
9393
<div><b>[#TITLE#]</b>
9494
<br/>
9595
[#DESCRIPTION#]</div>
96-
&nbsp;
97-
<div>
96+
<div style="padding-top:5px">
9897
<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>
9998
</div>
10099
</div>

0 commit comments

Comments
 (0)