mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 19:37:34 +00:00
LibWeb: Allow input color to give continuous updates
This commit is contained in:
parent
cf69fd0a09
commit
0dd5aa40a8
13 changed files with 53 additions and 19 deletions
16
Userland/Libraries/LibWeb/HTML/ColorPickerUpdateState.h
Normal file
16
Userland/Libraries/LibWeb/HTML/ColorPickerUpdateState.h
Normal file
|
@ -0,0 +1,16 @@
|
|||
/*
|
||||
* Copyright (c) 2023, Bastiaan van der Plaat <bastiaan.v.d.plaat@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace Web::HTML {
|
||||
|
||||
enum class ColorPickerUpdateState {
|
||||
Update,
|
||||
Closed,
|
||||
};
|
||||
|
||||
}
|
|
@ -326,15 +326,17 @@ void Page::did_request_color_picker(WeakPtr<HTML::HTMLInputElement> target, Colo
|
|||
}
|
||||
}
|
||||
|
||||
void Page::color_picker_closed(Optional<Color> picked_color)
|
||||
void Page::color_picker_update(Optional<Color> picked_color, HTML::ColorPickerUpdateState state)
|
||||
{
|
||||
if (m_pending_non_blocking_dialog == PendingNonBlockingDialog::ColorPicker) {
|
||||
m_pending_non_blocking_dialog = PendingNonBlockingDialog::None;
|
||||
if (state == HTML::ColorPickerUpdateState::Closed)
|
||||
m_pending_non_blocking_dialog = PendingNonBlockingDialog::None;
|
||||
|
||||
if (m_pending_non_blocking_dialog_target) {
|
||||
auto& input_element = verify_cast<HTML::HTMLInputElement>(*m_pending_non_blocking_dialog_target);
|
||||
input_element.did_pick_color(move(picked_color));
|
||||
m_pending_non_blocking_dialog_target.clear();
|
||||
if (state == HTML::ColorPickerUpdateState::Closed)
|
||||
m_pending_non_blocking_dialog_target.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include <LibWeb/Cookie/Cookie.h>
|
||||
#include <LibWeb/Forward.h>
|
||||
#include <LibWeb/HTML/ActivateTab.h>
|
||||
#include <LibWeb/HTML/ColorPickerUpdateState.h>
|
||||
#include <LibWeb/HTML/SelectItem.h>
|
||||
#include <LibWeb/Loader/FileRequest.h>
|
||||
#include <LibWeb/PixelUnits.h>
|
||||
|
@ -128,7 +129,7 @@ public:
|
|||
void accept_dialog();
|
||||
|
||||
void did_request_color_picker(WeakPtr<HTML::HTMLInputElement> target, Color current_color);
|
||||
void color_picker_closed(Optional<Color> picked_color);
|
||||
void color_picker_update(Optional<Color> picked_color, HTML::ColorPickerUpdateState state);
|
||||
|
||||
void did_request_select_dropdown(WeakPtr<HTML::HTMLSelectElement> target, Web::CSSPixelPoint content_position, Web::CSSPixels minimum_width, Vector<Web::HTML::SelectItem> items);
|
||||
void select_dropdown_closed(Optional<String> value);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue