Skip to content

Instantly share code, notes, and snippets.

@toger5
toger5 / main.rs
Last active October 5, 2020 17:30
rust user not updating issue
...
let user: Rc<RefCell<Option<mpw::User>>> = Rc::new(RefCell::new(None));
...
// PASSWORD UI connections
{
let pwd_win = pwd_window.clone();
let m_k = master_key.clone();
@toger5
toger5 / config
Created November 19, 2019 00:30
Waybar Config Toger
{
"layer": "top", // Waybar at top layer
"position": "bottom", // Waybar position (top|bottom|left|right)
"height": 32, // Waybar height
// "width": 120, // Waybar width
// Choose the order of the modules
"modules-left": ["sway/workspaces", "sway/mode", "custom/media"],
"modules-center": ["sway/window"],
"modules-right": ["tray","pulseaudio", "network", "cpu", "memory", "temperature", "backlight", "battery", "battery#bat2", "clock"],
// Modules configuration

Implementation of dpi adaption in Godot

The theme is the master class that gets asked for style boxes, constants and fonts all the time. The theme is asked multiple times per node and hundreds of times a frame.

It's that simple. However, there is one great additional thing in Godot which makes the dpi addition easy to implement. There are two ways of accessing values in a theme. theme->get_styebox() and my_control->get_stylebox().

  • When asking the theme, it just calls the hash map with styles, and that's it.
  • When asking a control, it does some logic:
    1. font (cached) the next node up to the tree that has a theme assigned.
  1. check if the theme has the requested style. Yes: return it! No: go to the next Control with a theme.

Theme Refactoring and Computed_Properties

Godots theming system is very simple. It is still a game engine. Styleboxes are assigend to different states of Control-Nodes. There is no cascading, no shared variables. This makes it very easy to understand, and results in very little complexity. But also comes with a cost. Setting up themes is super tidious. For examle a color change requires you to update hundreds of values.

It is the Goal to desing a theme editor, which will generate a theme with systems, like a color palette, so that we get the best of both worlds. The simplicity of godots theming, and a advanced theming structure when setting up a theme using the theme editor. There is a big amount of freedom and creative ideas to make creating themes a pleasure, while still keeping the core architecture as simple as possible.

Editor Theme

The editor theme hides those shortcomings, by creting a new theme on each startup, and when theme settings change. A script than computes the colours, the dpi scales

  • eglBindApi(to open gl (not es)) at the beginning
  • remove getConfig (egl)
  • move egl window creating in egl context
@toger5
toger5 / Explanation.md
Last active October 22, 2018 12:13
Godot container. Examin updating.

Godot Container Events (sort)

There is an event called '"on_sort_children"' for each container object. This event is supposed to be used to get notified, when resorting is needed (in the sourcecode of godot this is used whenever the container itself is resized for example -> than the children need to get repositioned as well)

The event system in godot works by first calling the builtin functionality though. This means when the children need to be resorted, (new children added and the container needs to draw. NOT IMMEDIATLY AFTER ADDING EACH CHILD. FOR BETTER PERFORMANCE. BECAUSE 10 CHILDS CAN BE ADDED AND IT SORTS ONLY ONCE) the builtin funciton gets called first. This function actually transforms the children to the intended locations and sizes. After that the gd script signal connected functions get called. Right after the position actually got updated! Exacly where you need it :)

timo$ scons p=osx mono_glue=no module_mono_enabled=yes
scons: Reading SConscript files ...
Could not detect MinGW. Ensure its binaries are in your PATH or that MINGW32_PREFIX or MINGW64_PREFIX are properly defined.
Package mono-2 was not found in the pkg-config search path.
Perhaps you should add the directory containing `mono-2.pc'
to the PKG_CONFIG_PATH environment variable
No package 'mono-2' found
OSError: 'pkg-config mono-2 --cflags --libs' exited 1:
File "/Users/timo/Documents/Godot/_GodotDev/godot/SConstruct", line 378:
config.configure(env)