Commit graph

582 commits

Author SHA1 Message Date
David Vanderson
0dfc88ca71 sliderEntry text: commit on lost focus and escape key 2023-11-08 20:17:42 -05:00
David Vanderson
0dbb78d579 INSIDE typo 2023-11-08 15:42:09 -05:00
David Vanderson
19a313e0be INSIDE: incorporate feedback (thanks KnockerPulsar) 2023-11-08 15:33:49 -05:00
David Vanderson
f3763cc8ee sliderEntry: starting to work
This necessitated some tweaks to TextEntryWidget so we can draw the
cursor even when TextEntryWidget doesn't have focus.
2023-11-06 21:27:44 -05:00
David Vanderson
c3842fb30d sliderEntry: start on combo slider/label and textEntry 2023-11-06 21:01:39 -05:00
David Vanderson
838a07c216 matchEvent: directly query widgets for eventMatch
We were using a roundabout method of checking if an event matched
(should be looked at) to a widget.  It broke down when you want to have
a compound widget where the top one gets all the events and directs them
to widgets inside.

Now we call matchEvent() on the widget and it says if the given event
should be looked at.
2023-11-06 20:39:54 -05:00
David Vanderson
65abd17b77 normalizing apis - done for now 2023-11-06 13:02:13 -05:00
David Vanderson
b6b6411311 normalizing apis, fix button background 2023-11-06 12:59:37 -05:00
David Vanderson
83431e5aef normalizing apis 2023-11-06 12:47:33 -05:00
David Vanderson
e31a5795db scroll: fix dataSet/dataGet mismatch on key up/down 2023-11-06 12:47:02 -05:00
David Vanderson
0c805da415 normalizing apis 2023-11-06 12:15:03 -05:00
David Vanderson
be3f1bc9f3 normalizing apis
We are moving from passing in options (like whether to process events
and what stuff to draw) to install() to having a few more
functions per widget.

Instead of customizing a widget via options, the
idea is to start with the functions called in the high-level api
(like button()), and then adjust as needed.
2023-11-06 11:51:24 -05:00
David Vanderson
190bd880bf floatingWindow: normalize api and fix capture bug
When I consolidated captureMouseMaintain into WidgetData, I forgot that
floating windows (FloatingWindow and Popup) need to call
captureMouseMaintain after they add themselves with
subwindowCurentSet/subwindowAdd.

Otherwise it breaks being able to drag modal dialogs.
2023-11-06 09:11:31 -05:00
David Vanderson
c82aeff2cd WidgetData.init now calls captureMouseMaintain
This used to be done in each widget, but it should always happen.
labelClick() showed how a widget that doesn't normally capture the mouse
could be used in that way.
2023-11-06 08:16:47 -05:00
David Vanderson
e69eb8436d INSIDE: trying a code listing 2023-11-06 07:53:35 -05:00
David Vanderson
0b0b3ccd01 label: normalize api
Also comment the labelClick function to use as an example.
2023-11-06 07:48:09 -05:00
David Vanderson
70665083c1 start on INSIDE doc 2023-11-05 22:40:00 -05:00
David Vanderson
15b8906085 progress: function to show a progress bar
Also an example for how to use it with a background thread that calls
refresh().
2023-11-03 12:42:11 -04:00
David Vanderson
27f4114513 demo: add paned example to layout 2023-11-02 15:59:48 -04:00
David Vanderson
026e84bb8f refresh: can now call from any thread
Demo includes examples of showing a dialog/toast from a background
thread.

Adding a dialog/toast from a separate thread will automatically refresh.
2023-11-02 15:05:56 -04:00
David Vanderson
5377f8324c SDLBackend: disable using SDL_GetDisplayDPI
Seems like this wasn't helping, so we'll try without it for now.
2023-11-01 19:46:43 -04:00
David Vanderson
551397a014 SDLBackend: set hint using string so we compile with SDL < 2.24 2023-11-01 19:46:03 -04:00
David Vanderson
572f53a913 SDLBackend: set hint for dpi scaling on windows 2023-11-01 19:10:13 -04:00
David Vanderson
a2eb0b4333 dpi: add a linux-only call to "xrdb -get Xft.dpi"
If we get back a value, it takes precendence over calling
SDL_GetDisplayDPI.  Hopefully this helps more people with scaling
issues.
2023-11-01 14:38:59 -04:00
David Vanderson
6e9033f1f1 labelClick: a label that is clickable (thanks r4gus)
Also added openURL to dvui and the SDLBackend.

The combination is useful for making hyperlinks.
2023-10-31 23:12:32 -04:00
David Vanderson
87911fc144 stb_image: better failure messages 2023-10-31 22:05:46 -04:00
David Vanderson
1e29fc82ec examples: render zig favicon at natural size (thanks iacore)
This means it will look "pixel perfect" by default.  This is also better
because the example code now shows how to query the size of an image.
2023-10-31 21:49:59 -04:00
David Vanderson
2ad76daf2b build.zig: comments about freetype and stb_image 2023-10-31 15:34:17 -04:00
David Vanderson
fb2748de13 followup to cc.tvg - actually add the new file 2023-10-31 15:27:10 -04:00
David Vanderson
ce2609b339 move stb_image to separate repo (compat with zig 0.11.x) 2023-10-31 15:26:44 -04:00
David Vanderson
a67b12d9c4 icons: add entypo.cc (clockwise arrow)
The original entypo cc.svg didn't convert and looked very strange
compared to the ccw.svg.  I manually mirrored ccw.svg to produce a
working cc.svg that converted into tvg.

Also examples now have buttons to adjust size/rotation of the icons and
images
2023-10-31 14:45:57 -04:00
David Vanderson
67967549b4 scrollbar: remove default expand
This removes the last default expand, so now you always know that
everything defaults to expand .none
2023-10-31 14:03:35 -04:00
David Vanderson
78b994e86b menuItem: don't default expand to horizontal anymore
I did that under the assumption that menus would largely be vertical.
Now I think having a default expand that's not .none is a mistake.  It's
too hard to remember which things have which defaults.
2023-10-31 14:00:11 -04:00
David Vanderson
6b1adf4ff8 clean up some raster image debug stuff 2023-10-31 13:59:49 -04:00
David Vanderson
a3284dbdba add raster image support via stb_image 2023-10-31 13:18:43 -04:00
David Vanderson
f5a4a968ff buttonIcon: remove explicit width arg in favor of min_size_content
It now will directly pass min_size_content into the icon, which
determines width from height, so passing .min_size_content = .{.h = 20}
is enough.
2023-10-30 15:19:48 -04:00
David Vanderson
a7b6b64b5f sdl-test: add some testing code that creates many subwindows 2023-10-30 14:26:14 -04:00
David Vanderson
267ac39a30 adjust our frame overhead estimate faster
When you use beginWait()/waitTime() so that dvui manages the framerate
for you, it maintains an estimate of how much time is spent outside of
dvui's begin/end.

This estimate is used as part of what waitTime() returns to more
accurately hit timer deadlines. The estimate is only updated when we are
trying to wait for a timer and are not woken by an event.

Previously this estimate (in microseconds) was adjusted by how many
frames we had been adjusting it in the same direction.

Now we adjust it by 2^number of frames.  This should reduce the amount
of frames it takes for the estimate to find the "true" value.

Also show the internal estimate in the clock example.
2023-10-30 14:20:48 -04:00
David Vanderson
0374a896e1 debug: add src and id params to refresh()
The debug window got a new button that toggles whether refresh logs who
is calling it.

These helped me figure out where a spurious refresh was coming from.

In my case, the fps labels were changing size (because fps went from 10
to 9), and any widget that changes its minimum size triggers a refresh.

One solution is to pad the text.  Another is to specify a
min_size_content width.
2023-10-30 14:06:44 -04:00
David Vanderson
028ff57130 add Alignment and use it to clean up textEntry examples
This shows a way to visually left align widgets.
2023-10-30 12:30:33 -04:00
David Vanderson
4d73f54aea examples: move text entry stuff into it's own section 2023-10-30 11:28:40 -04:00
David Vanderson
1b98bb99d1 raiseSubwindow: add some comments after testing 2023-10-26 21:14:35 -04:00
David Vanderson
4c22eec7a3 pathAddArc: lower error from 1.0 to 0.1
This eliminates the shimmer that the spinner used to have.  Hopefully
this improves arcs across the board.
2023-10-26 20:53:22 -04:00
David Vanderson
ed71df9d73 dataSet/Get: add debug code to prevent type mismatches
If compiling in Debug or ReleaseSafe modes, we now save the typeName in
dataSet, and check that against the type given to dataGet.

Also includes some fixes to textLayout that were revealed by this.
2023-10-25 22:34:11 -04:00
David Vanderson
0f3ca509ea slider: fix dragging regression
slider now maintains it's mouse capture so you can click-drag on it
2023-10-25 20:59:11 -04:00
David Vanderson
ae758393c3 SDLBackend: inspect some env vars for content scale
* QT_AUTO_SCREEN_SCALE_FACTOR - if 0 we won't guess content scale from
  SDL2's dpi

* QT_SCALE_FACTOR - force content scale
* GDK_SCALE - force content scale

Hopefully these help improve the default content scale for some people.
2023-10-22 14:27:03 -04:00
AnErrupTion
c36b14c46c
Split Options, small refactoring
Signed-off-by: AnErrupTion <anerruption@disroot.org>
2023-10-22 11:32:15 +02:00
AnErrupTion
9bd943e53d
Split ScrollInfo, small refactoring
Signed-off-by: AnErrupTion <anerruption@disroot.org>
2023-10-22 10:31:18 +02:00
David Vanderson
dc2414fe7a floating window positioning fix, also fix losing the focused window 2023-10-20 14:08:20 -04:00
David Vanderson
905225cb4b floatingWindow: center on previously focused window
* Heuristically this seems to work.  Generally the new windows show up
  where the user us currently interacting.

* Also we nudge the new window downright if it's directly on top of
  either the previously focused window or the previously highest.  This
  helps prevent duplicate error alerts from exactly overlapping.

* .window_avoid = .nudge continues to nudge the window until it's no
  longer above any other window (but may still do so at the bottom right
  of the screen)

* For custom placement, after FloatingWindowWidget.init(), user code can
  modify the widget's rect (probably only want to do so if the rect has
  width/height, because it's zero-sized on the first frame)
2023-10-19 19:11:16 -04:00