Commit graph

1244 commits

Author SHA1 Message Date
Andreas Kling
bdff88d8d5 LibGUI: Make the LinkLabel widget keyboard-friendly
Make it tab-focusable and activate it with the return key. :^)
2020-12-26 16:09:02 +01:00
Andreas Kling
7babe5ade6 LibGUI: Set LinkLabel tooltip if text can't fit the widget
We were setting a tooltip when the text overflowed the *window* width,
make this more general by basing it on the *widget* width.
2020-12-26 13:17:57 +01:00
Andreas Kling
4e084793df LibGUI: Tweak GUI::Label API a bit and add did_change_text() virtual 2020-12-26 13:11:43 +01:00
Andreas Kling
9fe310c470 LibGUI: Minor tweaks to the GUI::LinkLabel
Remove some unnecessary includes and make the constructor private.
2020-12-26 13:07:53 +01:00
Andreas Kling
5452c8a566 LibGUI: Rename Link => LinkLabel 2020-12-26 13:03:38 +01:00
Sahan Fernando
d780e2265d LibC: Fix some incorrect printf usages 2020-12-26 10:05:50 +01:00
Alex McGrath
9014d300ed LibGUI: Add a Link widget
This is a widget that can represent a link, its underlined and has an
onclick action
2020-12-24 21:52:02 +01:00
Andreas Kling
ab549cf942 LibGUI+TextEditor+HackStudio: Add GML syntax highlighter :^) 2020-12-21 18:26:18 +01:00
Andreas Kling
3d3084f088 LibGUi: Rework GML parser into a lexer+parser
This will make it easier to add GML syntax highlighting. :^)
2020-12-21 18:26:18 +01:00
Andreas Kling
09e069bc0b LibGUI: Soft tab expansion should be based on insertion column
We were using the line length as the column, which worked as long as
you were at the end of the line, but not so well otherwise. :^)
2020-12-21 09:26:31 +01:00
William Marlow
d16eabed06 LibGUI: Get executable file icons from PNGs stored in ELF sections.
If an ELF application contains sections called "serenity_icon_s"
or "serenity_icon_m" then parse these as PNG images and use them
for the 16x16 and 32x32 executable file icons respectively.

If the application is not an ELF binary, the sections do not
exist, the sections are not valid PNGs, or the file cannot be read
then the default application icon will be used.
2020-12-21 00:12:59 +01:00
Lenny Maiorani
765936ebae
Everywhere: Switch from (void) to [[maybe_unused]] (#4473)
Problem:
- `(void)` simply casts the expression to void. This is understood to
  indicate that it is ignored, but this is really a compiler trick to
  get the compiler to not generate a warning.

Solution:
- Use the `[[maybe_unused]]` attribute to indicate the value is unused.

Note:
- Functions taking a `(void)` argument list have also been changed to
  `()` because this is not needed and shows up in the same grep
  command.
2020-12-21 00:09:48 +01:00
Andreas Kling
6e0976d858 LibGUI: Make the GML parser a bit more fault-tolerant
It will now fail and whine in the debug log instead of asserting.
2020-12-20 14:30:40 +01:00
Andreas Kling
64ba41ea13 LibGUI: Make GUI::Label auto-sizing declarative
You can now set the "autosize" property on a GUI::Label and it will
automatically update its width preference to fit the text.
2020-12-20 12:36:32 +01:00
Andreas Kling
de08e7b8c9 LibGUI: Rename ProgressBar property caption => text and expose to GML 2020-12-20 12:29:40 +01:00
Andreas Kling
48b0f4844b LibGUI: Add a couple more Widget registrations
Make it possible to instantiate BreadcrumbBar, ProgressBar and TreeView
from GML. :^)
2020-12-20 12:15:49 +01:00
Andreas Kling
822dc56ef3 LibGUI: Introduce GML - a simple GUI Markup Language :^)
This patch replaces the UI-from-JSON mechanism with a more
human-friendly DSL.

The current implementation simply converts the GML into a JSON object
that can be consumed by GUI::Widget::load_from_json(). The parser is
not very helpful if you make a mistake.

The language offers a very simple way to instantiate any registered
Core::Object class by simply saying @ClassName

@GUI::Label {
    text: "Hello friends!"
    tooltip: ":^)"
}

Layouts are Core::Objects and can be assigned to the "layout" property:

@GUI::Widget {
    layout: @GUI::VerticalBoxLayout {
        spacing: 2
        margins: [8, 8, 8, 8]
    }
}

And finally, child objects are simply nested within their parent:

@GUI::Widget {
    layout: @GUI::HorizontalBoxLayout {
    }
    @GUI::Button {
        text: "OK"
    }
    @GUI::Button {
        text: "Cancel"
    }
}

This feels a *lot* more pleasant to write than the JSON we had. The fact
that no new code was being written with the JSON mechanism was pretty
telling, so let's approach this with developer convenience in mind. :^)
2020-12-20 11:59:40 +01:00
Linus Groh
fe88f46bc9 LibGUI: Don't assume main widget exists in Window::handle_resize_event()
Just like the other event handler functions, handle_resize_event()
shouldn't assume that the window has a main widget (which is being
resized in this case).

Fixes #4450.
2020-12-18 19:20:15 +01:00
Sahan Fernando
8dc0d9b7b7 LibGUI: Make autoformatting performed on InsertTextCommand visible to on_edit_action 2020-12-18 16:25:42 +01:00
Andreas Kling
598efa60a3 LibGUI: Table views with SelectRows should scroll entire rows into view 2020-12-17 00:54:58 +01:00
Andreas Kling
f0138fcb25 LibGUI: Move selection behavior from TableView up to AbstractView
Let's make SelectionBehavior a view concept where views can either
select individual items (row, index) or whole rows. Maybe some day
we'll do whole columns, but I don't think we need that now.
2020-12-17 00:54:58 +01:00
Andreas Kling
226ac8a47b LibGUI: Don't fill IconView item text background unless actually wanted
We were always filling the rect behind item texts, even when the widget
had fill_with_background_color() == false.
2020-12-16 19:39:26 +01:00
Andreas Kling
4236127fb9 LibGUI: Make the IconView cursor rect show up on the desktop
It was getting lost in some bogus coordinate conversion math while
trying to constrain unusually long item texts.
2020-12-16 19:39:26 +01:00
Andreas Kling
50aab509ce LibGUI: Add ScrollableWidget helpers for rect conversion
to_content_rect() and to_widget_rect() help you convert rects from one
coordinate space to the other.
2020-12-16 19:39:26 +01:00
Andreas Kling
2759d518b7 FileManager+LibGUI: Draw the item text for desktop icons with shadow
This makes it look nice regardless of wallpaper or background color.
2020-12-16 12:16:14 +01:00
Andreas Kling
0fef901513 LibGUI: Show app icons for executables with associated .af files
This is a rather ugly hack just to get app icons to show up in the
FileManager. It would be a lot nicer to embed icons in executables
instead but it's not obvious to me how to do that.
2020-12-16 12:08:55 +01:00
Andreas Kling
c44dbabda1 LibGUI: Generate nicer icons for symlinked files
Instead of symlinks showing up with the "filetype-symlink" icon, we now
generate a new icon by taking the target file's icon and slapping a
small arrow emblem on top of it.

This looks rather nice. :^)
2020-12-16 12:08:48 +01:00
Andreas Kling
3d5e30a1e6 LibGUI: Add GUI::Icon::sizes()
This gives you a Vector<int> with all the sizes contained in the Icon.
2020-12-16 11:53:23 +01:00
Itamar
efe4da57df Loader: Stabilize loader & Use shared libraries everywhere :^)
The dynamic loader is now stable enough to be used everywhere in the
system - so this commit does just that.
No More .a Files, Long Live .so's!
2020-12-14 23:05:53 +01:00
Andreas Kling
396b09a1ec LibGUI: Don't focus BreadcrumbBar segments on click 2020-12-14 21:44:03 +01:00
Andreas Kling
818f7777c8 LibGUI: Add a basic BreadcrumbBar widget! :^)
This can be used to implement segmented path bars in FileManager and
wherever else wanted.
2020-12-14 20:43:42 +01:00
Andreas Kling
b00a347ac5 LibGUI: Protect GUI::Button across firing the on_click hook
If a hook triggers the deletion of the GUI::Button, we would be unable
to proceed in a well-defined manner here, so let's protect ourselves.

This probably needs to be done in a whole lot of places, since GUI
widgets are just ref-counted Core::Objects and running arbitrary code
can mean that they get deleted.
2020-12-14 20:43:42 +01:00
Andreas Kling
3ee5694e97 LibGUI: Simplify ComboBox/TextEditor relationship a bit
Instead of TextEditor knowing about the ComboBox button on the right
hand side, we now make ComboBox inherit from GUI::Frame, and make the
inner text editor widget frameless.

This allows us to place the button ourselves inside ComboBox without
any frame artifacts, and TextEditor no longer needs to keep track of
the geometry of that button.
2020-12-13 11:49:18 +01:00
Zac
dea399ff08 FileManager: focus_dependent_delete_action is correctly enabled/disabled
The focus_dependent_delete_action that sits in the file manager's
toolbar would always remain enabled, even if nothing was selected,
activating it if nothing was selected would then crash the application.

The action is now correctly enabled/disabled, but due to the way
selection works in TreeViews, something is always selected, what really
matters is if the TreeView has something selected, and it has focus.
As it currently stands, there is no way to know when the TreeView's
is_focused status changes. In order for this to work I added a callback
to the Widget class which fires when a widget receives or looses focus.
In that callback, the focus_dependent_delete_action's enabled value is
recalculated.
2020-12-11 09:36:44 +01:00
Sahan Fernando
8e1bda0e9d LibGUI: Show action shortcut in ToolBarButton tooltip 2020-12-09 15:00:34 +01:00
Ben Wiederhake
6c2ea4c4e9 Clipboard: Remove-unused bpp metadata
It's just more attack surface, and can be deduced from the format anyway.
2020-12-08 09:37:30 +01:00
Andreas Kling
ab289e183e LibGUI: Expose widget focus policy as a Core::Object property
This makes focus policies show up in the inspector which is helpful.
2020-12-07 19:46:34 +01:00
Linus Groh
886fe7e69f LibGUI: Allow GUI::Action to swallow key events when disabled
Sometimes an action should be disabled and the KeyEvent not posted to
the app's event loop nonetheless. In other words the action swallows the
KeyEvent without being activated.

Specific use-case: Terminal's Ctrl+Shift+{C,V}.
2020-12-07 15:55:12 +01:00
Sahan Fernando
4062add8ed LibGUI: Optimize GUI::Variant move constructor 2020-12-03 21:53:29 +01:00
Tom
f68115aba3 Taskbar: Wait on all waitable children in SIGCHLD handler
We need to call waitpid until no more waitable children are available.
This is necessary because SIGCHLD signals may coalesce into one when
multiple children terminate almost simultaneously.

Also, switch to EventLoop's asynchronous signal handling mechanism,
which allows more complex operations in the signal handler.
2020-12-02 12:57:25 +01:00
AnotherTest
169beff21e LibGUI: Add a ModelSelection::add_all(Vector) API
Using add() is very slow due to the change notifications.
2020-11-30 12:07:45 +01:00
AnotherTest
b66f3166cb LibGUI: Throw less view state away in model_did_update()
When `DontInvalidIndexes` is passed, be optimistic and keep the old
indices when the model validates them.
This is currently fine, as the group of models that use
DontInvalidateIndexes use it as "The old indices are still ok" (there's
a note about this in ProcessModel.cpp).
2020-11-30 12:07:45 +01:00
AnotherTest
c84756efa8 LibGUI: Don't start editing with (just) modifier keys when AnyKeyPressed
This fixes the control key starting an edit on (and inserting a nul
character into) a cell in Spreadsheet.
2020-11-30 12:07:45 +01:00
AnotherTest
71de8b7480 LibGUI: Remove `AbstractView::did_update_model()'
...and use `ModelClient::model_did_update()' instead.
This makes AbstractView a ModelClient (which it always was anyway).
2020-11-30 12:07:45 +01:00
Linus Groh
d66087ac2f LibGUI/FileIconProvider: Initialize s_filetype_image_icon
This was accidentally removed in 1c90321.
Fixes #4125.
2020-11-28 17:16:33 +01:00
Andreas Kling
1abda05d38 LibGUI: Make GUI::Dialogs non-minimizable by default 2020-11-28 10:26:05 +01:00
Andreas Kling
005afa4c6e LibGUI: Don't assert when right clicking on a vertical HeaderView
Just log a debug message instead. We still need to actually implement
vertical header context menus, but for now let's at least not crash.
2020-11-28 10:26:05 +01:00
Emanuel Sprung
3b7884ee8a TextEditor: Add button to match regular expression during search 2020-11-27 21:32:41 +01:00
Zac
018eff802b
LibGUI: Remove redundant set_title() call in FilePicker (#4153) 2020-11-24 18:41:44 +01:00
Jakub Berkop
c6bb3d452a
LibGUI: Widget::action_for_key_event() should fail for invalid shortcuts (#4137)
Previously GUI::Actions which were constructed without initializing
m_shortcut could be activated via an invalid GUI::Shortcut.

Steps to reproduce:
It was possible to enable TextEditor's markdown preview by pressing
Ctrl or Alt (Cmd/Ctrl) keys, which should not happen, as this Action
did not specify a shortcut.

This fix should apply to all other cases where actions where declared
without specifying a shortcut.
2020-11-23 18:41:15 +01:00