April Summary

Bold is a fast text editor. You can find details on the home page.

This is the first month of the rewrite, so there was a lot of setup. I started by customizing my build system, writing code to create screenshots, implementing a light and dark theme, and finally a util to generate settings from a config file. I knew if I didn't have an easy way to load and set default settings, I'd have a lot of hardcoded values.

Once that was out of the way, I worked on the GUI system. I have no idea how it should be implemented and I wrote a prototype at the start of the year to get ideas. When I looked online I saw

  1. How to create GUI (for a webpage or app)
  2. How a DOM GUI is implemented (closer but not what I want)
  3. Articles about immediate mode gui where there was a lot of hardcoded logic and I needed to manage a lot of state on the client side.

I wanted something that could figure out the sizes of the UI, spacing between them, and manage some state for me. None of the articles had that so I guess I'll need to figure this out on my own. Here's what I got working so far. I had one prototype (I spent <2 weeks on it) before I started the rewrite so this is my second attempt at UI.

None of the x's and y's are hardcoded in this image. You can see the debug buttons are centered with some text around it. The menu and window buttons are at the corners. My mouse isn't visible but it's over the "View" menu which you can see is highlighted. Below is how the right-click menu will look once I implement the logic.

The GUI needs more polish. One problem is highlighting of the active menu items and the padding around them. Another are the icons, it doesn't look aligned with the text. The tricky part is knowing how high the icons should be when font size and icon size can be changed independently.

An unexpected problem was pixel densities. I had code to simulate different pixel densities but it wasn't enough, I regularly had to test different pixel density because it was easy to forget to divide something or to accidentally do it more than once, especially when the gui is a work in progress. There were moments where it looked right on the density I was testing on.

Background Task and Threads

The second thing that took considerable effort was threads. I've written a few apps with threads, I knew enough that I should have a single and multi-threaded build, but this time my mistake was tying multi-threaded builds to GUI builds. It's early enough that it took maybe 30min of work to decouple them.

I made a small mistake at the start of writing an event system. I suspected that I should define every event as a struct but since I had no idea what my events would be I used a 32byte object with pointers, floats, and ints. Generic vars that all events used. It was extremely annoying to change events because I had to look up the order of the params every time. Towards the end of the month, I defined a struct for the events I changed, but not the others since I didn't know if I'd keep them. That made events a lot easier.

Avoiding shared objects and locks was successful but I did need to clone some objects. I wanted to avoid copying since I thought that would lead to bad habits, but whenever it came up the objects would be small, like 128 byte or less. The events were not frequent, like whenever a folder is loaded. That's not much copying. I'm not sure if there were more mistakes around threads, background tasks, or events but I'm sure I'll run into them in the next 2 months.

Not one line of text editing has been written. I implemented that in the beta and understand it well. I may implement it soon since this is a text editor and I don't want to go too long without it.

I'll have a summary every month. If you like you can come back next week for the weekly update.