mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 21:37:35 +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);
|
||||
|
|
|
@ -231,9 +231,9 @@ void ViewImplementation::prompt_closed(Optional<String> response)
|
|||
client().async_prompt_closed(move(response));
|
||||
}
|
||||
|
||||
void ViewImplementation::color_picker_closed(Optional<Color> picked_color)
|
||||
void ViewImplementation::color_picker_update(Optional<Color> picked_color, Web::HTML::ColorPickerUpdateState state)
|
||||
{
|
||||
client().async_color_picker_closed(picked_color);
|
||||
client().async_color_picker_update(picked_color, state);
|
||||
}
|
||||
|
||||
void ViewImplementation::select_dropdown_closed(Optional<String> value)
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include <LibGfx/StandardCursor.h>
|
||||
#include <LibWeb/Forward.h>
|
||||
#include <LibWeb/HTML/ActivateTab.h>
|
||||
#include <LibWeb/HTML/ColorPickerUpdateState.h>
|
||||
#include <LibWeb/HTML/SelectItem.h>
|
||||
#include <LibWebView/Forward.h>
|
||||
#include <LibWebView/WebContentClient.h>
|
||||
|
@ -84,7 +85,7 @@ public:
|
|||
void alert_closed();
|
||||
void confirm_closed(bool accepted);
|
||||
void prompt_closed(Optional<String> response);
|
||||
void color_picker_closed(Optional<Color> picked_color);
|
||||
void color_picker_update(Optional<Color> picked_color, Web::HTML::ColorPickerUpdateState state);
|
||||
void select_dropdown_closed(Optional<String> value);
|
||||
|
||||
void toggle_media_play_state();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue