Code Monkey home page Code Monkey logo

Comments (8)

yglukhov avatar yglukhov commented on July 20, 2024

Another option would be to allow some kind of variables which can be changed from outside, but not from the solver, but I can't see those in Kiwi as well (

from kiwi.

MatthieuDartiailh avatar MatthieuDartiailh commented on July 20, 2024

I believe what you are looking for are EditVariables. You can look at cassowary examples as kiwi implement the same solver. This example in particular seems to describe your use case: http://cassowary.readthedocs.io/en/latest/topics/examples.html

from kiwi.

yglukhov avatar yglukhov commented on July 20, 2024

@MatthieuDartiailh, I doubt it. The example you're providing is using stay constraints (grep for add_stay), which is missing in kiwi.

To somehow rephrase my question I can provide a use case which I want to implement. Let's say there's a UI system, with view hierarchies, where every view has x, y, width and height variables. All the variables are tied with constraints. Then there's the window with its width and height variables. The user may resize it, so I "edit" the width and height of the window and it works for the first relayout, but subsequent calls to solver.solve may randomly change these variables again. So I want those variables to stay and be changed when its otherwise impossible to solve the constraints.

from kiwi.

MatthieuDartiailh avatar MatthieuDartiailh commented on July 20, 2024

I believe you can still achieve your goal without stay constraints, as it is done in enaml (https://github.com/nucleic/enaml/blob/master/enaml/layout/layout_manager.py#L244). You can look at how the constraints are defined and how resize is done.
I must say I am not an expert here, @sccolbert would be more qualified to answer you.

from kiwi.

MatthieuDartiailh avatar MatthieuDartiailh commented on July 20, 2024

See also this discussion #9

from kiwi.

yglukhov avatar yglukhov commented on July 20, 2024

Thanks, #9 explains a lot. Maybe this info should be mentioned on the front page, that stay constraints can be "simulated" by adding/removing external EQ constraints.

from kiwi.

sccolbert avatar sccolbert commented on July 20, 2024

@yglukhov The right way to do what you want is with edit variables. In Enaml, each widget has a variable for left, top, width, and height. Child widgets are ultimately constrained based on their parent's width and height variables. Those variables are added to the solver via solver.addEditVariable. When solving for the layout of the children, the current size of the parent is used to suggest values for the width and height variables via solver.suggestValue. The system is then solved via solver.updateVariables.

https://github.com/nucleic/enaml/blob/master/enaml/layout/layout_manager.py#L358-L360

from kiwi.

yglukhov avatar yglukhov commented on July 20, 2024

@sccolbert, ah that makes even more sense. Thank you. Still worth mentioning in the docs I think.

from kiwi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.