Commit graph

3163 commits

Author SHA1 Message Date
Andreas Kling
d9d13f2445 AK: Support case-insensitive HashMap<String, T>.
We achieve this by allowing you to specify custom traits for the key type.
For convenience, we also provide a CaseInsensitiveStringTraits for String.
2019-07-13 11:00:29 +02:00
Andreas Kling
b425de18cc LibGUI: Add an auto-repeat interval to GAbstractButton.
Use this in GSpinBox to implement auto-increment / auto-decrement while you
are pressing down the respective buttons. :^)
2019-07-13 10:27:19 +02:00
Andreas Kling
c53f6a52e0 LibC: Fix make target dependency that was breaking parallel make sometimes. 2019-07-13 08:09:53 +02:00
Robin Burchell
6c4024c04a Kernel: First cut of a sb16 driver
Also add an AudioServer that (right now) doesn't do much.
It tries to open, parse, and play a wav file. In the future, it can do more.

My general thinking here here is that /dev/audio will be "owned" by AudioServer,
and we'll do mixing in software before passing buffers off to the kernel
to play, but we have to start somewhere.
2019-07-13 08:00:24 +02:00
Andreas Kling
6e671f78a8 Painter: Don't add line spacing after the very last line in draw_text().
This means that single-line draw_text() calls don't get any additional line
spacing added. Which makes things look right.
2019-07-12 19:54:10 +02:00
Andreas Kling
33466aba65 HelloWorld: Make the demo label say "Hello\nWorld!".
This is really just to show off multi-line GLabels :^)
2019-07-12 19:54:10 +02:00
Andreas Kling
ae6615d5a0 Painter: Implement multi-line support in Painter::draw_text().
This patch makes it possible to draw_text() things like "ABC\nDEF\nGHI".
It works by breaking the string into lines, then computing a bounding rect
for all the lines, and finally aligning each line appropriately within
the bounding rect and drawing them one by one.

Fixes #297.
2019-07-12 19:53:56 +02:00
Robin Burchell
8a1a9e78d7 WSWindowManager: Ensure that we pick a single window to deliver a full stream of events to
This is effectively a mouse grab except that we don't require any client
coordination to request it (which is probably OK, and certainly a lot
simpler to implement).

This prevents e.g. dragging the mouse cursor out of paint and over the
terminal from selecting text unexpectedly.
2019-07-12 18:19:45 +02:00
Andreas Kling
d0a2668833 TextEditor: Fix build (copy_ref() in outdated PR changes.) 2019-07-11 21:30:49 +02:00
Rhin
d7b836858e TextEditor: Move the application UI into a dedicated TextEditorWidget. (#292)
Added a main widget for the text editor as a stepping stone to add new features.
2019-07-11 20:52:33 +02:00
Andreas Kling
2dc0ea1cf9 FontEditor: Initial port to using a VisualBuilder generated UI.
Here goes the first attempt at using VisualBuilder to make an application.

There are many features missing that we are gonna have to implement,
noticeably custom widgets (for the glyph editor and glyph map widgets)
but this patch already moves most of the UI layout to a form file. :^)
2019-07-11 20:19:26 +02:00
Andreas Kling
974c0f97b8 GGroupBox: Allow constructing these without an initial text. 2019-07-11 20:16:34 +02:00
Andreas Kling
25e3d46502 AK: Delete bad pointer assignment operators and constructors.
We shouldn't allow constructing e.g an OwnPtr from a RefPtr, and similar
conversions. Instead just delete those functions so the compiler whines
loudly if you try to use them.

This patch also deletes constructing OwnPtr from a WeakPtr, even though
that *may* be a valid thing to do, it's sufficiently weird that we can
make the client jump through some hoops if he really wants it. :^)
2019-07-11 16:50:30 +02:00
Lawrence Manning
01998a10e3 GSlider: Make the knob width proportional to the range, if in that mode (#288)
Regardless of mode, made the knob container clickable so the knob position
can be moved without dragging the knob itself.

Added a 3rd GSlider to the WidgetGallery showing the proportional mode in
action.
2019-07-11 16:31:43 +02:00
Andreas Kling
eb64a4ca60 AK: Remove copy_ref().
This patch removes copy_ref() from RefPtr and NonnullRefPtr. This means that
it's now okay to simply copy these smart pointers instead:

- RefPtr = RefPtr // Okay!
- RefPtr = NonnullRefPtr // Okay!
- NonnullRefPtr = NonnullRefPtr // Okay!
- NonnullRefPtr = RefPtr // Not okay, since RefPtr can be null.
2019-07-11 16:05:51 +02:00
Andreas Kling
323704c851 TextEditor: Remove use of copy_ref(). 2019-07-11 16:04:53 +02:00
Andreas Kling
a35dc10f54 ProcessManager: Remove use of copy_ref(). 2019-07-11 16:04:17 +02:00
Andreas Kling
6382c14faf IRCClient: Remove use of copy_ref(). 2019-07-11 16:03:54 +02:00
Andreas Kling
433b6678c6 FontEditor: Remove use of copy_ref(). 2019-07-11 16:02:55 +02:00
Andreas Kling
b522e3cc05 GWidget: Make set_font() take either Font* or Font&. 2019-07-11 16:02:39 +02:00
Andreas Kling
c0742e4c23 FileManager: Remove use of copy_ref(). 2019-07-11 15:59:06 +02:00
Andreas Kling
7faf878e0a GToolBar: Make add_action() take a GAction& instead of NonnullRefPtr&&.
There's very little reason to take NonnullRefPtr&& in arguments really.
You can avoid ref-count churn in the cases where ownership is transferred
from the caller to the callee, but that's a pretty unusual situation and
not worth optimizing for at this stage.
2019-07-11 15:57:29 +02:00
Andreas Kling
8327b12291 Minesweeper: Remove use of copy_ref(). 2019-07-11 15:53:01 +02:00
Andreas Kling
22528d8db3 GLabel: Make set_icon() take a GraphicsBitmap*.
Taking a RefPtr<GraphicsBitmap>&& was just making things unnecessarily
complicated for clients, and didn't actually improve anything.
2019-07-11 15:52:15 +02:00
Andreas Kling
992272761c LibGUI: Remove use of copy_ref(). 2019-07-11 15:49:47 +02:00
Andreas Kling
b0372883ff AK: Remove use of copy_ref(). 2019-07-11 15:45:11 +02:00
Andreas Kling
5254a320d8 Kernel: Remove use of copy_ref() in favor of regular RefPtr copies.
This is obviously more readable. If we ever run into a situation where
ref count churn is actually causing trouble in the future, we can deal with
it then. For now, let's keep it simple. :^)
2019-07-11 15:40:04 +02:00
Andreas Kling
560d037c41 AK: Make it more more pleasant to copy RefPtr's.
I had a silly ambition that we would avoid unnecessary ref count churn by
forcing explicit use of "copy_ref()" wherever a copy was actually needed.
This was making RefPtr a bit clunky to work with, for no real benefit.

This patch adds the missing copy construction/assignment stuff to RefPtr.
2019-07-11 15:38:38 +02:00
Andreas Kling
32fb7ecef4 AK: Remove weird RefPtr(RefPtr&) constructor. 2019-07-11 15:19:16 +02:00
Andreas Kling
3d9f783e31 AK: Make MappedFile non-copyable. 2019-07-11 15:14:30 +02:00
Andreas Kling
6534f5f083 AK: Remove weird NonnullRefPtr(NonnullRefPtr&) constructor. 2019-07-11 14:28:29 +02:00
Robin Burchell
bee39d8524 AK: Use operator== for comparison in Vector::contains_slow 2019-07-11 14:17:37 +02:00
Robin Burchell
2c4af740c7 AK: Add operator== & operator!= to Vector 2019-07-11 14:17:37 +02:00
Lawrence Manning
c3ecf753b2 AKString: add missing comparison operators
And some trivial tests.
2019-07-11 14:13:30 +02:00
Andreas Kling
26956db5ac Travis: Try to install a modern C++ compiler for host compilations.
It seems like the newest Ubuntu supported by Travis is 16.04. The bundled
gcc is unable to compile the trendy and modern Serenity code, so let's try
to install a newer GCC on the CI bot. :^)
2019-07-10 22:03:46 +02:00
Andreas Kling
9c6fe21b49 FormCompiler: Build individual compilation units instead of all-at-a-time. 2019-07-10 21:28:04 +02:00
Andreas Kling
f07649faba Build: Build the host-side FormCompiler before everything else.
Since we're gonna want to use this for building other apps, it should be
the very first thing we build.
2019-07-10 21:22:27 +02:00
Andreas Kling
3eb6a9a286 FormCompiler: Produce a C++ header file as output.
Also make sure the generated main widget has autofill turned on.
2019-07-10 21:14:25 +02:00
Andreas Kling
0bf5c6fa3a Demos: Add a HelloWorld2 demo.
This is a simple test app with its UI generated from a VisualBuilder form.
The name is probably silly, but who cares. :^)
2019-07-10 21:13:29 +02:00
Andreas Kling
b3d431e390 GWidget: Add "set_autofill" as an alias for set_fill_with_background_color. 2019-07-10 21:12:09 +02:00
Andreas Kling
f465de8f76 GWidget: Add placeholder setters for the backcolor/forecolor properties. 2019-07-10 21:00:34 +02:00
Andreas Kling
8d67aa1e59 FormCompiler: Generate a basic UI skeleton holder struct.
The basic idea is that you would use it like this:

MyWidget::MyWidget(GWidget* parent)
    : GWidget(parent)
{
    m_ui = new UI_MyWidget;
    set_main_widget(m_ui->main_widget);
    ...
}
2019-07-10 20:58:54 +02:00
Andreas Kling
2d3293dfbd FormCompiler: Start working on a C++ code generator for VisualBuilder forms. 2019-07-10 20:41:31 +02:00
Andreas Kling
69fea8d41d VisualBuilder: Expose the "name" property on all widgets. 2019-07-10 20:34:17 +02:00
Andreas Kling
b06d2c04dc CObject: Add a "name" property.
This will be useful for things like the VisualBuilder code generator.
2019-07-10 20:33:53 +02:00
Andreas Kling
c33766f039 LibCore: Tweak slightly-off error message in CProcessStatisticsReader. 2019-07-10 15:32:30 +02:00
Andreas Kling
245ae479eb ProcessManager: Use CProcessStatisticsReader to get process data.
It was silly to duplicate this functionality in so many places. Now everyone
uses CProcessStatisticsReader to parse /proc/all :^)
2019-07-10 15:27:52 +02:00
Andreas Kling
64d9b43734 WindowServer: Use CProcessStatisticsReader in WSCPUMonitor. 2019-07-10 15:22:44 +02:00
Andreas Kling
ea6363c540 top: Remove some unused code. 2019-07-10 15:22:42 +02:00
Andreas Kling
01216f3c3f Userland+LibCore: Use CProcessStatisticsReader to implement top.
Also tweaked CProcessStatisticsReader a bit to simplify the API.
2019-07-10 13:56:28 +02:00