Merge branch 'develop'

This commit is contained in:
Insality 2020-03-22 02:24:25 +03:00
commit f769f80b10
29 changed files with 102 additions and 37 deletions

View File

@ -185,7 +185,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-03-21 23:23:01 </i> <i style="float:right;">Last updated 2020-03-22 02:23:51 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View File

@ -406,7 +406,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-03-21 23:23:01 </i> <i style="float:right;">Last updated 2020-03-22 02:23:51 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View File

@ -215,7 +215,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-03-21 23:23:01 </i> <i style="float:right;">Last updated 2020-03-22 02:23:51 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View File

@ -234,7 +234,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-03-21 23:23:01 </i> <i style="float:right;">Last updated 2020-03-22 02:23:51 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View File

@ -405,7 +405,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-03-21 23:23:01 </i> <i style="float:right;">Last updated 2020-03-22 02:23:51 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View File

@ -277,7 +277,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-03-21 23:23:01 </i> <i style="float:right;">Last updated 2020-03-22 02:23:51 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View File

@ -239,7 +239,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-03-21 23:23:01 </i> <i style="float:right;">Last updated 2020-03-22 02:23:51 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View File

@ -370,7 +370,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-03-21 23:23:01 </i> <i style="float:right;">Last updated 2020-03-22 02:23:51 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View File

@ -236,7 +236,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-03-21 23:23:01 </i> <i style="float:right;">Last updated 2020-03-22 02:23:51 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View File

@ -211,7 +211,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-03-21 23:23:01 </i> <i style="float:right;">Last updated 2020-03-22 02:23:51 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View File

@ -181,7 +181,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-03-21 23:23:01 </i> <i style="float:right;">Last updated 2020-03-22 02:23:51 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View File

@ -86,7 +86,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-03-21 23:23:01 </i> <i style="float:right;">Last updated 2020-03-22 02:23:51 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View File

@ -240,7 +240,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-03-21 23:23:01 </i> <i style="float:right;">Last updated 2020-03-22 02:23:51 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View File

@ -378,7 +378,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-03-21 23:23:01 </i> <i style="float:right;">Last updated 2020-03-22 02:23:51 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View File

@ -239,7 +239,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-03-21 23:23:01 </i> <i style="float:right;">Last updated 2020-03-22 02:23:51 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View File

@ -507,7 +507,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-03-21 23:23:01 </i> <i style="float:right;">Last updated 2020-03-22 02:23:51 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View File

@ -91,6 +91,10 @@
<td class="name" nowrap><a href="#set">set(value[, is_silent])</a></td> <td class="name" nowrap><a href="#set">set(value[, is_silent])</a></td>
<td class="summary">Set value for slider</td> <td class="summary">Set value for slider</td>
</tr> </tr>
<tr>
<td class="name" nowrap><a href="#set_steps">set_steps(steps)</a></td>
<td class="summary">Set slider steps.</td>
</tr>
</table> </table>
<h2><a href="#Tables">Tables</a></h2> <h2><a href="#Tables">Tables</a></h2>
<table class="function_list"> <table class="function_list">
@ -166,6 +170,32 @@
</dd>
<dt>
<a name = "set_steps"></a>
<strong>set_steps(steps)</strong>
</dt>
<dd>
Set slider steps. Pin node will
apply closest step position
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">steps</span>
<span class="types"><span class="type">number[]</span></span>
Array of steps
</li>
</ul>
<h3>Usage:</h3>
<ul>
<pre class="example">slider:set_steps({<span class="number">0</span>, <span class="number">0.2</span>, <span class="number">0.6</span>, <span class="number">1</span>})</pre>
</ul>
</dd> </dd>
</dl> </dl>
<h2 class="section-header "><a name="Tables"></a>Tables</h2> <h2 class="section-header "><a name="Tables"></a>Tables</h2>
@ -248,7 +278,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-03-21 23:23:01 </i> <i style="float:right;">Last updated 2020-03-22 02:23:51 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View File

@ -352,7 +352,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-03-21 23:23:01 </i> <i style="float:right;">Last updated 2020-03-22 02:23:51 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View File

@ -307,7 +307,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-03-21 23:23:01 </i> <i style="float:right;">Last updated 2020-03-22 02:23:51 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View File

@ -239,7 +239,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-03-21 23:23:01 </i> <i style="float:right;">Last updated 2020-03-22 02:23:51 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View File

@ -750,7 +750,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-03-21 23:23:01 </i> <i style="float:right;">Last updated 2020-03-22 02:23:51 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View File

@ -155,7 +155,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-03-21 23:23:01 </i> <i style="float:right;">Last updated 2020-03-22 02:23:51 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View File

@ -193,7 +193,7 @@ There is next interests in druid:
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-03-21 23:23:01 </i> <i style="float:right;">Last updated 2020-03-22 02:23:51 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View File

@ -138,7 +138,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-03-21 23:23:01 </i> <i style="float:right;">Last updated 2020-03-22 02:23:51 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View File

@ -89,7 +89,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-03-21 23:23:01 </i> <i style="float:right;">Last updated 2020-03-22 02:23:51 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View File

@ -80,14 +80,14 @@
<h2>Overview</h2> <h2>Overview</h2>
<p>See the <a href="https://github.com/Insality/druid/tree/develop/example/kenney">example folder</a> for examples of how to use Druid</p> <p>See the <a href="https://github.com/Insality/druid/tree/develop/example/kenney">example folder</a> for examples of how to use Druid</p>
<p>Try the HTML5 version of the example app</p> <p>Try the <a href="https://insality.github.io/druid/druid/">HTML5 version</a> of the example app</p>
</div> <!-- id="content" --> </div> <!-- id="content" -->
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-03-21 23:23:01 </i> <i style="float:right;">Last updated 2020-03-22 02:23:51 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View File

@ -83,6 +83,8 @@
<a href="https://insality.github.io/druid/"><img src="media/druid_logo.png" alt=""/></a></p> <a href="https://insality.github.io/druid/"><img src="media/druid_logo.png" alt=""/></a></p>
<p><a href="https://github.com/Insality/druid/releases"><img src="https://img.shields.io/github/v/release/insality/druid" alt="GitHub release (latest by date)"/></a></p>
<p><strong>Druid</strong> - powerful defold component UI library. Use basic druid components or make your own game-specific components to make amazing GUI in your games.</p> <p><strong>Druid</strong> - powerful defold component UI library. Use basic druid components or make your own game-specific components to make amazing GUI in your games.</p>
@ -181,7 +183,7 @@
<p>See the <a href="https://github.com/insality/druid-assets">druid-assets repository</a> for examples of how to create custom components and styles</p> <p>See the <a href="https://github.com/insality/druid-assets">druid-assets repository</a> for examples of how to create custom components and styles</p>
<p>Try the HTML5 version of the example app</p> <p>Try the <a href="https://insality.github.io/druid/druid/">HTML5 version</a> of the example app</p>
<p><a name="Documentation"></a></p> <p><a name="Documentation"></a></p>
@ -218,7 +220,7 @@ https://insality.github.io/druid/</p>
<p><a name="License"></a></p> <p><a name="License"></a></p>
<h2>License</h2> <h2>License</h2>
<p>Original idea by <a href="https://github.com/AGulev">AGulev</a></p> <p>Original created by <a href="https://github.com/AGulev">AGulev</a></p>
<p>Developed and supporting by <a href="https://github.com/Insality">Insality</a></p> <p>Developed and supporting by <a href="https://github.com/Insality">Insality</a></p>
@ -234,7 +236,7 @@ https://insality.github.io/druid/</p>
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-03-21 23:23:01 </i> <i style="float:right;">Last updated 2020-03-22 02:23:51 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View File

@ -30,6 +30,12 @@ local function on_change_value(self)
end end
local function set_position(self, value)
value = helper.clamp(value, 0, 1)
gui.set_position(self.node, self.start_pos + self.dist * value)
end
--- Component init function --- Component init function
-- @function slider:init -- @function slider:init
-- @tparam node node Gui pin node -- @tparam node node Gui pin node
@ -76,9 +82,8 @@ function M.on_input(self, action_id, action)
self.target_pos.x = helper.clamp(self.pos.x, self.start_pos.x, self.end_pos.x) self.target_pos.x = helper.clamp(self.pos.x, self.start_pos.x, self.end_pos.x)
self.target_pos.y = helper.clamp(self.pos.y, self.start_pos.y, self.end_pos.y) self.target_pos.y = helper.clamp(self.pos.y, self.start_pos.y, self.end_pos.y)
gui.set_position(self.node, self.target_pos)
if prev_x ~= self.target_pos.x or prev_y ~= self.target_pos.y then if prev_x ~= self.target_pos.x or prev_y ~= self.target_pos.y then
local prev_value = self.value
if self.dist.x > 0 then if self.dist.x > 0 then
self.value = (self.target_pos.x - self.start_pos.x) / self.dist.x self.value = (self.target_pos.x - self.start_pos.x) / self.dist.x
@ -88,10 +93,29 @@ function M.on_input(self, action_id, action)
self.value = (self.target_pos.y - self.start_pos.y) / self.dist.y self.value = (self.target_pos.y - self.start_pos.y) / self.dist.y
end end
if self.steps then
local closest_dist = 1000
local closest = nil
for i = 1, #self.steps do
local dist = math.abs(self.value - self.steps[i])
if dist < closest_dist then
closest = self.steps[i]
closest_dist = dist
end
end
if closest then
self.value = closest
end
end
if prev_value ~= self.value then
on_change_value(self) on_change_value(self)
end end
end end
set_position(self, self.value)
end
if action.released then if action.released then
self.is_drag = false self.is_drag = false
end end
@ -106,8 +130,7 @@ end
-- @tparam[opt] bool is_silent Don't trigger event if true -- @tparam[opt] bool is_silent Don't trigger event if true
function M.set(self, value, is_silent) function M.set(self, value, is_silent)
value = helper.clamp(value, 0, 1) value = helper.clamp(value, 0, 1)
set_position(self, value)
gui.set_position(self.node, self.start_pos + self.dist * value)
self.value = value self.value = value
if not is_silent then if not is_silent then
on_change_value(self) on_change_value(self)
@ -115,4 +138,14 @@ function M.set(self, value, is_silent)
end end
--- Set slider steps. Pin node will
-- apply closest step position
-- @function slider:set_steps
-- @tparam number[] steps Array of steps
-- @usage slider:set_steps({0, 0.2, 0.6, 1})
function M.set_steps(self, steps)
self.steps = steps
end
return M return M