mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 20:15:17 +00:00
LibGUI: Run clang-format on everything.
This commit is contained in:
parent
bc951ca565
commit
7ad8790d80
Notes:
sideshowbarker
2024-07-19 13:41:50 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/7ad8790d803
43 changed files with 525 additions and 363 deletions
|
@ -1,5 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <AK/StdLibExtras.h>
|
||||
|
||||
namespace AK {
|
||||
|
||||
template<typename T>
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
#include <Kernel/KeyCode.h>
|
||||
#include <LibGUI/GAbstractView.h>
|
||||
#include <LibGUI/GModel.h>
|
||||
#include <LibGUI/GScrollBar.h>
|
||||
#include <LibGUI/GPainter.h>
|
||||
#include <LibGUI/GScrollBar.h>
|
||||
#include <LibGUI/GTextBox.h>
|
||||
#include <Kernel/KeyCode.h>
|
||||
|
||||
GAbstractView::GAbstractView(GWidget* parent)
|
||||
: GScrollableWidget(parent)
|
||||
|
@ -84,7 +84,7 @@ void GAbstractView::begin_editing(const GModelIndex& index)
|
|||
|
||||
void GAbstractView::stop_editing()
|
||||
{
|
||||
m_edit_index = { };
|
||||
m_edit_index = {};
|
||||
delete m_edit_widget;
|
||||
m_edit_widget = nullptr;
|
||||
}
|
||||
|
|
|
@ -29,7 +29,6 @@ GAction::GAction(const StringView& text, const GShortcut& shortcut, Function<voi
|
|||
{
|
||||
}
|
||||
|
||||
|
||||
GAction::GAction(const StringView& text, const GShortcut& shortcut, RetainPtr<GraphicsBitmap>&& icon, Function<void(GAction&)> on_activation_callback, GWidget* widget)
|
||||
: on_activation(move(on_activation_callback))
|
||||
, m_text(text)
|
||||
|
@ -99,10 +98,10 @@ void GAction::set_enabled(bool enabled)
|
|||
if (m_enabled == enabled)
|
||||
return;
|
||||
m_enabled = enabled;
|
||||
for_each_toolbar_button([enabled] (GButton& button) {
|
||||
for_each_toolbar_button([enabled](GButton& button) {
|
||||
button.set_enabled(enabled);
|
||||
});
|
||||
for_each_menu_item([enabled] (GMenuItem& item) {
|
||||
for_each_menu_item([enabled](GMenuItem& item) {
|
||||
item.set_enabled(enabled);
|
||||
});
|
||||
}
|
||||
|
@ -112,10 +111,10 @@ void GAction::set_checked(bool checked)
|
|||
if (m_checked == checked)
|
||||
return;
|
||||
m_checked = checked;
|
||||
for_each_toolbar_button([checked] (GButton& button) {
|
||||
for_each_toolbar_button([checked](GButton& button) {
|
||||
button.set_checked(checked);
|
||||
});
|
||||
for_each_menu_item([checked] (GMenuItem& item) {
|
||||
for_each_menu_item([checked](GMenuItem& item) {
|
||||
item.set_checked(checked);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
#include <LibGUI/GAction.h>
|
||||
#include <LibGUI/GApplication.h>
|
||||
#include <LibGUI/GEventLoop.h>
|
||||
#include <LibGUI/GMenuBar.h>
|
||||
#include <LibGUI/GAction.h>
|
||||
#include <LibGUI/GWindow.h>
|
||||
#include <LibGUI/GLabel.h>
|
||||
#include <LibGUI/GMenuBar.h>
|
||||
#include <LibGUI/GPainter.h>
|
||||
#include <LibGUI/GWindow.h>
|
||||
#include <WindowServer/WSAPITypes.h>
|
||||
|
||||
static GApplication* s_the;
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
#include "GButton.h"
|
||||
#include <AK/StringBuilder.h>
|
||||
#include <Kernel/KeyCode.h>
|
||||
#include <LibGUI/GAction.h>
|
||||
#include <LibGUI/GPainter.h>
|
||||
#include <SharedGraphics/StylePainter.h>
|
||||
#include <AK/StringBuilder.h>
|
||||
#include <LibGUI/GAction.h>
|
||||
#include <Kernel/KeyCode.h>
|
||||
|
||||
GButton::GButton(GWidget* parent)
|
||||
: GAbstractButton(parent)
|
||||
|
@ -18,7 +18,7 @@ GButton::GButton(const StringView& text, GWidget* parent)
|
|||
GButton::~GButton()
|
||||
{
|
||||
if (m_action)
|
||||
m_action->unregister_button({ }, *this);
|
||||
m_action->unregister_button({}, *this);
|
||||
}
|
||||
|
||||
void GButton::paint_event(GPaintEvent& event)
|
||||
|
@ -67,7 +67,7 @@ void GButton::click()
|
|||
void GButton::set_action(GAction& action)
|
||||
{
|
||||
m_action = action.make_weak_ptr();
|
||||
action.register_button({ }, *this);
|
||||
action.register_button({}, *this);
|
||||
set_enabled(action.is_enabled());
|
||||
set_checkable(action.is_checkable());
|
||||
if (action.is_checkable())
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#include <Kernel/KeyCode.h>
|
||||
#include <LibGUI/GCheckBox.h>
|
||||
#include <LibGUI/GPainter.h>
|
||||
#include <SharedGraphics/CharacterBitmap.h>
|
||||
#include <SharedGraphics/StylePainter.h>
|
||||
#include <Kernel/KeyCode.h>
|
||||
|
||||
static const char* s_checked_bitmap_data = {
|
||||
" "
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include <LibC/SharedBuffer.h>
|
||||
#include <LibGUI/GClipboard.h>
|
||||
#include <LibGUI/GEventLoop.h>
|
||||
#include <WindowServer/WSAPITypes.h>
|
||||
#include <LibC/SharedBuffer.h>
|
||||
|
||||
GClipboard& GClipboard::the()
|
||||
{
|
||||
|
@ -21,15 +21,15 @@ String GClipboard::data() const
|
|||
request.type = WSAPI_ClientMessage::Type::GetClipboardContents;
|
||||
auto response = GEventLoop::current().sync_request(request, WSAPI_ServerMessage::Type::DidGetClipboardContents);
|
||||
if (response.clipboard.shared_buffer_id < 0)
|
||||
return { };
|
||||
return {};
|
||||
auto shared_buffer = SharedBuffer::create_from_shared_buffer_id(response.clipboard.shared_buffer_id);
|
||||
if (!shared_buffer) {
|
||||
dbgprintf("GClipboard::data() failed to attach to the shared buffer\n");
|
||||
return { };
|
||||
return {};
|
||||
}
|
||||
if (response.clipboard.contents_size > shared_buffer->size()) {
|
||||
dbgprintf("GClipboard::data() clipping contents size is greater than shared buffer size\n");
|
||||
return { };
|
||||
return {};
|
||||
}
|
||||
return String((const char*)shared_buffer->data(), response.clipboard.contents_size);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include <LibGUI/GDesktop.h>
|
||||
#include <LibGUI/GDialog.h>
|
||||
#include <LibGUI/GEventLoop.h>
|
||||
#include <LibGUI/GDesktop.h>
|
||||
|
||||
GDialog::GDialog(CObject* parent)
|
||||
: GWindow(parent)
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
#include "GDirectoryModel.h"
|
||||
#include <dirent.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <grp.h>
|
||||
#include <pwd.h>
|
||||
#include <AK/FileSystemPath.h>
|
||||
#include <AK/StringBuilder.h>
|
||||
#include <SharedGraphics/GraphicsBitmap.h>
|
||||
#include <LibGUI/GPainter.h>
|
||||
#include <LibCore/CLock.h>
|
||||
#include <LibCore/CDirIterator.h>
|
||||
#include <LibCore/CLock.h>
|
||||
#include <LibGUI/GPainter.h>
|
||||
#include <SharedGraphics/GraphicsBitmap.h>
|
||||
#include <dirent.h>
|
||||
#include <grp.h>
|
||||
#include <pwd.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
static CLockable<HashMap<String, RetainPtr<GraphicsBitmap>>>& thumbnail_cache()
|
||||
{
|
||||
|
@ -94,13 +94,20 @@ int GDirectoryModel::column_count(const GModelIndex&) const
|
|||
String GDirectoryModel::column_name(int column) const
|
||||
{
|
||||
switch (column) {
|
||||
case Column::Icon: return "";
|
||||
case Column::Name: return "Name";
|
||||
case Column::Size: return "Size";
|
||||
case Column::Owner: return "Owner";
|
||||
case Column::Group: return "Group";
|
||||
case Column::Permissions: return "Mode";
|
||||
case Column::Inode: return "Inode";
|
||||
case Column::Icon:
|
||||
return "";
|
||||
case Column::Name:
|
||||
return "Name";
|
||||
case Column::Size:
|
||||
return "Size";
|
||||
case Column::Owner:
|
||||
return "Owner";
|
||||
case Column::Group:
|
||||
return "Group";
|
||||
case Column::Permissions:
|
||||
return "Mode";
|
||||
case Column::Inode:
|
||||
return "Inode";
|
||||
}
|
||||
ASSERT_NOT_REACHED();
|
||||
}
|
||||
|
@ -108,13 +115,20 @@ String GDirectoryModel::column_name(int column) const
|
|||
GModel::ColumnMetadata GDirectoryModel::column_metadata(int column) const
|
||||
{
|
||||
switch (column) {
|
||||
case Column::Icon: return { 16, TextAlignment::Center };
|
||||
case Column::Name: return { 120, TextAlignment::CenterLeft };
|
||||
case Column::Size: return { 80, TextAlignment::CenterRight };
|
||||
case Column::Owner: return { 50, TextAlignment::CenterLeft };
|
||||
case Column::Group: return { 50, TextAlignment::CenterLeft };
|
||||
case Column::Permissions: return { 80, TextAlignment::CenterLeft };
|
||||
case Column::Inode: return { 80, TextAlignment::CenterRight };
|
||||
case Column::Icon:
|
||||
return { 16, TextAlignment::Center };
|
||||
case Column::Name:
|
||||
return { 120, TextAlignment::CenterLeft };
|
||||
case Column::Size:
|
||||
return { 80, TextAlignment::CenterRight };
|
||||
case Column::Owner:
|
||||
return { 50, TextAlignment::CenterLeft };
|
||||
case Column::Group:
|
||||
return { 50, TextAlignment::CenterLeft };
|
||||
case Column::Permissions:
|
||||
return { 80, TextAlignment::CenterLeft };
|
||||
case Column::Inode:
|
||||
return { 80, TextAlignment::CenterRight };
|
||||
}
|
||||
ASSERT_NOT_REACHED();
|
||||
}
|
||||
|
@ -175,8 +189,7 @@ static String permission_string(mode_t mode)
|
|||
mode & S_IWGRP ? 'w' : '-',
|
||||
mode & S_ISGID ? 's' : (mode & S_IXGRP ? 'x' : '-'),
|
||||
mode & S_IROTH ? 'r' : '-',
|
||||
mode & S_IWOTH ? 'w' : '-'
|
||||
);
|
||||
mode & S_IWOTH ? 'w' : '-');
|
||||
|
||||
if (mode & S_ISVTX)
|
||||
builder.append("t");
|
||||
|
@ -207,31 +220,45 @@ GVariant GDirectoryModel::data(const GModelIndex& index, Role role) const
|
|||
auto& entry = this->entry(index.row());
|
||||
if (role == Role::Sort) {
|
||||
switch (index.column()) {
|
||||
case Column::Icon: return entry.is_directory() ? 0 : 1;
|
||||
case Column::Name: return entry.name;
|
||||
case Column::Size: return (int)entry.size;
|
||||
case Column::Owner: return name_for_uid(entry.uid);
|
||||
case Column::Group: return name_for_gid(entry.gid);
|
||||
case Column::Permissions: return permission_string(entry.mode);
|
||||
case Column::Inode: return (int)entry.inode;
|
||||
case Column::Icon:
|
||||
return entry.is_directory() ? 0 : 1;
|
||||
case Column::Name:
|
||||
return entry.name;
|
||||
case Column::Size:
|
||||
return (int)entry.size;
|
||||
case Column::Owner:
|
||||
return name_for_uid(entry.uid);
|
||||
case Column::Group:
|
||||
return name_for_gid(entry.gid);
|
||||
case Column::Permissions:
|
||||
return permission_string(entry.mode);
|
||||
case Column::Inode:
|
||||
return (int)entry.inode;
|
||||
}
|
||||
ASSERT_NOT_REACHED();
|
||||
}
|
||||
if (role == Role::Display) {
|
||||
switch (index.column()) {
|
||||
case Column::Icon: return icon_for(entry);
|
||||
case Column::Name: return entry.name;
|
||||
case Column::Size: return (int)entry.size;
|
||||
case Column::Owner: return name_for_uid(entry.uid);
|
||||
case Column::Group: return name_for_gid(entry.gid);
|
||||
case Column::Permissions: return permission_string(entry.mode);
|
||||
case Column::Inode: return (int)entry.inode;
|
||||
case Column::Icon:
|
||||
return icon_for(entry);
|
||||
case Column::Name:
|
||||
return entry.name;
|
||||
case Column::Size:
|
||||
return (int)entry.size;
|
||||
case Column::Owner:
|
||||
return name_for_uid(entry.uid);
|
||||
case Column::Group:
|
||||
return name_for_gid(entry.gid);
|
||||
case Column::Permissions:
|
||||
return permission_string(entry.mode);
|
||||
case Column::Inode:
|
||||
return (int)entry.inode;
|
||||
}
|
||||
}
|
||||
if (role == Role::Icon) {
|
||||
return icon_for(entry);
|
||||
}
|
||||
return { };
|
||||
return {};
|
||||
}
|
||||
|
||||
void GDirectoryModel::update()
|
||||
|
|
|
@ -1,24 +1,23 @@
|
|||
#include <LibCore/CObject.h>
|
||||
#include "GEventLoop.h"
|
||||
#include "GEvent.h"
|
||||
#include "GWindow.h"
|
||||
#include <LibGUI/GApplication.h>
|
||||
#include <LibGUI/GAction.h>
|
||||
#include <LibCore/CNotifier.h>
|
||||
#include <LibGUI/GMenu.h>
|
||||
#include <LibGUI/GDesktop.h>
|
||||
#include <LibGUI/GWidget.h>
|
||||
#include <LibC/unistd.h>
|
||||
#include <LibC/stdio.h>
|
||||
#include <LibC/errno.h>
|
||||
#include <LibC/fcntl.h>
|
||||
#include <LibC/stdio.h>
|
||||
#include <LibC/stdlib.h>
|
||||
#include <LibC/string.h>
|
||||
#include <LibC/time.h>
|
||||
#include <LibC/sys/select.h>
|
||||
#include <LibC/sys/socket.h>
|
||||
#include <LibC/sys/time.h>
|
||||
#include <LibC/errno.h>
|
||||
#include <LibC/string.h>
|
||||
#include <LibC/stdlib.h>
|
||||
#include <LibC/time.h>
|
||||
#include <LibC/unistd.h>
|
||||
#include <LibCore/CNotifier.h>
|
||||
#include <LibCore/CObject.h>
|
||||
#include <LibGUI/GAction.h>
|
||||
#include <LibGUI/GApplication.h>
|
||||
#include <LibGUI/GDesktop.h>
|
||||
#include <LibGUI/GMenu.h>
|
||||
#include <LibGUI/GWidget.h>
|
||||
#include <sys/uio.h>
|
||||
|
||||
//#define GEVENTLOOP_DEBUG
|
||||
|
@ -156,20 +155,42 @@ void GEventLoop::handle_mouse_event(const WSAPI_ServerMessage& event, GWindow& w
|
|||
#endif
|
||||
GMouseEvent::Type type;
|
||||
switch (event.type) {
|
||||
case WSAPI_ServerMessage::Type::MouseMove: type = GEvent::MouseMove; break;
|
||||
case WSAPI_ServerMessage::Type::MouseUp: type = GEvent::MouseUp; break;
|
||||
case WSAPI_ServerMessage::Type::MouseDown: type = GEvent::MouseDown; break;
|
||||
case WSAPI_ServerMessage::Type::MouseDoubleClick: type = GEvent::MouseDoubleClick; break;
|
||||
case WSAPI_ServerMessage::Type::MouseWheel: type = GEvent::MouseWheel; break;
|
||||
default: ASSERT_NOT_REACHED(); break;
|
||||
case WSAPI_ServerMessage::Type::MouseMove:
|
||||
type = GEvent::MouseMove;
|
||||
break;
|
||||
case WSAPI_ServerMessage::Type::MouseUp:
|
||||
type = GEvent::MouseUp;
|
||||
break;
|
||||
case WSAPI_ServerMessage::Type::MouseDown:
|
||||
type = GEvent::MouseDown;
|
||||
break;
|
||||
case WSAPI_ServerMessage::Type::MouseDoubleClick:
|
||||
type = GEvent::MouseDoubleClick;
|
||||
break;
|
||||
case WSAPI_ServerMessage::Type::MouseWheel:
|
||||
type = GEvent::MouseWheel;
|
||||
break;
|
||||
default:
|
||||
ASSERT_NOT_REACHED();
|
||||
break;
|
||||
}
|
||||
GMouseButton button { GMouseButton::None };
|
||||
switch (event.mouse.button) {
|
||||
case WSAPI_MouseButton::NoButton: button = GMouseButton::None; break;
|
||||
case WSAPI_MouseButton::Left: button = GMouseButton::Left; break;
|
||||
case WSAPI_MouseButton::Right: button = GMouseButton::Right; break;
|
||||
case WSAPI_MouseButton::Middle: button = GMouseButton::Middle; break;
|
||||
default: ASSERT_NOT_REACHED(); break;
|
||||
case WSAPI_MouseButton::NoButton:
|
||||
button = GMouseButton::None;
|
||||
break;
|
||||
case WSAPI_MouseButton::Left:
|
||||
button = GMouseButton::Left;
|
||||
break;
|
||||
case WSAPI_MouseButton::Right:
|
||||
button = GMouseButton::Right;
|
||||
break;
|
||||
case WSAPI_MouseButton::Middle:
|
||||
button = GMouseButton::Middle;
|
||||
break;
|
||||
default:
|
||||
ASSERT_NOT_REACHED();
|
||||
break;
|
||||
}
|
||||
post_event(window, make<GMouseEvent>(type, event.mouse.position, event.mouse.buttons, button, event.mouse.modifiers, event.mouse.wheel_delta));
|
||||
}
|
||||
|
|
|
@ -57,19 +57,19 @@ GFilePicker::GFilePicker(const StringView& path, CObject* parent)
|
|||
clear_preview();
|
||||
};
|
||||
|
||||
auto open_parent_directory_action = GAction::create("Open parent directory", { Mod_Alt, Key_Up }, GraphicsBitmap::load_from_file("/res/icons/16x16/open-parent-directory.png"), [this] (const GAction&) {
|
||||
auto open_parent_directory_action = GAction::create("Open parent directory", { Mod_Alt, Key_Up }, GraphicsBitmap::load_from_file("/res/icons/16x16/open-parent-directory.png"), [this](const GAction&) {
|
||||
m_model->open(String::format("%s/..", m_model->path().characters()));
|
||||
clear_preview();
|
||||
});
|
||||
toolbar->add_action(*open_parent_directory_action);
|
||||
|
||||
auto mkdir_action = GAction::create("New directory...", GraphicsBitmap::load_from_file("/res/icons/16x16/mkdir.png"), [this] (const GAction&) {
|
||||
auto mkdir_action = GAction::create("New directory...", GraphicsBitmap::load_from_file("/res/icons/16x16/mkdir.png"), [this](const GAction&) {
|
||||
GInputBox input_box("Enter name:", "New directory", this);
|
||||
if (input_box.exec() == GInputBox::ExecOK && !input_box.text_value().is_empty()) {
|
||||
auto new_dir_path = FileSystemPath(String::format("%s/%s",
|
||||
m_model->path().characters(),
|
||||
input_box.text_value().characters()
|
||||
)).string();
|
||||
m_model->path().characters(),
|
||||
input_box.text_value().characters()))
|
||||
.string();
|
||||
int rc = mkdir(new_dir_path.characters(), 0777);
|
||||
if (rc < 0) {
|
||||
GMessageBox::show(String::format("mkdir(\"%s\") failed: %s", new_dir_path.characters(), strerror(errno)), "Error", GMessageBox::Type::Error, this);
|
||||
|
@ -96,7 +96,7 @@ GFilePicker::GFilePicker(const StringView& path, CObject* parent)
|
|||
filename_label->set_preferred_size({ 60, 0 });
|
||||
auto* filename_textbox = new GTextBox(filename_container);
|
||||
|
||||
m_view->on_activation = [this, filename_textbox] (auto& index) {
|
||||
m_view->on_activation = [this, filename_textbox](auto& index) {
|
||||
auto& filter_model = (GSortingProxyModel&)*m_view->model();
|
||||
auto local_index = filter_model.map_to_target(index);
|
||||
const GDirectoryModel::Entry& entry = m_model->entry(local_index.row());
|
||||
|
@ -125,7 +125,7 @@ GFilePicker::GFilePicker(const StringView& path, CObject* parent)
|
|||
cancel_button->set_size_policy(SizePolicy::Fixed, SizePolicy::Fill);
|
||||
cancel_button->set_preferred_size({ 80, 0 });
|
||||
cancel_button->set_text("Cancel");
|
||||
cancel_button->on_click = [this] (auto&) {
|
||||
cancel_button->on_click = [this](auto&) {
|
||||
done(ExecCancel);
|
||||
};
|
||||
|
||||
|
@ -133,7 +133,7 @@ GFilePicker::GFilePicker(const StringView& path, CObject* parent)
|
|||
ok_button->set_size_policy(SizePolicy::Fixed, SizePolicy::Fill);
|
||||
ok_button->set_preferred_size({ 80, 0 });
|
||||
ok_button->set_text("OK");
|
||||
ok_button->on_click = [this, filename_textbox] (auto&) {
|
||||
ok_button->on_click = [this, filename_textbox](auto&) {
|
||||
FileSystemPath path(String::format("%s/%s", m_model->path().characters(), filename_textbox->text().characters()));
|
||||
m_selected_file = path;
|
||||
done(ExecOK);
|
||||
|
|
|
@ -1,17 +1,22 @@
|
|||
#include <LibGUI/GFileSystemModel.h>
|
||||
#include <LibCore/CDirIterator.h>
|
||||
#include <AK/FileSystemPath.h>
|
||||
#include <AK/StringBuilder.h>
|
||||
#include <sys/stat.h>
|
||||
#include <LibCore/CDirIterator.h>
|
||||
#include <LibGUI/GFileSystemModel.h>
|
||||
#include <dirent.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
struct GFileSystemModel::Node {
|
||||
String name;
|
||||
Node* parent { nullptr };
|
||||
Vector<Node*> children;
|
||||
enum Type { Unknown, Directory, File };
|
||||
enum Type
|
||||
{
|
||||
Unknown,
|
||||
Directory,
|
||||
File
|
||||
};
|
||||
Type type { Unknown };
|
||||
|
||||
bool has_traversed { false };
|
||||
|
@ -111,15 +116,15 @@ GModelIndex GFileSystemModel::index(const StringView& path) const
|
|||
}
|
||||
}
|
||||
if (!found)
|
||||
return { };
|
||||
return {};
|
||||
}
|
||||
return { };
|
||||
return {};
|
||||
}
|
||||
|
||||
String GFileSystemModel::path(const GModelIndex& index) const
|
||||
{
|
||||
if (!index.is_valid())
|
||||
return { };
|
||||
return {};
|
||||
auto& node = *(Node*)index.internal_data();
|
||||
node.reify_if_needed(*this);
|
||||
return node.full_path(*this);
|
||||
|
@ -172,11 +177,11 @@ GModelIndex GFileSystemModel::index(int row, int column, const GModelIndex& pare
|
|||
GModelIndex GFileSystemModel::parent_index(const GModelIndex& index) const
|
||||
{
|
||||
if (!index.is_valid())
|
||||
return { };
|
||||
return {};
|
||||
auto& node = *(const Node*)index.internal_data();
|
||||
if (!node.parent) {
|
||||
ASSERT(&node == m_root);
|
||||
return { };
|
||||
return {};
|
||||
}
|
||||
return node.parent->index(*this);
|
||||
}
|
||||
|
@ -184,7 +189,7 @@ GModelIndex GFileSystemModel::parent_index(const GModelIndex& index) const
|
|||
GVariant GFileSystemModel::data(const GModelIndex& index, Role role) const
|
||||
{
|
||||
if (!index.is_valid())
|
||||
return { };
|
||||
return {};
|
||||
auto& node = *(const Node*)index.internal_data();
|
||||
if (role == GModel::Role::Display)
|
||||
return node.name;
|
||||
|
@ -196,7 +201,7 @@ GVariant GFileSystemModel::data(const GModelIndex& index, Role role) const
|
|||
}
|
||||
return m_file_icon;
|
||||
}
|
||||
return { };
|
||||
return {};
|
||||
}
|
||||
|
||||
int GFileSystemModel::column_count(const GModelIndex&) const
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include <LibGUI/GFontDatabase.h>
|
||||
#include <LibCore/CDirIterator.h>
|
||||
#include <LibGUI/GFontDatabase.h>
|
||||
#include <SharedGraphics/Font.h>
|
||||
#include <dirent.h>
|
||||
#include <stdio.h>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include <LibGUI/GFrame.h>
|
||||
#include <SharedGraphics/StylePainter.h>
|
||||
#include <LibGUI/GPainter.h>
|
||||
#include <SharedGraphics/StylePainter.h>
|
||||
|
||||
GFrame::GFrame(GWidget* parent)
|
||||
: GWidget(parent)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include <LibGUI/GInputBox.h>
|
||||
#include <LibGUI/GBoxLayout.h>
|
||||
#include <LibGUI/GLabel.h>
|
||||
#include <LibGUI/GButton.h>
|
||||
#include <LibGUI/GInputBox.h>
|
||||
#include <LibGUI/GLabel.h>
|
||||
#include <LibGUI/GTextEditor.h>
|
||||
#include <stdio.h>
|
||||
|
||||
|
@ -55,7 +55,7 @@ void GInputBox::build()
|
|||
m_cancel_button->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
||||
m_cancel_button->set_preferred_size({ 0, 20 });
|
||||
m_cancel_button->set_text("Cancel");
|
||||
m_cancel_button->on_click = [this] (auto&) {
|
||||
m_cancel_button->on_click = [this](auto&) {
|
||||
dbgprintf("GInputBox: Cancel button clicked\n");
|
||||
done(ExecCancel);
|
||||
};
|
||||
|
@ -64,7 +64,7 @@ void GInputBox::build()
|
|||
m_ok_button->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
||||
m_ok_button->set_preferred_size({ 0, 20 });
|
||||
m_ok_button->set_text("OK");
|
||||
m_ok_button->on_click = [this] (auto&) {
|
||||
m_ok_button->on_click = [this](auto&) {
|
||||
dbgprintf("GInputBox: OK button clicked\n");
|
||||
m_text_value = m_text_editor->text();
|
||||
done(ExecOK);
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#include <Kernel/KeyCode.h>
|
||||
#include <LibGUI/GItemView.h>
|
||||
#include <LibGUI/GModel.h>
|
||||
#include <LibGUI/GScrollBar.h>
|
||||
#include <LibGUI/GPainter.h>
|
||||
#include <Kernel/KeyCode.h>
|
||||
#include <LibGUI/GScrollBar.h>
|
||||
|
||||
GItemView::GItemView(GWidget* parent)
|
||||
: GAbstractView(parent)
|
||||
|
@ -38,7 +38,7 @@ void GItemView::did_update_model()
|
|||
void GItemView::update_content_size()
|
||||
{
|
||||
if (!model())
|
||||
return set_content_size({ });
|
||||
return set_content_size({});
|
||||
|
||||
m_visual_column_count = available_size().width() / effective_item_size().width();
|
||||
if (m_visual_column_count)
|
||||
|
@ -55,7 +55,7 @@ void GItemView::update_content_size()
|
|||
Rect GItemView::item_rect(int item_index) const
|
||||
{
|
||||
if (!m_visual_row_count || !m_visual_column_count)
|
||||
return { };
|
||||
return {};
|
||||
int visual_row_index = item_index / m_visual_column_count;
|
||||
int visual_column_index = item_index % m_visual_column_count;
|
||||
return {
|
||||
|
@ -79,7 +79,7 @@ void GItemView::mousedown_event(GMouseEvent& event)
|
|||
return;
|
||||
}
|
||||
}
|
||||
model()->set_selected_index({ });
|
||||
model()->set_selected_index({});
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
@ -100,7 +100,7 @@ void GItemView::paint_event(GPaintEvent& event)
|
|||
|
||||
GPainter painter(*this);
|
||||
painter.add_clip_rect(widget_inner_rect());
|
||||
painter.add_clip_rect(event.rect());
|
||||
painter.add_clip_rect(event.rect());
|
||||
painter.fill_rect(event.rect(), Color::White);
|
||||
painter.translate(-horizontal_scrollbar().value(), -vertical_scrollbar().value());
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ void GLayout::add_widget(GWidget& widget)
|
|||
|
||||
void GLayout::remove_widget(GWidget& widget)
|
||||
{
|
||||
m_entries.remove_first_matching([&] (auto& entry) {
|
||||
m_entries.remove_first_matching([&](auto& entry) {
|
||||
return entry.widget == &widget;
|
||||
});
|
||||
if (m_owner)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include <LibGUI/GListView.h>
|
||||
#include <LibGUI/GScrollBar.h>
|
||||
#include <LibGUI/GPainter.h>
|
||||
#include <Kernel/KeyCode.h>
|
||||
#include <LibGUI/GListView.h>
|
||||
#include <LibGUI/GPainter.h>
|
||||
#include <LibGUI/GScrollBar.h>
|
||||
|
||||
GListView::GListView(GWidget* parent)
|
||||
: GAbstractView(parent)
|
||||
|
@ -18,7 +18,7 @@ GListView::~GListView()
|
|||
void GListView::update_content_size()
|
||||
{
|
||||
if (!model())
|
||||
return set_content_size({ });
|
||||
return set_content_size({});
|
||||
|
||||
int content_width = 0;
|
||||
for (int row = 0, row_count = model()->row_count(); row < row_count; ++row) {
|
||||
|
@ -76,7 +76,7 @@ void GListView::mousedown_event(GMouseEvent& event)
|
|||
update();
|
||||
return;
|
||||
}
|
||||
model()->set_selected_index({ });
|
||||
model()->set_selected_index({});
|
||||
update();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include <LibGUI/GAction.h>
|
||||
#include <LibGUI/GMenu.h>
|
||||
#include <LibGUI/GEventLoop.h>
|
||||
#include <AK/HashMap.h>
|
||||
#include <LibGUI/GAction.h>
|
||||
#include <LibGUI/GEventLoop.h>
|
||||
#include <LibGUI/GMenu.h>
|
||||
|
||||
//#define GMENU_DEBUG
|
||||
|
||||
|
@ -81,8 +81,8 @@ int GMenu::realize_menu()
|
|||
ASSERT(m_menu_id > 0);
|
||||
for (int i = 0; i < m_items.size(); ++i) {
|
||||
auto& item = *m_items[i];
|
||||
item.set_menu_id({ }, m_menu_id);
|
||||
item.set_identifier({ }, i);
|
||||
item.set_menu_id({}, m_menu_id);
|
||||
item.set_identifier({}, i);
|
||||
if (item.type() == GMenuItem::Separator) {
|
||||
WSAPI_ClientMessage request;
|
||||
request.type = WSAPI_ClientMessage::Type::AddMenuSeparator;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include <LibGUI/GMenuBar.h>
|
||||
#include <LibGUI/GEventLoop.h>
|
||||
#include <LibGUI/GMenuBar.h>
|
||||
|
||||
GMenuBar::GMenuBar()
|
||||
{
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include <LibGUI/GMenuItem.h>
|
||||
#include <LibGUI/GAction.h>
|
||||
#include <LibGUI/GEventLoop.h>
|
||||
#include <LibGUI/GMenuItem.h>
|
||||
#include <WindowServer/WSAPITypes.h>
|
||||
|
||||
GMenuItem::GMenuItem(unsigned menu_id, Type type)
|
||||
|
@ -14,7 +14,7 @@ GMenuItem::GMenuItem(unsigned menu_id, Retained<GAction>&& action)
|
|||
, m_menu_id(menu_id)
|
||||
, m_action(move(action))
|
||||
{
|
||||
m_action->register_menu_item({ }, *this);
|
||||
m_action->register_menu_item({}, *this);
|
||||
m_enabled = m_action->is_enabled();
|
||||
m_checkable = m_action->is_checkable();
|
||||
if (m_checkable)
|
||||
|
@ -24,7 +24,7 @@ GMenuItem::GMenuItem(unsigned menu_id, Retained<GAction>&& action)
|
|||
GMenuItem::~GMenuItem()
|
||||
{
|
||||
if (m_action)
|
||||
m_action->unregister_menu_item({ }, *this);
|
||||
m_action->unregister_menu_item({}, *this);
|
||||
}
|
||||
|
||||
void GMenuItem::set_enabled(bool enabled)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include <LibGUI/GMessageBox.h>
|
||||
#include <LibGUI/GBoxLayout.h>
|
||||
#include <LibGUI/GLabel.h>
|
||||
#include <LibGUI/GButton.h>
|
||||
#include <LibGUI/GLabel.h>
|
||||
#include <LibGUI/GMessageBox.h>
|
||||
#include <stdio.h>
|
||||
|
||||
void GMessageBox::show(const StringView& text, const StringView& title, Type type, CObject* parent)
|
||||
|
@ -73,7 +73,7 @@ void GMessageBox::build()
|
|||
button->set_size_policy(SizePolicy::Fixed, SizePolicy::Fixed);
|
||||
button->set_preferred_size({ 100, 20 });
|
||||
button->set_text("OK");
|
||||
button->on_click = [this] (auto&) {
|
||||
button->on_click = [this](auto&) {
|
||||
dbgprintf("GMessageBox: OK button clicked\n");
|
||||
done(0);
|
||||
};
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include <LibGUI/GModel.h>
|
||||
#include <LibGUI/GAbstractView.h>
|
||||
#include <LibGUI/GModel.h>
|
||||
|
||||
GModel::GModel()
|
||||
{
|
||||
|
@ -29,7 +29,7 @@ void GModel::did_update()
|
|||
{
|
||||
if (on_model_update)
|
||||
on_model_update(*this);
|
||||
for_each_view([] (auto& view) {
|
||||
for_each_view([](auto& view) {
|
||||
view.did_update_model();
|
||||
});
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ void GModel::set_selected_index(const GModelIndex& index)
|
|||
m_selected_index = index;
|
||||
if (on_selection_changed)
|
||||
on_selection_changed(index);
|
||||
for_each_view([] (auto& view) {
|
||||
for_each_view([](auto& view) {
|
||||
view.did_update_selection();
|
||||
});
|
||||
}
|
||||
|
@ -54,9 +54,9 @@ GModelIndex GModel::create_index(int row, int column, void* data) const
|
|||
GModelIndex GModel::sibling(int row, int column, const GModelIndex& parent) const
|
||||
{
|
||||
if (!parent.is_valid())
|
||||
return { };
|
||||
return {};
|
||||
int row_count = this->row_count(parent);
|
||||
if (row < 0 || row > row_count)
|
||||
return { };
|
||||
return {};
|
||||
return index(row, column, parent);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include <LibGUI/GProgressBar.h>
|
||||
#include <LibGUI/GPainter.h>
|
||||
#include <AK/StringBuilder.h>
|
||||
#include <LibGUI/GPainter.h>
|
||||
#include <LibGUI/GProgressBar.h>
|
||||
|
||||
GProgressBar::GProgressBar(GWidget* parent)
|
||||
: GFrame(parent)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include <LibGUI/GRadioButton.h>
|
||||
#include <LibGUI/GPainter.h>
|
||||
#include <LibGUI/GRadioButton.h>
|
||||
#include <SharedGraphics/GraphicsBitmap.h>
|
||||
|
||||
static RetainPtr<GraphicsBitmap> s_unfilled_circle_bitmap;
|
||||
|
@ -55,7 +55,7 @@ void GRadioButton::for_each_in_group(Callback callback)
|
|||
{
|
||||
if (!parent())
|
||||
return;
|
||||
parent()->for_each_child_of_type<GRadioButton>([&] (auto& child) {
|
||||
parent()->for_each_child_of_type<GRadioButton>([&](auto& child) {
|
||||
return callback(static_cast<GRadioButton&>(child));
|
||||
});
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ void GRadioButton::click()
|
|||
{
|
||||
if (!is_enabled())
|
||||
return;
|
||||
for_each_in_group([this] (auto& button) {
|
||||
for_each_in_group([this](auto& button) {
|
||||
if (&button != this)
|
||||
button.set_checked(false);
|
||||
return IterationDecision::Continue;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include <LibGUI/GResizeCorner.h>
|
||||
#include <LibGUI/GPainter.h>
|
||||
#include <LibGUI/GResizeCorner.h>
|
||||
#include <LibGUI/GWindow.h>
|
||||
#include <SharedGraphics/GraphicsBitmap.h>
|
||||
#include <WindowServer/WSAPITypes.h>
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#include <LibGUI/GPainter.h>
|
||||
#include <LibGUI/GScrollBar.h>
|
||||
#include <SharedGraphics/StylePainter.h>
|
||||
#include <SharedGraphics/CharacterBitmap.h>
|
||||
#include <SharedGraphics/GraphicsBitmap.h>
|
||||
#include <LibGUI/GPainter.h>
|
||||
#include <SharedGraphics/StylePainter.h>
|
||||
|
||||
static const char* s_up_arrow_bitmap_data = {
|
||||
" "
|
||||
|
@ -28,7 +28,6 @@ static const char* s_down_arrow_bitmap_data = {
|
|||
" "
|
||||
};
|
||||
|
||||
|
||||
static const char* s_left_arrow_bitmap_data = {
|
||||
" "
|
||||
" # "
|
||||
|
@ -146,7 +145,7 @@ Rect GScrollBar::increment_gutter_rect() const
|
|||
{
|
||||
auto scrubber_rect = this->scrubber_rect();
|
||||
if (orientation() == Orientation::Vertical)
|
||||
return { 0, scrubber_rect.bottom() + 1, button_width(), height() - button_height() - scrubber_rect.bottom() - 1};
|
||||
return { 0, scrubber_rect.bottom() + 1, button_width(), height() - button_height() - scrubber_rect.bottom() - 1 };
|
||||
else
|
||||
return { scrubber_rect.right() + 1, 0, width() - button_width() - scrubber_rect.right() - 1, button_width() };
|
||||
}
|
||||
|
@ -174,7 +173,7 @@ int GScrollBar::scrubber_size() const
|
|||
Rect GScrollBar::scrubber_rect() const
|
||||
{
|
||||
if (!has_scrubber())
|
||||
return { };
|
||||
return {};
|
||||
float x_or_y;
|
||||
if (m_value == m_min)
|
||||
x_or_y = button_size();
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
#include <LibGUI/GScrollableWidget.h>
|
||||
#include <LibGUI/GScrollBar.h>
|
||||
#include <LibGUI/GScrollableWidget.h>
|
||||
|
||||
GScrollableWidget::GScrollableWidget(GWidget* parent)
|
||||
: GFrame(parent)
|
||||
{
|
||||
m_vertical_scrollbar = new GScrollBar(Orientation::Vertical, this);
|
||||
m_vertical_scrollbar->set_step(4);
|
||||
m_vertical_scrollbar->on_change = [this] (int) {
|
||||
m_vertical_scrollbar->on_change = [this](int) {
|
||||
did_scroll();
|
||||
update();
|
||||
};
|
||||
|
@ -14,7 +14,7 @@ GScrollableWidget::GScrollableWidget(GWidget* parent)
|
|||
m_horizontal_scrollbar = new GScrollBar(Orientation::Horizontal, this);
|
||||
m_horizontal_scrollbar->set_step(4);
|
||||
m_horizontal_scrollbar->set_big_step(30);
|
||||
m_horizontal_scrollbar->on_change = [this] (int) {
|
||||
m_horizontal_scrollbar->on_change = [this](int) {
|
||||
did_scroll();
|
||||
update();
|
||||
};
|
||||
|
|
|
@ -1,114 +1,218 @@
|
|||
#include <LibGUI/GShortcut.h>
|
||||
#include <AK/StringBuilder.h>
|
||||
#include <LibGUI/GShortcut.h>
|
||||
|
||||
static String to_string(KeyCode key)
|
||||
{
|
||||
switch (key) {
|
||||
case Key_Escape: return "Escape";
|
||||
case Key_Tab: return "Tab";
|
||||
case Key_Backspace: return "Backspace";
|
||||
case Key_Return: return "Return";
|
||||
case Key_Insert: return "Insert";
|
||||
case Key_Delete: return "Delete";
|
||||
case Key_PrintScreen: return "PrintScreen";
|
||||
case Key_SysRq: return "SysRq";
|
||||
case Key_Home: return "Home";
|
||||
case Key_End: return "End";
|
||||
case Key_Left: return "Left";
|
||||
case Key_Up: return "Up";
|
||||
case Key_Right: return "Right";
|
||||
case Key_Down: return "Down";
|
||||
case Key_PageUp: return "PageUp";
|
||||
case Key_PageDown: return "PageDown";
|
||||
case Key_Shift: return "Shift";
|
||||
case Key_Control: return "Control";
|
||||
case Key_Alt: return "Alt";
|
||||
case Key_CapsLock: return "CapsLock";
|
||||
case Key_NumLock: return "NumLock";
|
||||
case Key_ScrollLock: return "ScrollLock";
|
||||
case Key_F1: return "F1";
|
||||
case Key_F2: return "F2";
|
||||
case Key_F3: return "F3";
|
||||
case Key_F4: return "F4";
|
||||
case Key_F5: return "F5";
|
||||
case Key_F6: return "F6";
|
||||
case Key_F7: return "F7";
|
||||
case Key_F8: return "F8";
|
||||
case Key_F9: return "F9";
|
||||
case Key_F10: return "F10";
|
||||
case Key_F11: return "F11";
|
||||
case Key_F12: return "F12";
|
||||
case Key_Space: return "Space";
|
||||
case Key_ExclamationPoint: return "!";
|
||||
case Key_DoubleQuote: return "\"";
|
||||
case Key_Hashtag: return "#";
|
||||
case Key_Dollar: return "$";
|
||||
case Key_Percent: return "%";
|
||||
case Key_Ampersand: return "&";
|
||||
case Key_Apostrophe: return "'";
|
||||
case Key_LeftParen: return "(";
|
||||
case Key_RightParen: return ")";
|
||||
case Key_Asterisk: return "*";
|
||||
case Key_Plus: return "+";
|
||||
case Key_Comma: return ",";
|
||||
case Key_Minus: return "-";
|
||||
case Key_Period: return ",";
|
||||
case Key_Slash: return "/";
|
||||
case Key_0: return "0";
|
||||
case Key_1: return "1";
|
||||
case Key_2: return "2";
|
||||
case Key_3: return "3";
|
||||
case Key_4: return "4";
|
||||
case Key_5: return "5";
|
||||
case Key_6: return "6";
|
||||
case Key_7: return "7";
|
||||
case Key_8: return "8";
|
||||
case Key_9: return "9";
|
||||
case Key_Colon: return ":";
|
||||
case Key_Semicolon: return ";";
|
||||
case Key_LessThan: return "<";
|
||||
case Key_Equal: return "=";
|
||||
case Key_GreaterThan: return ">";
|
||||
case Key_QuestionMark: return "?";
|
||||
case Key_AtSign: return "@";
|
||||
case Key_A: return "A";
|
||||
case Key_B: return "B";
|
||||
case Key_C: return "C";
|
||||
case Key_D: return "D";
|
||||
case Key_E: return "E";
|
||||
case Key_F: return "F";
|
||||
case Key_G: return "G";
|
||||
case Key_H: return "H";
|
||||
case Key_I: return "I";
|
||||
case Key_J: return "J";
|
||||
case Key_K: return "K";
|
||||
case Key_L: return "L";
|
||||
case Key_M: return "M";
|
||||
case Key_N: return "N";
|
||||
case Key_O: return "O";
|
||||
case Key_P: return "P";
|
||||
case Key_Q: return "Q";
|
||||
case Key_R: return "R";
|
||||
case Key_S: return "S";
|
||||
case Key_T: return "T";
|
||||
case Key_U: return "U";
|
||||
case Key_V: return "V";
|
||||
case Key_W: return "W";
|
||||
case Key_X: return "X";
|
||||
case Key_Y: return "Y";
|
||||
case Key_Z: return "Z";
|
||||
case Key_LeftBracket: return "[";
|
||||
case Key_RightBracket: return "]";
|
||||
case Key_Backslash: return "\\";
|
||||
case Key_Circumflex: return "^";
|
||||
case Key_Underscore: return "_";
|
||||
case Key_LeftBrace: return "{";
|
||||
case Key_RightBrace: return "}";
|
||||
case Key_Pipe: return "|";
|
||||
case Key_Tilde: return "~";
|
||||
case Key_Backtick: return "`";
|
||||
case Key_Escape:
|
||||
return "Escape";
|
||||
case Key_Tab:
|
||||
return "Tab";
|
||||
case Key_Backspace:
|
||||
return "Backspace";
|
||||
case Key_Return:
|
||||
return "Return";
|
||||
case Key_Insert:
|
||||
return "Insert";
|
||||
case Key_Delete:
|
||||
return "Delete";
|
||||
case Key_PrintScreen:
|
||||
return "PrintScreen";
|
||||
case Key_SysRq:
|
||||
return "SysRq";
|
||||
case Key_Home:
|
||||
return "Home";
|
||||
case Key_End:
|
||||
return "End";
|
||||
case Key_Left:
|
||||
return "Left";
|
||||
case Key_Up:
|
||||
return "Up";
|
||||
case Key_Right:
|
||||
return "Right";
|
||||
case Key_Down:
|
||||
return "Down";
|
||||
case Key_PageUp:
|
||||
return "PageUp";
|
||||
case Key_PageDown:
|
||||
return "PageDown";
|
||||
case Key_Shift:
|
||||
return "Shift";
|
||||
case Key_Control:
|
||||
return "Control";
|
||||
case Key_Alt:
|
||||
return "Alt";
|
||||
case Key_CapsLock:
|
||||
return "CapsLock";
|
||||
case Key_NumLock:
|
||||
return "NumLock";
|
||||
case Key_ScrollLock:
|
||||
return "ScrollLock";
|
||||
case Key_F1:
|
||||
return "F1";
|
||||
case Key_F2:
|
||||
return "F2";
|
||||
case Key_F3:
|
||||
return "F3";
|
||||
case Key_F4:
|
||||
return "F4";
|
||||
case Key_F5:
|
||||
return "F5";
|
||||
case Key_F6:
|
||||
return "F6";
|
||||
case Key_F7:
|
||||
return "F7";
|
||||
case Key_F8:
|
||||
return "F8";
|
||||
case Key_F9:
|
||||
return "F9";
|
||||
case Key_F10:
|
||||
return "F10";
|
||||
case Key_F11:
|
||||
return "F11";
|
||||
case Key_F12:
|
||||
return "F12";
|
||||
case Key_Space:
|
||||
return "Space";
|
||||
case Key_ExclamationPoint:
|
||||
return "!";
|
||||
case Key_DoubleQuote:
|
||||
return "\"";
|
||||
case Key_Hashtag:
|
||||
return "#";
|
||||
case Key_Dollar:
|
||||
return "$";
|
||||
case Key_Percent:
|
||||
return "%";
|
||||
case Key_Ampersand:
|
||||
return "&";
|
||||
case Key_Apostrophe:
|
||||
return "'";
|
||||
case Key_LeftParen:
|
||||
return "(";
|
||||
case Key_RightParen:
|
||||
return ")";
|
||||
case Key_Asterisk:
|
||||
return "*";
|
||||
case Key_Plus:
|
||||
return "+";
|
||||
case Key_Comma:
|
||||
return ",";
|
||||
case Key_Minus:
|
||||
return "-";
|
||||
case Key_Period:
|
||||
return ",";
|
||||
case Key_Slash:
|
||||
return "/";
|
||||
case Key_0:
|
||||
return "0";
|
||||
case Key_1:
|
||||
return "1";
|
||||
case Key_2:
|
||||
return "2";
|
||||
case Key_3:
|
||||
return "3";
|
||||
case Key_4:
|
||||
return "4";
|
||||
case Key_5:
|
||||
return "5";
|
||||
case Key_6:
|
||||
return "6";
|
||||
case Key_7:
|
||||
return "7";
|
||||
case Key_8:
|
||||
return "8";
|
||||
case Key_9:
|
||||
return "9";
|
||||
case Key_Colon:
|
||||
return ":";
|
||||
case Key_Semicolon:
|
||||
return ";";
|
||||
case Key_LessThan:
|
||||
return "<";
|
||||
case Key_Equal:
|
||||
return "=";
|
||||
case Key_GreaterThan:
|
||||
return ">";
|
||||
case Key_QuestionMark:
|
||||
return "?";
|
||||
case Key_AtSign:
|
||||
return "@";
|
||||
case Key_A:
|
||||
return "A";
|
||||
case Key_B:
|
||||
return "B";
|
||||
case Key_C:
|
||||
return "C";
|
||||
case Key_D:
|
||||
return "D";
|
||||
case Key_E:
|
||||
return "E";
|
||||
case Key_F:
|
||||
return "F";
|
||||
case Key_G:
|
||||
return "G";
|
||||
case Key_H:
|
||||
return "H";
|
||||
case Key_I:
|
||||
return "I";
|
||||
case Key_J:
|
||||
return "J";
|
||||
case Key_K:
|
||||
return "K";
|
||||
case Key_L:
|
||||
return "L";
|
||||
case Key_M:
|
||||
return "M";
|
||||
case Key_N:
|
||||
return "N";
|
||||
case Key_O:
|
||||
return "O";
|
||||
case Key_P:
|
||||
return "P";
|
||||
case Key_Q:
|
||||
return "Q";
|
||||
case Key_R:
|
||||
return "R";
|
||||
case Key_S:
|
||||
return "S";
|
||||
case Key_T:
|
||||
return "T";
|
||||
case Key_U:
|
||||
return "U";
|
||||
case Key_V:
|
||||
return "V";
|
||||
case Key_W:
|
||||
return "W";
|
||||
case Key_X:
|
||||
return "X";
|
||||
case Key_Y:
|
||||
return "Y";
|
||||
case Key_Z:
|
||||
return "Z";
|
||||
case Key_LeftBracket:
|
||||
return "[";
|
||||
case Key_RightBracket:
|
||||
return "]";
|
||||
case Key_Backslash:
|
||||
return "\\";
|
||||
case Key_Circumflex:
|
||||
return "^";
|
||||
case Key_Underscore:
|
||||
return "_";
|
||||
case Key_LeftBrace:
|
||||
return "{";
|
||||
case Key_RightBrace:
|
||||
return "}";
|
||||
case Key_Pipe:
|
||||
return "|";
|
||||
case Key_Tilde:
|
||||
return "~";
|
||||
case Key_Backtick:
|
||||
return "`";
|
||||
|
||||
case Key_Invalid: return "Invalid";
|
||||
case Key_Invalid:
|
||||
return "Invalid";
|
||||
default:
|
||||
ASSERT_NOT_REACHED();
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include <LibGUI/GSlider.h>
|
||||
#include <LibGUI/GPainter.h>
|
||||
#include <LibGUI/GSlider.h>
|
||||
#include <SharedGraphics/StylePainter.h>
|
||||
|
||||
GSlider::GSlider(GWidget* parent)
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
#include <LibGUI/GSortingProxyModel.h>
|
||||
#include <AK/QuickSort.h>
|
||||
#include <stdlib.h>
|
||||
#include <LibGUI/GSortingProxyModel.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
GSortingProxyModel::GSortingProxyModel(Retained<GModel>&& target)
|
||||
: m_target(move(target))
|
||||
, m_key_column(-1)
|
||||
{
|
||||
m_target->on_model_update = [this] (GModel&) {
|
||||
m_target->on_model_update = [this](GModel&) {
|
||||
resort();
|
||||
};
|
||||
}
|
||||
|
@ -29,9 +29,9 @@ int GSortingProxyModel::column_count(const GModelIndex& index) const
|
|||
GModelIndex GSortingProxyModel::map_to_target(const GModelIndex& index) const
|
||||
{
|
||||
if (!index.is_valid())
|
||||
return { };
|
||||
return {};
|
||||
if (index.row() >= m_row_mappings.size() || index.column() >= column_count())
|
||||
return { };
|
||||
return {};
|
||||
return target().index(m_row_mappings[index.row()], index.column());
|
||||
}
|
||||
|
||||
|
@ -82,7 +82,7 @@ void GSortingProxyModel::resort()
|
|||
did_update();
|
||||
return;
|
||||
}
|
||||
quick_sort(m_row_mappings.begin(), m_row_mappings.end(), [&] (auto row1, auto row2) -> bool {
|
||||
quick_sort(m_row_mappings.begin(), m_row_mappings.end(), [&](auto row1, auto row2) -> bool {
|
||||
auto data1 = target().data(target().index(row1, m_key_column), GModel::Role::Sort);
|
||||
auto data2 = target().data(target().index(row2, m_key_column), GModel::Role::Sort);
|
||||
if (data1 == data2)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include <LibGUI/GSpinBox.h>
|
||||
#include <LibGUI/GButton.h>
|
||||
#include <LibGUI/GSpinBox.h>
|
||||
#include <LibGUI/GTextEditor.h>
|
||||
|
||||
GSpinBox::GSpinBox(GWidget* parent)
|
||||
|
@ -16,10 +16,10 @@ GSpinBox::GSpinBox(GWidget* parent)
|
|||
};
|
||||
m_increment_button = new GButton(this);
|
||||
m_increment_button->set_text("\xf6");
|
||||
m_increment_button->on_click = [this] (GButton&) { set_value(m_value + 1); };
|
||||
m_increment_button->on_click = [this](GButton&) { set_value(m_value + 1); };
|
||||
m_decrement_button = new GButton(this);
|
||||
m_decrement_button->set_text("\xf7");
|
||||
m_decrement_button->on_click = [this] (GButton&) { set_value(m_value - 1); };
|
||||
m_decrement_button->on_click = [this](GButton&) { set_value(m_value - 1); };
|
||||
}
|
||||
|
||||
GSpinBox::~GSpinBox()
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include <LibGUI/GSplitter.h>
|
||||
#include <LibGUI/GBoxLayout.h>
|
||||
#include <LibGUI/GSplitter.h>
|
||||
#include <LibGUI/GWindow.h>
|
||||
|
||||
GSplitter::GSplitter(Orientation orientation, GWidget* parent)
|
||||
|
@ -40,7 +40,7 @@ void GSplitter::mousedown_event(GMouseEvent& event)
|
|||
GWidget* first_resizee { nullptr };
|
||||
GWidget* second_resizee { nullptr };
|
||||
int fudge = layout()->spacing();
|
||||
for_each_child_widget([&] (auto& child) {
|
||||
for_each_child_widget([&](auto& child) {
|
||||
int child_start = m_orientation == Orientation::Horizontal ? child.relative_rect().left() : child.relative_rect().top();
|
||||
int child_end = m_orientation == Orientation::Horizontal ? child.relative_rect().right() : child.relative_rect().bottom();
|
||||
if (x_or_y > child_end && (x_or_y - fudge) <= child_end)
|
||||
|
@ -65,7 +65,8 @@ void GSplitter::mousemove_event(GMouseEvent& event)
|
|||
if (!m_first_resizee || !m_second_resizee) {
|
||||
// One or both of the resizees were deleted during an ongoing resize, screw this.
|
||||
m_resizing = false;
|
||||
return;;
|
||||
return;
|
||||
;
|
||||
}
|
||||
int minimum_size = 0;
|
||||
auto new_first_resizee_size = m_first_resizee_start_size;
|
||||
|
@ -112,5 +113,4 @@ void GSplitter::mouseup_event(GMouseEvent& event)
|
|||
m_resizing = false;
|
||||
if (!rect().contains(event.position()))
|
||||
window()->set_override_cursor(GStandardCursor::None);
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include <LibGUI/GStackWidget.h>
|
||||
#include <LibGUI/GBoxLayout.h>
|
||||
#include <LibGUI/GStackWidget.h>
|
||||
|
||||
GStackWidget::GStackWidget(GWidget* parent)
|
||||
: GWidget(parent)
|
||||
|
@ -28,7 +28,7 @@ void GStackWidget::resize_event(GResizeEvent& event)
|
|||
{
|
||||
if (!m_active_widget)
|
||||
return;
|
||||
m_active_widget->set_relative_rect({ { }, event.size() });
|
||||
m_active_widget->set_relative_rect({ {}, event.size() });
|
||||
}
|
||||
|
||||
void GStackWidget::child_event(CChildEvent& event)
|
||||
|
@ -44,7 +44,7 @@ void GStackWidget::child_event(CChildEvent& event)
|
|||
} else if (event.type() == GEvent::ChildRemoved) {
|
||||
if (m_active_widget == &child) {
|
||||
GWidget* new_active_widget = nullptr;
|
||||
for_each_child_widget([&] (auto& new_child) {
|
||||
for_each_child_widget([&](auto& new_child) {
|
||||
new_active_widget = &new_child;
|
||||
return IterationDecision::Abort;
|
||||
});
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
#include <LibGUI/GStatusBar.h>
|
||||
#include <LibGUI/GLabel.h>
|
||||
#include <LibGUI/GBoxLayout.h>
|
||||
#include <SharedGraphics/StylePainter.h>
|
||||
#include <LibGUI/GLabel.h>
|
||||
#include <LibGUI/GPainter.h>
|
||||
#include <LibGUI/GResizeCorner.h>
|
||||
#include <LibGUI/GStatusBar.h>
|
||||
#include <SharedGraphics/StylePainter.h>
|
||||
|
||||
GStatusBar::GStatusBar(GWidget* parent)
|
||||
: GWidget(parent)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include <LibGUI/GTabWidget.h>
|
||||
#include <LibGUI/GBoxLayout.h>
|
||||
#include <LibGUI/GPainter.h>
|
||||
#include <LibGUI/GTabWidget.h>
|
||||
#include <SharedGraphics/StylePainter.h>
|
||||
|
||||
GTabWidget::GTabWidget(GWidget* parent)
|
||||
|
@ -61,7 +61,7 @@ void GTabWidget::child_event(CChildEvent& event)
|
|||
} else if (event.type() == GEvent::ChildRemoved) {
|
||||
if (m_active_widget == &child) {
|
||||
GWidget* new_active_widget = nullptr;
|
||||
for_each_child_widget([&] (auto& new_child) {
|
||||
for_each_child_widget([&](auto& new_child) {
|
||||
new_active_widget = &new_child;
|
||||
return IterationDecision::Abort;
|
||||
});
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
#include <LibGUI/GTableView.h>
|
||||
#include <AK/StringBuilder.h>
|
||||
#include <Kernel/KeyCode.h>
|
||||
#include <LibGUI/GAction.h>
|
||||
#include <LibGUI/GMenu.h>
|
||||
#include <LibGUI/GModel.h>
|
||||
#include <LibGUI/GScrollBar.h>
|
||||
#include <LibGUI/GPainter.h>
|
||||
#include <LibGUI/GScrollBar.h>
|
||||
#include <LibGUI/GTableView.h>
|
||||
#include <LibGUI/GTextBox.h>
|
||||
#include <LibGUI/GWindow.h>
|
||||
#include <LibGUI/GMenu.h>
|
||||
#include <LibGUI/GAction.h>
|
||||
#include <Kernel/KeyCode.h>
|
||||
#include <AK/StringBuilder.h>
|
||||
|
||||
GTableView::GTableView(GWidget* parent)
|
||||
: GAbstractView(parent)
|
||||
|
@ -24,7 +24,7 @@ GTableView::~GTableView()
|
|||
void GTableView::update_content_size()
|
||||
{
|
||||
if (!model())
|
||||
return set_content_size({ });
|
||||
return set_content_size({});
|
||||
|
||||
int content_width = 0;
|
||||
int column_count = model()->column_count();
|
||||
|
@ -80,9 +80,9 @@ int GTableView::column_width(int column_index) const
|
|||
Rect GTableView::header_rect(int column_index) const
|
||||
{
|
||||
if (!model())
|
||||
return { };
|
||||
return {};
|
||||
if (is_column_hidden(column_index))
|
||||
return { };
|
||||
return {};
|
||||
int x_offset = 0;
|
||||
for (int i = 0; i < column_index; ++i) {
|
||||
if (is_column_hidden(i))
|
||||
|
@ -100,7 +100,7 @@ Point GTableView::adjusted_position(const Point& position)
|
|||
Rect GTableView::column_resize_grabbable_rect(int column) const
|
||||
{
|
||||
if (!model())
|
||||
return { };
|
||||
return {};
|
||||
auto header_rect = this->header_rect(column);
|
||||
return { header_rect.right() - 1, header_rect.top(), 4, header_rect.height() };
|
||||
}
|
||||
|
@ -148,7 +148,7 @@ void GTableView::mousedown_event(GMouseEvent& event)
|
|||
return;
|
||||
}
|
||||
}
|
||||
model()->set_selected_index({ });
|
||||
model()->set_selected_index({});
|
||||
update();
|
||||
}
|
||||
|
||||
|
@ -427,7 +427,7 @@ GMenu& GTableView::ensure_header_context_menu()
|
|||
for (int column = 0; column < model()->column_count(); ++column) {
|
||||
auto& column_data = this->column_data(column);
|
||||
auto name = model()->column_name(column);
|
||||
column_data.visibility_action = GAction::create(name, [this, column] (GAction& action) {
|
||||
column_data.visibility_action = GAction::create(name, [this, column](GAction& action) {
|
||||
action.set_checked(!action.is_checked());
|
||||
set_column_hidden(column, !action.is_checked());
|
||||
});
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
#include <LibGUI/GTextEditor.h>
|
||||
#include <LibGUI/GScrollBar.h>
|
||||
#include <LibGUI/GFontDatabase.h>
|
||||
#include <LibGUI/GClipboard.h>
|
||||
#include <LibGUI/GPainter.h>
|
||||
#include <LibGUI/GWindow.h>
|
||||
#include <LibGUI/GMenu.h>
|
||||
#include <LibGUI/GAction.h>
|
||||
#include <Kernel/KeyCode.h>
|
||||
#include <AK/StringBuilder.h>
|
||||
#include <unistd.h>
|
||||
#include <Kernel/KeyCode.h>
|
||||
#include <LibGUI/GAction.h>
|
||||
#include <LibGUI/GClipboard.h>
|
||||
#include <LibGUI/GFontDatabase.h>
|
||||
#include <LibGUI/GMenu.h>
|
||||
#include <LibGUI/GPainter.h>
|
||||
#include <LibGUI/GScrollBar.h>
|
||||
#include <LibGUI/GTextEditor.h>
|
||||
#include <LibGUI/GWindow.h>
|
||||
#include <ctype.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include <unistd.h>
|
||||
|
||||
GTextEditor::GTextEditor(Type type, GWidget* parent)
|
||||
: GScrollableWidget(parent)
|
||||
|
@ -35,29 +35,35 @@ GTextEditor::~GTextEditor()
|
|||
|
||||
void GTextEditor::create_actions()
|
||||
{
|
||||
m_undo_action = GAction::create("Undo", { Mod_Ctrl, Key_Z }, GraphicsBitmap::load_from_file("/res/icons/16x16/undo.png"), [&] (const GAction&) {
|
||||
m_undo_action = GAction::create("Undo", { Mod_Ctrl, Key_Z }, GraphicsBitmap::load_from_file("/res/icons/16x16/undo.png"), [&](const GAction&) {
|
||||
// FIXME: Undo
|
||||
}, this);
|
||||
},
|
||||
this);
|
||||
|
||||
m_redo_action = GAction::create("Redo", { Mod_Ctrl, Key_Y }, GraphicsBitmap::load_from_file("/res/icons/16x16/redo.png"), [&] (const GAction&) {
|
||||
m_redo_action = GAction::create("Redo", { Mod_Ctrl, Key_Y }, GraphicsBitmap::load_from_file("/res/icons/16x16/redo.png"), [&](const GAction&) {
|
||||
// FIXME: Redo
|
||||
}, this);
|
||||
},
|
||||
this);
|
||||
|
||||
m_cut_action = GAction::create("Cut", { Mod_Ctrl, Key_X }, GraphicsBitmap::load_from_file("/res/icons/cut16.png"), [&] (const GAction&) {
|
||||
m_cut_action = GAction::create("Cut", { Mod_Ctrl, Key_X }, GraphicsBitmap::load_from_file("/res/icons/cut16.png"), [&](const GAction&) {
|
||||
cut();
|
||||
}, this);
|
||||
},
|
||||
this);
|
||||
|
||||
m_copy_action = GAction::create("Copy", { Mod_Ctrl, Key_C }, GraphicsBitmap::load_from_file("/res/icons/16x16/edit-copy.png"), [&] (const GAction&) {
|
||||
m_copy_action = GAction::create("Copy", { Mod_Ctrl, Key_C }, GraphicsBitmap::load_from_file("/res/icons/16x16/edit-copy.png"), [&](const GAction&) {
|
||||
copy();
|
||||
}, this);
|
||||
},
|
||||
this);
|
||||
|
||||
m_paste_action = GAction::create("Paste", { Mod_Ctrl, Key_V }, GraphicsBitmap::load_from_file("/res/icons/paste16.png"), [&] (const GAction&) {
|
||||
m_paste_action = GAction::create("Paste", { Mod_Ctrl, Key_V }, GraphicsBitmap::load_from_file("/res/icons/paste16.png"), [&](const GAction&) {
|
||||
paste();
|
||||
}, this);
|
||||
},
|
||||
this);
|
||||
|
||||
m_delete_action = GAction::create("Delete", { 0, Key_Delete }, GraphicsBitmap::load_from_file("/res/icons/16x16/delete.png"), [&] (const GAction&) {
|
||||
m_delete_action = GAction::create("Delete", { 0, Key_Delete }, GraphicsBitmap::load_from_file("/res/icons/16x16/delete.png"), [&](const GAction&) {
|
||||
do_delete();
|
||||
}, this);
|
||||
},
|
||||
this);
|
||||
}
|
||||
|
||||
void GTextEditor::set_text(const StringView& text)
|
||||
|
@ -69,7 +75,7 @@ void GTextEditor::set_text(const StringView& text)
|
|||
m_lines.clear();
|
||||
int start_of_current_line = 0;
|
||||
|
||||
auto add_line = [&] (int current_position) {
|
||||
auto add_line = [&](int current_position) {
|
||||
int line_length = current_position - start_of_current_line;
|
||||
auto line = make<Line>();
|
||||
if (line_length)
|
||||
|
@ -189,7 +195,7 @@ void GTextEditor::mousedown_event(GMouseEvent& event)
|
|||
|
||||
if (event.modifiers() & Mod_Shift) {
|
||||
if (!has_selection())
|
||||
m_selection.set(m_cursor, { });
|
||||
m_selection.set(m_cursor, {});
|
||||
} else {
|
||||
m_selection.clear();
|
||||
}
|
||||
|
@ -200,7 +206,7 @@ void GTextEditor::mousedown_event(GMouseEvent& event)
|
|||
|
||||
if (!(event.modifiers() & Mod_Shift)) {
|
||||
if (!has_selection())
|
||||
m_selection.set(m_cursor, { });
|
||||
m_selection.set(m_cursor, {});
|
||||
}
|
||||
|
||||
if (m_selection.start().is_valid() && m_selection.start() != m_cursor)
|
||||
|
@ -243,7 +249,7 @@ int GTextEditor::ruler_width() const
|
|||
Rect GTextEditor::ruler_content_rect(int line_index) const
|
||||
{
|
||||
if (!m_ruler_visible)
|
||||
return { };
|
||||
return {};
|
||||
return {
|
||||
0 - ruler_width() + horizontal_scrollbar().value(),
|
||||
line_index * line_height(),
|
||||
|
@ -263,7 +269,7 @@ void GTextEditor::paint_event(GPaintEvent& event)
|
|||
|
||||
painter.translate(frame_thickness(), frame_thickness());
|
||||
|
||||
Rect ruler_rect { 0, 0, ruler_width(), height() - height_occupied_by_horizontal_scrollbar()};
|
||||
Rect ruler_rect { 0, 0, ruler_width(), height() - height_occupied_by_horizontal_scrollbar() };
|
||||
|
||||
if (m_ruler_visible) {
|
||||
painter.fill_rect(ruler_rect, Color::LightGray);
|
||||
|
@ -289,8 +295,7 @@ void GTextEditor::paint_event(GPaintEvent& event)
|
|||
String::format("%u", i),
|
||||
is_current_line ? Font::default_bold_font() : font(),
|
||||
TextAlignment::CenterRight,
|
||||
is_current_line ? Color::DarkGray : Color::MidGray
|
||||
);
|
||||
is_current_line ? Color::DarkGray : Color::MidGray);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -310,7 +315,8 @@ void GTextEditor::paint_event(GPaintEvent& event)
|
|||
int selection_end_column_on_line = selection.end().line() == i ? selection.end().column() : line.length();
|
||||
|
||||
int selection_left = content_x_for_position({ i, selection_start_column_on_line });
|
||||
int selection_right = content_x_for_position({ i, selection_end_column_on_line });;
|
||||
int selection_right = content_x_for_position({ i, selection_end_column_on_line });
|
||||
;
|
||||
|
||||
Rect selection_rect { selection_left, line_rect.y(), selection_right - selection_left, line_rect.height() };
|
||||
painter.fill_rect(selection_rect, Color::from_rgb(0x955233));
|
||||
|
@ -325,7 +331,7 @@ void GTextEditor::paint_event(GPaintEvent& event)
|
|||
void GTextEditor::toggle_selection_if_needed_for_event(const GKeyEvent& event)
|
||||
{
|
||||
if (event.shift() && !m_selection.is_valid()) {
|
||||
m_selection.set(m_cursor, { });
|
||||
m_selection.set(m_cursor, {});
|
||||
did_update_selection();
|
||||
update();
|
||||
return;
|
||||
|
@ -654,7 +660,7 @@ int GTextEditor::content_x_for_position(const GTextPosition& position) const
|
|||
Rect GTextEditor::cursor_content_rect() const
|
||||
{
|
||||
if (!m_cursor.is_valid())
|
||||
return { };
|
||||
return {};
|
||||
ASSERT(!m_lines.is_empty());
|
||||
ASSERT(m_cursor.column() <= (current_line().length() + 1));
|
||||
|
||||
|
@ -662,7 +668,7 @@ Rect GTextEditor::cursor_content_rect() const
|
|||
|
||||
if (is_single_line()) {
|
||||
Rect cursor_rect { cursor_x, 0, 1, font().glyph_height() + 2 };
|
||||
cursor_rect.center_vertically_within({ { }, frame_inner_rect().size() });
|
||||
cursor_rect.center_vertically_within({ {}, frame_inner_rect().size() });
|
||||
return cursor_rect;
|
||||
}
|
||||
return { cursor_x, m_cursor.line() * line_height(), 1, line_height() };
|
||||
|
@ -694,7 +700,7 @@ Rect GTextEditor::line_content_rect(int line_index) const
|
|||
auto& line = *m_lines[line_index];
|
||||
if (is_single_line()) {
|
||||
Rect line_rect = { content_x_for_position({ line_index, 0 }), 0, line.length() * glyph_width(), font().glyph_height() + 2 };
|
||||
line_rect.center_vertically_within({ { }, frame_inner_rect().size() });
|
||||
line_rect.center_vertically_within({ {}, frame_inner_rect().size() });
|
||||
return line_rect;
|
||||
}
|
||||
return {
|
||||
|
@ -887,7 +893,7 @@ void GTextEditor::clear()
|
|||
String GTextEditor::selected_text() const
|
||||
{
|
||||
if (!has_selection())
|
||||
return { };
|
||||
return {};
|
||||
|
||||
auto selection = normalized_selection();
|
||||
StringBuilder builder;
|
||||
|
@ -1005,7 +1011,7 @@ void GTextEditor::did_change()
|
|||
update_content_size();
|
||||
if (!m_have_pending_change_notification) {
|
||||
m_have_pending_change_notification = true;
|
||||
deferred_invoke([this] (auto&) {
|
||||
deferred_invoke([this](auto&) {
|
||||
if (on_change)
|
||||
on_change();
|
||||
m_have_pending_change_notification = false;
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#include <LibGUI/GToolBar.h>
|
||||
#include <LibGUI/GAction.h>
|
||||
#include <LibGUI/GBoxLayout.h>
|
||||
#include <LibGUI/GButton.h>
|
||||
#include <LibGUI/GAction.h>
|
||||
#include <LibGUI/GPainter.h>
|
||||
#include <LibGUI/GToolBar.h>
|
||||
|
||||
GToolBar::GToolBar(GWidget* parent)
|
||||
: GWidget(parent)
|
||||
|
@ -32,7 +32,7 @@ void GToolBar::add_action(Retained<GAction>&& action)
|
|||
button->set_icon(item->action->icon());
|
||||
else
|
||||
button->set_text(item->action->text());
|
||||
button->on_click = [raw_action_ptr] (const GButton&) {
|
||||
button->on_click = [raw_action_ptr](const GButton&) {
|
||||
raw_action_ptr->activate();
|
||||
};
|
||||
|
||||
|
@ -54,7 +54,7 @@ public:
|
|||
set_background_color(Color::White);
|
||||
set_preferred_size({ 8, 22 });
|
||||
}
|
||||
virtual ~SeparatorWidget() override { }
|
||||
virtual ~SeparatorWidget() override {}
|
||||
|
||||
virtual void paint_event(GPaintEvent& event) override
|
||||
{
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include <LibGUI/GTreeView.h>
|
||||
#include <LibGUI/GPainter.h>
|
||||
#include <LibGUI/GScrollBar.h>
|
||||
#include <LibGUI/GTreeView.h>
|
||||
|
||||
//#define DEBUG_ITEM_RECTS
|
||||
|
||||
|
@ -39,9 +39,9 @@ GModelIndex GTreeView::index_at_content_position(const Point& position, bool& is
|
|||
{
|
||||
is_toggle = false;
|
||||
if (!model())
|
||||
return { };
|
||||
return {};
|
||||
GModelIndex result;
|
||||
traverse_in_paint_order([&] (const GModelIndex& index, const Rect& rect, const Rect& toggle_rect, int) {
|
||||
traverse_in_paint_order([&](const GModelIndex& index, const Rect& rect, const Rect& toggle_rect, int) {
|
||||
if (rect.contains(position)) {
|
||||
result = index;
|
||||
return IterationDecision::Abort;
|
||||
|
@ -88,7 +88,7 @@ void GTreeView::traverse_in_paint_order(Callback callback) const
|
|||
int indent_level = 0;
|
||||
int y_offset = 0;
|
||||
|
||||
Function<IterationDecision(const GModelIndex&)> traverse_index = [&] (const GModelIndex& index) {
|
||||
Function<IterationDecision(const GModelIndex&)> traverse_index = [&](const GModelIndex& index) {
|
||||
int row_count_at_index = model.row_count(index);
|
||||
if (index.is_valid()) {
|
||||
auto& metadata = ensure_metadata_for_index(index);
|
||||
|
@ -139,7 +139,7 @@ void GTreeView::paint_event(GPaintEvent& event)
|
|||
auto& model = *this->model();
|
||||
auto visible_content_rect = this->visible_content_rect();
|
||||
|
||||
traverse_in_paint_order([&] (const GModelIndex& index, const Rect& rect, const Rect& toggle_rect, int indent_level) {
|
||||
traverse_in_paint_order([&](const GModelIndex& index, const Rect& rect, const Rect& toggle_rect, int indent_level) {
|
||||
if (!rect.intersects(visible_content_rect))
|
||||
return IterationDecision::Continue;
|
||||
#ifdef DEBUG_ITEM_RECTS
|
||||
|
@ -202,7 +202,7 @@ void GTreeView::scroll_into_view(const GModelIndex& a_index, Orientation orienta
|
|||
if (!a_index.is_valid())
|
||||
return;
|
||||
Rect found_rect;
|
||||
traverse_in_paint_order([&] (const GModelIndex& index, const Rect& rect, const Rect&, int) {
|
||||
traverse_in_paint_order([&](const GModelIndex& index, const Rect& rect, const Rect&, int) {
|
||||
if (index == a_index) {
|
||||
found_rect = rect;
|
||||
return IterationDecision::Abort;
|
||||
|
@ -251,7 +251,7 @@ void GTreeView::update_content_size()
|
|||
{
|
||||
int height = 0;
|
||||
int width = 0;
|
||||
traverse_in_paint_order([&] (const GModelIndex&, const Rect& rect, const Rect&, int) {
|
||||
traverse_in_paint_order([&](const GModelIndex&, const Rect& rect, const Rect&, int) {
|
||||
width = max(width, rect.right());
|
||||
height += rect.height();
|
||||
return IterationDecision::Continue;
|
||||
|
@ -267,7 +267,7 @@ void GTreeView::keydown_event(GKeyEvent& event)
|
|||
if (event.key() == KeyCode::Key_Up) {
|
||||
GModelIndex previous_index;
|
||||
GModelIndex found_index;
|
||||
traverse_in_paint_order([&] (const GModelIndex& index, const Rect&, const Rect&, int) {
|
||||
traverse_in_paint_order([&](const GModelIndex& index, const Rect&, const Rect&, int) {
|
||||
if (index == cursor_index) {
|
||||
found_index = previous_index;
|
||||
return IterationDecision::Abort;
|
||||
|
@ -284,7 +284,7 @@ void GTreeView::keydown_event(GKeyEvent& event)
|
|||
if (event.key() == KeyCode::Key_Down) {
|
||||
GModelIndex previous_index;
|
||||
GModelIndex found_index;
|
||||
traverse_in_paint_order([&] (const GModelIndex& index, const Rect&, const Rect&, int) {
|
||||
traverse_in_paint_order([&](const GModelIndex& index, const Rect&, const Rect&, int) {
|
||||
if (previous_index == cursor_index) {
|
||||
found_index = index;
|
||||
return IterationDecision::Abort;
|
||||
|
|
|
@ -252,4 +252,3 @@ String GVariant::to_string() const
|
|||
}
|
||||
ASSERT_NOT_REACHED();
|
||||
}
|
||||
|
||||
|
|
|
@ -2,13 +2,13 @@
|
|||
#include "GEvent.h"
|
||||
#include "GEventLoop.h"
|
||||
#include "GWindow.h"
|
||||
#include <LibGUI/GLayout.h>
|
||||
#include <AK/Assertions.h>
|
||||
#include <SharedGraphics/GraphicsBitmap.h>
|
||||
#include <LibGUI/GAction.h>
|
||||
#include <LibGUI/GPainter.h>
|
||||
#include <LibGUI/GApplication.h>
|
||||
#include <LibGUI/GLayout.h>
|
||||
#include <LibGUI/GMenu.h>
|
||||
#include <LibGUI/GPainter.h>
|
||||
#include <SharedGraphics/GraphicsBitmap.h>
|
||||
#include <unistd.h>
|
||||
|
||||
GWidget::GWidget(GWidget* parent)
|
||||
|
@ -116,7 +116,7 @@ void GWidget::handle_paint_event(GPaintEvent& event)
|
|||
#endif
|
||||
}
|
||||
paint_event(event);
|
||||
for_each_child_widget([&] (auto& child) {
|
||||
for_each_child_widget([&](auto& child) {
|
||||
if (!child.is_visible())
|
||||
return IterationDecision::Continue;
|
||||
if (child.relative_rect().intersects(event.rect())) {
|
||||
|
@ -418,7 +418,7 @@ void GWidget::invalidate_layout()
|
|||
if (m_layout_dirty)
|
||||
return;
|
||||
m_layout_dirty = true;
|
||||
deferred_invoke([this] (auto&) {
|
||||
deferred_invoke([this](auto&) {
|
||||
m_layout_dirty = false;
|
||||
auto* w = window();
|
||||
if (!w)
|
||||
|
@ -472,7 +472,7 @@ void GWidget::move_to_front()
|
|||
return;
|
||||
if (parent->children().size() == 1)
|
||||
return;
|
||||
parent->children().remove_first_matching([this] (auto& entry) {
|
||||
parent->children().remove_first_matching([this](auto& entry) {
|
||||
return entry == this;
|
||||
});
|
||||
parent->children().append(this);
|
||||
|
@ -486,7 +486,7 @@ void GWidget::move_to_back()
|
|||
return;
|
||||
if (parent->children().size() == 1)
|
||||
return;
|
||||
parent->children().remove_first_matching([this] (auto& entry) {
|
||||
parent->children().remove_first_matching([this](auto& entry) {
|
||||
return entry == this;
|
||||
});
|
||||
parent->children().prepend(this);
|
||||
|
|
|
@ -2,12 +2,12 @@
|
|||
#include "GEvent.h"
|
||||
#include "GEventLoop.h"
|
||||
#include "GWidget.h"
|
||||
#include <SharedGraphics/GraphicsBitmap.h>
|
||||
#include <LibGUI/GPainter.h>
|
||||
#include <AK/HashMap.h>
|
||||
#include <LibC/stdio.h>
|
||||
#include <LibC/stdlib.h>
|
||||
#include <LibC/unistd.h>
|
||||
#include <AK/HashMap.h>
|
||||
#include <LibGUI/GPainter.h>
|
||||
#include <SharedGraphics/GraphicsBitmap.h>
|
||||
|
||||
//#define UPDATE_COALESCING_DEBUG
|
||||
|
||||
|
@ -235,7 +235,7 @@ void GWindow::event(CEvent& event)
|
|||
auto rect = rects.first();
|
||||
if (rect.is_empty() || created_new_backing_store) {
|
||||
rects.clear();
|
||||
rects.append({ { }, paint_event.window_size() });
|
||||
rects.append({ {}, paint_event.window_size() });
|
||||
}
|
||||
|
||||
for (auto& rect : rects)
|
||||
|
@ -294,10 +294,10 @@ void GWindow::event(CEvent& event)
|
|||
m_back_bitmap = nullptr;
|
||||
if (!m_pending_paint_event_rects.is_empty()) {
|
||||
m_pending_paint_event_rects.clear_with_capacity();
|
||||
m_pending_paint_event_rects.append({ { }, new_size });
|
||||
m_pending_paint_event_rects.append({ {}, new_size });
|
||||
}
|
||||
m_rect_when_windowless = { { }, new_size };
|
||||
m_main_widget->set_relative_rect({ { }, new_size });
|
||||
m_rect_when_windowless = { {}, new_size };
|
||||
m_main_widget->set_relative_rect({ {}, new_size });
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -326,7 +326,7 @@ void GWindow::update(const Rect& a_rect)
|
|||
}
|
||||
|
||||
if (m_pending_paint_event_rects.is_empty()) {
|
||||
deferred_invoke([this] (auto&) {
|
||||
deferred_invoke([this](auto&) {
|
||||
auto rects = move(m_pending_paint_event_rects);
|
||||
if (rects.is_empty())
|
||||
return;
|
||||
|
@ -357,7 +357,7 @@ void GWindow::set_main_widget(GWidget* widget)
|
|||
if (m_main_widget->vertical_size_policy() == SizePolicy::Fixed)
|
||||
new_window_rect.set_height(m_main_widget->preferred_size().height());
|
||||
set_rect(new_window_rect);
|
||||
m_main_widget->set_relative_rect({ { }, new_window_rect.size() });
|
||||
m_main_widget->set_relative_rect({ {}, new_window_rect.size() });
|
||||
m_main_widget->set_window(this);
|
||||
if (m_main_widget->accepts_focus())
|
||||
m_main_widget->set_focus(true);
|
||||
|
@ -530,14 +530,14 @@ void GWindow::start_wm_resize()
|
|||
Vector<GWidget*> GWindow::focusable_widgets() const
|
||||
{
|
||||
if (!m_main_widget)
|
||||
return { };
|
||||
return {};
|
||||
|
||||
Vector<GWidget*> collected_widgets;
|
||||
|
||||
Function<void(GWidget&)> collect_focusable_widgets = [&] (GWidget& widget) {
|
||||
Function<void(GWidget&)> collect_focusable_widgets = [&](GWidget& widget) {
|
||||
if (widget.accepts_focus())
|
||||
collected_widgets.append(&widget);
|
||||
widget.for_each_child_widget([&] (auto& child) {
|
||||
widget.for_each_child_widget([&](auto& child) {
|
||||
if (!child.is_visible())
|
||||
return IterationDecision::Continue;
|
||||
if (!child.is_enabled())
|
||||
|
|
Loading…
Add table
Reference in a new issue