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

Reaction to scale and other problems... #24

Open
ErrrikMarrrtinez opened this issue May 17, 2024 · 0 comments
Open

Reaction to scale and other problems... #24

ErrrikMarrrtinez opened this issue May 17, 2024 · 0 comments

Comments

@ErrrikMarrrtinez
Copy link

ErrrikMarrrtinez commented May 17, 2024

Tell me how to calculate the correct trajectory of the x and y coordinates when changing the scale, so that the rtk.Popup is conditionally exactly under it?

How can I solve the problem with twitching along with the current mouseover\onmouseenter\onmouseleave for the widget during a smooth scroll viewport

How can I make the animation stable when scaling in for example the interface?

There is a problem with rtc.Popup and the auto close parameter - it does not work if you open an additional rtk.Popup with the autoclose parameter inside any rt.Popup (for nested rtk.Popup)

I have a simple version of rtk.Flowbox but with a horizontal offset, I did not use subclasses but created a function directly in onreflow. At the moment, the function is different from the one on the forum:

function rtk_FlowBox(params)
    local flowbox = rtk.Container(params)
    local spacing = params.spacing or 0
    local min_elem_width = params.min_elem_width or 240 -- minw
    local last_width = nil 
    local last_visible_count = nil -- last count visible
    flowbox.onreflow = function(self)
        local visible_count = 0
        for i, info in ipairs(self.children) do
            if info[1].visible then
                visible_count = visible_count + 1
            end
        end
        if self.calc.w == last_width and visible_count == last_visible_count then
            return
        end
        last_width = self.calc.w
        last_visible_count = visible_count
        local visible_w, new_y, new_x = 0, 0, 0
        local elems_per_row = math.max(1, math.floor(self.calc.w / (min_elem_width + spacing)))
        local elem_width = self.calc.w / elems_per_row
        for i, info in ipairs(self.children) do
            local elem = info[1]
            if elem.visible then
                if visible_w + elem_width + spacing > self.calc.w then
                    new_x, new_y, visible_w = 0, new_y + elem.calc.h + spacing, 0
                end
                elem:resize(elem_width, elem.calc.h)
                elem:move(new_x, new_y)
                new_x = new_x + elem_width + spacing
                visible_w = visible_w + elem_width
            end
        end
    end
    return flowbox
end

It works great and is more "optimized" in terms of calculations, using the standard rtk.FlowBox (vertical) is somewhat expensive in terms of resources, with automatic filling of child elements (fillw\fillh=true). But the only problem is that when changing any scale, it begins to infinitely increase the height of the child elements being placed (to put it correctly, not "infinitely", but "continuously").

Additionally, there is an error described on the forum regarding automatic changes for rtk.Window, and its strange behavior for child containers or elements that have automatic filling (only when borderless = false for rtk.Window)

Also regarding mouseenter: suppose I have an onmouseenter handler for a container to highlight its borders in red, and inside the container there are also buttons with their own enter\leave handlers. When hovering inside the container on some element, focus is lost from the container, which causes the problem. The solution is to use a separate defer that would monitor rtk.Widget.mouseover in order to set for it related functionality with onmouseenter, and using many flags between them is tedious

By the way, for rtk.Popup, when you specify the anchor attribute, the popup opens without taking into account the x and y offset using padding or margin.

I also have a question about creating a widget and animation that I have not been able to solve, if you can answer, then I will share it so that you can familiarize yourself

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

No branches or pull requests

1 participant