-
-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/progress #17
Feature/progress #17
Conversation
druid/base/progress.lua
Outdated
data.ON_UPDATE, | ||
} | ||
|
||
local LERP_KOEF = 0.08 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lerp speed of filling progress bar, calling in update, need to move in settings
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should be more user-friendly and use one SPEED? (px in sec)
local total_width = set_to * instance.max_size | ||
|
||
local scale = math.min(total_width / instance.slice_size, 1) | ||
local size = math.max(total_width, instance.slice_size) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
scale will be applied, if we cant set size less of slice9 node. Or node have no slice9 settings
|
||
--- Fill a progress bar and stop progress animation | ||
function M.fill(instance) | ||
set_bar_to(instance, 1, true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
silence don't throw steps callbacks
-- @param to - value between 0..1 | ||
-- @param callback - callback when progress ended if need | ||
function M.to(instance, to, callback) | ||
to = helper.clamp(to, 0, 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For now we can't pass values different from 0..1
Maybe, later we can do loop progress bar, if value < 0 or > 1
druid/base/progress.lua
Outdated
|
||
--- Called when layout updated (rotate for example) | ||
function M.on_layout_updated(instance) | ||
instance:set_to(instance.last_value) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure, what this works correctly now, need to check
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comment above
druid/base/progress_rich.lua
Outdated
@@ -0,0 +1,54 @@ | |||
local M = {} | |||
|
|||
local DELAY = 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Delay, before main fill animation is started
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's move rich components into rich folder?
self.druid:new_button("button_1", function() | ||
print("On button 1") | ||
end) | ||
local function change_page(self, delta) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Temporary pages for test different GUI components
There is buttons to change pages
@@ -0,0 +1,18 @@ | |||
path_settings { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
settings to disable mipmaps, to render correctly small scaling of slice9
druid/base/progress.lua
Outdated
local M = {} | ||
|
||
M.interest = { | ||
data.LAYOUT_CHANGED, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's remove data.LAYOUT_CHANGED event if we don't sure that it works.
We can add it later using universal abstraction for save values and restore them when layout changed
druid/base/progress.lua
Outdated
instance.prop = hash("scale."..key) | ||
instance.key = key | ||
|
||
instance.node = gui.get_node(name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe it would be better to use helper.get_node() here?
druid/base/progress.lua
Outdated
|
||
--- Called when layout updated (rotate for example) | ||
function M.on_layout_updated(instance) | ||
instance:set_to(instance.last_value) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comment above
druid/base/progress.lua
Outdated
data.ON_UPDATE, | ||
} | ||
|
||
local LERP_KOEF = 0.08 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should be more user-friendly and use one SPEED? (px in sec)
druid/base/progress_rich.lua
Outdated
@@ -0,0 +1,54 @@ | |||
local M = {} | |||
|
|||
local DELAY = 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's move rich components into rich folder?
druid/base/progress_rich.lua
Outdated
function M.init(instance, name, red, green, key) | ||
instance.red = instance.parent:new_progress(red, key) | ||
instance.green = instance.parent:new_progress(green, key) | ||
instance.fill = instance.parent:new_progress(name, key) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My favorite part: using base components as building blocks for rich components.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should do a few improvements, but looks great, anyway!
@@ -1,7 +1,7 @@ | |||
local data = require("druid.data") | |||
local ui_animate = require("druid.helper.druid_animate") | |||
local settings = require("druid.settings") | |||
local helper = require("druid.helper.helper") | |||
local helper = require("druid.helper") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved to easier require
@@ -12,6 +12,14 @@ M.button = { | |||
SCALE_CHANGE = vmath.vector3(-0.05, - 0.05, 1), | |||
} | |||
|
|||
M.progress = { | |||
SPEED = 5, -- progress bar fill rate, more faster |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We operate with scaling property. For now I don't know how to describe it better
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Resolve #11
Progress now filling with target value in update
You can setup value any times as you want, progress will animate correctly
You can setup slice size of progress node to more accurate scaling (if progress edges is rounded)
You can setup steps and callback on steps [0..1]. It throw callback, when progress bar fill through this value
Add clamp and round functions
Add progress_rich, what use 3 progress bars (main fill, red to show decrease values and green to show inc. values)
It show you visually diff before main fill is animated