mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-15 10:50:40 +00:00
Browser: Add support for color pickers
This commit is contained in:
parent
2995a2e212
commit
3e1a154440
Notes:
sideshowbarker
2024-07-17 07:09:53 +09:00
Author: https://github.com/circl-lastname Commit: https://github.com/SerenityOS/serenity/commit/3e1a154440 Pull-request: https://github.com/SerenityOS/serenity/pull/20951 Reviewed-by: https://github.com/AtkinsSJ ✅ Reviewed-by: https://github.com/trflynn89
1 changed files with 18 additions and 0 deletions
|
@ -28,6 +28,7 @@
|
|||
#include <LibGUI/BoxLayout.h>
|
||||
#include <LibGUI/Button.h>
|
||||
#include <LibGUI/Clipboard.h>
|
||||
#include <LibGUI/ColorPicker.h>
|
||||
#include <LibGUI/Dialog.h>
|
||||
#include <LibGUI/InputBox.h>
|
||||
#include <LibGUI/Menu.h>
|
||||
|
@ -566,6 +567,23 @@ Tab::Tab(BrowserWindow& window)
|
|||
m_dialog->done(GUI::Dialog::ExecResult::Cancel);
|
||||
};
|
||||
|
||||
view().on_request_color_picker = [this](Color current_color) {
|
||||
auto& window = this->window();
|
||||
|
||||
m_dialog = GUI::ColorPicker::construct(current_color, &window);
|
||||
auto& dialog = static_cast<GUI::ColorPicker&>(*m_dialog);
|
||||
|
||||
dialog.set_icon(window.icon());
|
||||
dialog.set_color_has_alpha_channel(false);
|
||||
|
||||
if (dialog.exec() == GUI::ColorPicker::ExecResult::OK)
|
||||
view().color_picker_closed(dialog.color());
|
||||
else
|
||||
view().color_picker_closed({});
|
||||
|
||||
m_dialog = nullptr;
|
||||
};
|
||||
|
||||
view().on_received_source = [this](auto& url, auto& source) {
|
||||
view_source(url, source);
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue