Skip to content
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

Merged
merged 12 commits into from
Apr 3, 2019
Merged

Feature/progress #17

merged 12 commits into from
Apr 3, 2019

Conversation

Insality
Copy link
Owner

@Insality Insality commented Apr 2, 2019

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

@Insality Insality requested a review from AGulev April 2, 2019 07:02
data.ON_UPDATE,
}

local LERP_KOEF = 0.08
Copy link
Owner Author

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

Copy link
Collaborator

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)
Copy link
Owner Author

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)
Copy link
Owner Author

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)
Copy link
Owner Author

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


--- Called when layout updated (rotate for example)
function M.on_layout_updated(instance)
instance:set_to(instance.last_value)
Copy link
Owner Author

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

Copy link
Collaborator

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 Show resolved Hide resolved
@@ -0,0 +1,54 @@
local M = {}

local DELAY = 1
Copy link
Owner Author

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

Copy link
Collaborator

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)
Copy link
Owner Author

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 {
Copy link
Owner Author

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

local M = {}

M.interest = {
data.LAYOUT_CHANGED,
Copy link
Collaborator

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

instance.prop = hash("scale."..key)
instance.key = key

instance.node = gui.get_node(name)
Copy link
Collaborator

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?


--- Called when layout updated (rotate for example)
function M.on_layout_updated(instance)
instance:set_to(instance.last_value)
Copy link
Collaborator

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 Show resolved Hide resolved
data.ON_UPDATE,
}

local LERP_KOEF = 0.08
Copy link
Collaborator

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)

@@ -0,0 +1,54 @@
local M = {}

local DELAY = 1
Copy link
Collaborator

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?

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)
Copy link
Collaborator

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.

Copy link
Collaborator

@AGulev AGulev left a 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!

@Insality Insality requested a review from AGulev April 3, 2019 20:14
@@ -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")
Copy link
Owner Author

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
Copy link
Owner Author

@Insality Insality Apr 3, 2019

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

Copy link
Collaborator

@AGulev AGulev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@Insality Insality merged commit d49cd27 into develop Apr 3, 2019
@Insality Insality deleted the feature/progress branch April 3, 2019 20:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants