ableton / aqt-cassowary Goto Github PK
View Code? Open in Web Editor NEWUse the Cassowary constraint solver in QML applications
Home Page: http://ableton.github.io/aqt-cassowary
License: MIT License
Use the Cassowary constraint solver in QML applications
Home Page: http://ableton.github.io/aqt-cassowary
License: MIT License
Debugging constraints and the output of debug: true
can be messy. It would be nice to be able to name constraints and variables such that they show like that in the debugging output. This might need changes to Rhea.
An error rises that seems to caused by a wrong order when initializing objects. We should investigate further and improve the queuing of changes to the solver such that it enforces a correct order.
All solver-relevant objects inherit from QQuickItem
to benefit from automatic parent management. However QQuickItem is kinda overkill for our needs here by doing the parenting manually.
The library API has been quite stable for the last few months and has been used in production without major issues. It makes sense to make a 1.0 release.
Remaining tasks:
make install
make dist
to build tarballs.Reproduce
$ mkdir build
$ cd build
$ cmake -GNinja ..
$ nina
ninja: error: 'src/rhea-prefix/lib/librhea-s.a', needed by 'output/libAqtCassowaryPlugin.so', missing and no known rule to make it
Default GNU make
generator works fine though.
One can see this when resizing the window in the different examples. Resolutions should happen in the same frame, but we still should do the queuing that we do now. A good way to achieve this is by using the polish()
and updatePolisth()
API of QQuickItem
The current syntax works and is very declarative, but it is kinda verbose. There are several strategies one can find to fix this problem.
One strategy is to simply add more helpers such that some common cases can be come more terse and require less construction of Qt objects. I like the idea of requiring less QObjects a lot, so for example, we could try rewriting this:
Solver {
Variable { id: var1 }
Variable { id: var2 }
Constraint { expr: geq(var2, var1) }
Constraint { expr: eq(plus(var2, var1), 100) }
Constraint { espr: leq(var2, 200) }
}
As:
property Variable var1: Variable {}
property Variable var2: Variable {}
property Variable var3: Variable {}
Solver {
constraints: [
geq(var2, var1),
eq(plus(var2, var1), 100),
leq(var2, 200)
]
}
Note that declaring variables like that is already possible (they don't need to be in the solver). I am not sure whether it's a good idea or not. It depends on whether you want/need to expose them to the outside world.
A nother intersting approach, but less QML-ish, would be to use strings instead and parse the expressions, like this:
Solver {
variables: [ "var1", "var2" ]
constraints: [
"var1 >= var2",
"var2 + var1 == 100",
"var2 <= 200"
]
}
In this later case, the API would need a major revamp, such that one could access the values of these string-identified variables. It lso becomes more tricky to inject values that come with QML, since one need then to manipulate the string somehow, and it might perform worse if constraints change often (which they should not anyways, but...).
While running the example Splitters.qml app, if you quickly resize the window smaller such that minimum sizes are not possible to maintain, you get a crash:
libc++abi.dylib: terminating with uncaught exception of type rhea::internal_error: dual_optimize: no pivot found
Process: qmlscene [38401]
Path: /Volumes/VOLUME/*/qmlscene
Identifier: qmlscene
Version: ???
Code Type: X86-64 (Native)
Parent Process: Python [38398]
Responsible: Terminal [315]
User ID: 502
Date/Time: 2015-01-28 13:49:26.833 +0100
OS Version: Mac OS X 10.10.1 (14B25)
Report Version: 11
Anonymous UUID: EFB97EAA-C3CD-BD5F-AD8C-26F1610BA6F4
Sleep/Wake UUID: 0FC0CBDB-F97D-4047-A59B-E860D7279480
Time Awake Since Boot: 760000 seconds
Time Since Wake: 20000 seconds
Crashed Thread: 0 Dispatch queue: com.apple.main-thread
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Application Specific Information:
terminating with uncaught exception of type rhea::internal_error: dual_optimize: no pivot found
abort() called
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 libsystem_kernel.dylib 0x00007fff953e6282 __pthread_kill + 10
1 libsystem_c.dylib 0x00007fff96a75b73 abort + 129
2 libc++abi.dylib 0x00007fff8be3ea21 abort_message + 257
3 libc++abi.dylib 0x00007fff8be669b9 default_terminate_handler() + 243
4 libobjc.A.dylib 0x00007fff90ffc6db _objc_terminate() + 124
5 libc++abi.dylib 0x00007fff8be640a1 std::__terminate(void (*)()) + 8
6 libc++abi.dylib 0x00007fff8be63d48 __cxa_rethrow + 99
7 libobjc.A.dylib 0x00007fff90ffc4e4 objc_exception_rethrow + 40
8 com.apple.AppKit 0x00007fff924bc7f0 -[NSWindow(NSWindowResizing) _resizeWithEvent:] + 1778
9 com.apple.AppKit 0x00007fff91e73eb9 -[NSTitledFrame mouseDown:] + 200
10 com.apple.AppKit 0x00007fff91e73caa -[NSThemeFrame mouseDown:] + 68
11 com.apple.AppKit 0x00007fff9230cf4f -[NSWindow _reallySendEvent:] + 12827
12 com.apple.AppKit 0x00007fff91d9750c -[NSWindow sendEvent:] + 368
13 libqcocoa.dylib 0x000000010d214717 -[QNSWindow superSendEvent:] + 39
14 libqcocoa.dylib 0x000000010d2140bb -[QNSWindowHelper handleWindowEvent:] + 411
15 com.apple.AppKit 0x00007fff91d49096 -[NSApplication sendEvent:] + 2238
16 libqcocoa.dylib 0x000000010d22b00e -[QNSApplication sendEvent:] + 78
17 com.apple.AppKit 0x00007fff91bd5e98 -[NSApplication run] + 711
18 libqcocoa.dylib 0x000000010d22792d QCocoaEventDispatcher::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) + 2189
19 org.qt-project.QtCore 0x000000010a0c33fd QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) + 381
20 org.qt-project.QtCore 0x000000010a0c63da QCoreApplication::exec() + 346
21 qmlscene 0x000000010947e2ec main + 11516
22 qmlscene 0x000000010947b444 start + 52
Also, as part of this, remove the manually maintained index.html
and replace it with the generated documentation, like in https://github.com/Ableton/atria
The most common usecase of this library, layout, is still kinda cumbersome with this library since one still needs to map all the values to and from the Cassowary variables. It would be nice to have sensible defaults and utilities to be able to write code like this:
import Aqt.Cassowary.Layout 1.0
Layout {
id: root
Constraint { expr: eq(button2.left, plus(button1.right, 20)) }
Constraint { expr: eq(root.horizontalCenter, divide(plus(button1.left, button2.right), 2)) }
Anchors {
id: button1
Button {}
}
Anchors {
id: button2
Button {}
}
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.