Commit graph

736 commits

Author SHA1 Message Date
Simon Hausmann
65e09c723a Use hover effects in the ugly style
Use a darker shade between the unpressed and the pressed shade when hovering
over controls that can be activated.
2020-11-24 22:12:17 +01:00
Simon Hausmann
727ab2ee9d Minor tweak to the ugly style
Don't use the shiny blue when pressing items - it's seemingly pretty
but it won't go well with a color change on hover.
2020-11-24 22:02:16 +01:00
Olivier Goffart
3ae7c6e0b5 Hover effect 2020-11-24 18:09:32 +01:00
Olivier Goffart
8a64f10e84 Remove ComponentVtable::input_event
And the custom handling of the mouse grabber
2020-11-24 16:23:37 +01:00
Olivier Goffart
0c97b4f296 More use of the ItemRc 2020-11-24 13:42:34 +01:00
Simon Hausmann
d80868bbf4 Add support for font_weight to Text and TextInput
This allows implementing another sliding puzzle theme feature, the
boldness of the tile number text in the simple theme when the tile is in
the correct position. For the other themes the weight is constant and
it's bold.

More cleanup to follow later: unify the font handle and FontCacheKey
handling, improve the API to allow for the use of symbolic constants
(normal, bold, etc.) instead of the CSS number values.
2020-11-24 10:10:00 +01:00
Simon Hausmann
3d85e45ec3 Add support for source clipping to the Image element
This allows rendering only a sub-rectangle of the original image, which
we can use right away in the sliding puzzle demo.
2020-11-23 15:46:59 +01:00
Simon Hausmann
fa95064363 Fix resource embedding across component boundaries
When referencing an image a repeated element and were targeting a
configuration that requires resource embedding, then that image would
not embedded.

This was due to the fact that we didn't recurse into sub-components in
the resource collection phase and the generators made a per-component
embedding decision. The field responsible for that was also not
propagated to sub-components.

This patch addresses these two bugs by cleaning up the entire mechanism:

The compiler first generates the new ResourceReference::AbsolutePath for
all img!"foo.png" expressions. If the compiler is configured to embed
resources, then the embed_resources pass will traverse all
sub-components and expressions in them to change them to
ResourceReference::EmbeddedData with a unique integer id. Simultaenously
all the resources to be embedded get also collected in the root
component, so that the build script as well as the generator can take
care of dependency handling and actual resource embedding.
2020-11-23 13:47:16 +01:00
Olivier Goffart
df318d9104 Fix states in the root of other components 2020-11-20 17:14:04 +01:00
Olivier Goffart
08fe5f6c72 Add a Clip 2020-11-20 15:45:45 +01:00
Simon Hausmann
89e0b57627 Rework and simplify the focus handling
Instead of determining the focus item through item tree traversal and
pointer comparison and storing the intermediate indices in the
components in the tree, remember the focus item by a pair of
VWeak<ComponentVTable, Dyn> and item_index: usize.

This speeds up determining the focus item as well as delivering events,
which can now be done directly after retrieving an ItemRef with
get_item_ref.

This also fixes the duplicate line edit focus in the 7gui cells
test case.
2020-11-20 15:33:15 +01:00
Olivier Goffart
551c50560f Fix warning with clang 2020-11-20 12:47:32 +01:00
Olivier Goffart
d5c4885955 Transitions in C++ 2020-11-20 11:38:03 +01:00
Olivier Goffart
091a0834d3 Transitions in rust (C++ and interpreter not implemented yet) 2020-11-20 10:30:17 +01:00
Olivier Goffart
865e6055f2 Work on transition: lower the transitions 2020-11-20 09:39:06 +01:00
Olivier Goffart
88ceeeb3e6 Error when a transition reffers to a state that does not exist 2020-11-20 09:39:06 +01:00
Olivier Goffart
4d4c73925c Some refactoring to prepare for transitions on properties 2020-11-20 09:39:06 +01:00
Simon Hausmann
78fae068dd Use ComponentRc during item tree traversal
This is in preparation for allowing the run-time / items to clone VRc's
of the component.

ComponentVTable functions like visit_children_item contine to take a
ComponentRefPin as "self" parameter type, as a VRc would not be
supported by rust right now. That means the implementation then uses
self_weak to obtain a strong self-reference.
2020-11-19 17:04:01 +01:00
Simon Hausmann
54cc66c400 Fix timing/placement of extra setup code
The setup code is used to place an initial set_focus_item call, for
example. In preparation for future changes, this needs to happen *after*
self_weak has been set up. For C++ this means placing the code into the
create() function, where there's no (implicit) this pointer, so we need
to use self in some places.
2020-11-19 17:00:56 +01:00
Simon Hausmann
9c9e6c7563 Clean up C++ repeated component creation
Centralize the self_weak setup to be emitted only once, in the create()
function. create() is now always emitted and equipped with a parent
parameter, for non-root components. This allows slightly simplifying the
generic repeater code.
2020-11-19 16:41:26 +01:00
Simon Hausmann
7d7903d1ae Fix warning about extra parentheses for conditionals 2020-11-19 15:50:26 +01:00
Simon Hausmann
ce8c728c57 Fix clang warning about implicitly truncating double to int
Well, let's do that explicitly then. The test case mod.60 uses

    mod(8.3, 10)
2020-11-19 15:46:07 +01:00
Olivier Goffart
15fd1c45a3 More warning fixes with clang 2020-11-19 15:04:39 +01:00
Olivier Goffart
6b3dd802a3 Another attempt to fix clang warning about unused captures 2020-11-19 14:42:29 +01:00
Olivier Goffart
88d559eb09 Revert "Attempt to fix clang warning about unused capture"
This reverts commit 3b26dc215e.

This did not work
2020-11-19 14:39:46 +01:00
Olivier Goffart
3b26dc215e Attempt to fix clang warning about unused capture 2020-11-19 14:28:06 +01:00
Olivier Goffart
3fce3e6f1b Get rid of the component in the C++ ComponentWindow::run 2020-11-19 13:42:52 +01:00
Olivier Goffart
c50fc6f51c More work on state properties with transitions
C++ set the proper binding for StateInfo state binding
2020-11-19 13:31:18 +01:00
Olivier Goffart
cfa9413861 More work on the state binding for transition:
When there is a transition, turn the state property into a property of StateInfo

Not yet implemented for C++
2020-11-19 12:43:28 +01:00
Olivier Goffart
8b76114083 Recompile if a dependencies changes 2020-11-18 13:23:59 +01:00
Simon Hausmann
a2839e03c2 Cpp: Add a self_weak to repeated components
The main struct has it, and sub-components should have it, too.
2020-11-18 12:00:30 +01:00
Olivier Goffart
f131c2d081 When only importing a component, treat that component as the root component 2020-11-18 10:43:39 +01:00
Simon Hausmann
7a5113ece1 Free graphics resources without item tree traversal 2020-11-18 08:49:57 +01:00
Olivier Goffart
ba0ec058ab Make C++ build output more pretty
Avoid empty lines in stderr from the compiler, and make sure
the description from the compile line mention the output target
instead of not the source tomake it consistant with other outputs
2020-11-17 15:17:58 +01:00
Olivier Goffart
7a746c15da Also make sure to generate struct when the property is an array of struct 2020-11-17 12:33:19 +01:00
Olivier Goffart
dec29e6d98 Allow to export structs 2020-11-17 12:22:10 +01:00
Olivier Goffart
7967a074fb Fix accessing struct declared in a different file 2020-11-17 12:02:21 +01:00
Simon Hausmann
54ee7b3556 Cpp: Give each generated component a ComponentWindow
That's a counted reference to the window in the run-time and avoids the need to do the parent->parent->window dance.
2020-11-16 16:59:57 +01:00
Simon Hausmann
f9ced44188 Rust: Simplify window access code
We don't need to do the parent dance anymore, use _self.window directly.
2020-11-16 16:55:29 +01:00
Simon Hausmann
7d5131afc8 Rust: Make the window a member of each struct
This avoids the parent dance in the Drop implementation
2020-11-16 15:56:13 +01:00
Olivier Goffart
dd4435fe5d Add round/ceil/floor 2020-11-16 12:52:01 +01:00
Olivier Goffart
65a03fa11d Fix mod test 2020-11-13 16:15:44 +01:00
Olivier Goffart
b45a14bd7a modulo 2020-11-13 16:07:18 +01:00
Olivier Goffart
1eb57ae4a3 Add minmax tests 2020-11-13 15:55:42 +01:00
Olivier Goffart
6ca7c85eab Implement min and max 2020-11-13 15:30:07 +01:00
Olivier Goffart
d499e86640 Implement cubic-bezier 2020-11-13 13:36:32 +01:00
Simon Hausmann
2282697b0c Fix relative file imports from relative sources with the CLI viewer
Calling

    viewer ./examples/printerdemo/ui/printerdemo.60

would fail trying to resolve the relative path import "common.60" from
printerdemo.60, because we would apply the logic for resolving relative
include paths to be relative to the input file *also* for the initial
include path, derived from the main input file. That would result in a
search path

    ./examples/printerdemo/ui/./examples/printerdemo/ui

and that doesn't work :-)

So apply the resolution of relative include paths to be relative to the
input file only to those in the compiler configuration.
2020-11-12 15:47:50 +01:00
Simon Hausmann
c258a907f0 Simplify event loop start-up
Move the layout constraint tracker into the window where we can apply
the constraints right before drawing, instead of doing that from within
the event loop. This allows to remove the component parameter from the
run function.
2020-11-12 15:04:48 +01:00
Simon Hausmann
64b92df87e Initialize the component in the Window at component creation time
This will allow getting rid of the component as parameter to run()
2020-11-11 19:03:04 +01:00
Simon Hausmann
5d744c86c2 Begin passing the VRC<ComponentVTable, Dyn> into the run-time library
First by changing the signature of run() and by adding a self_weak
to the C++ struct.
2020-11-11 18:31:51 +01:00