mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Make it possible to add a title to context menu
This commit is contained in:
parent
687156ac90
commit
0b489a0135
9 changed files with 33 additions and 18 deletions
|
@ -67,12 +67,17 @@ void prompt_alert(const char *message, bool trusted) {
|
|||
sServo->Delegate().OnServoPromptAlert(char2hstring(message), trusted);
|
||||
}
|
||||
|
||||
void show_context_menu(const char *const *items_list, uint32_t items_size) {
|
||||
void show_context_menu(const char *title, const char *const *items_list,
|
||||
uint32_t items_size) {
|
||||
std::optional<hstring> opt_title = {};
|
||||
if (title != nullptr) {
|
||||
opt_title = char2hstring(title);
|
||||
}
|
||||
std::vector<winrt::hstring> items;
|
||||
for (uint32_t i = 0; i < items_size; i++) {
|
||||
items.push_back(char2hstring(items_list[i]));
|
||||
}
|
||||
sServo->Delegate().OnServoShowContextMenu(items);
|
||||
sServo->Delegate().OnServoShowContextMenu(opt_title, items);
|
||||
}
|
||||
|
||||
void on_devtools_started(Servo::DevtoolsServerState result,
|
||||
|
|
|
@ -105,7 +105,8 @@ public:
|
|||
virtual void OnServoMediaSessionMetadata(hstring, hstring, hstring) = 0;
|
||||
virtual void OnServoMediaSessionPlaybackStateChange(int) = 0;
|
||||
virtual void OnServoPromptAlert(hstring, bool) = 0;
|
||||
virtual void OnServoShowContextMenu(std::vector<hstring>) = 0;
|
||||
virtual void OnServoShowContextMenu(std::optional<hstring>,
|
||||
std::vector<hstring>) = 0;
|
||||
virtual Servo::PromptResult OnServoPromptOkCancel(hstring, bool) = 0;
|
||||
virtual Servo::PromptResult OnServoPromptYesNo(hstring, bool) = 0;
|
||||
virtual std::optional<hstring> OnServoPromptInput(hstring, hstring, bool) = 0;
|
||||
|
|
|
@ -564,9 +564,10 @@ void ServoControl::OnServoDevtoolsStarted(bool success,
|
|||
});
|
||||
}
|
||||
|
||||
void ServoControl::OnServoShowContextMenu(std::vector<winrt::hstring> items) {
|
||||
void ServoControl::OnServoShowContextMenu(std::optional<hstring> title,
|
||||
std::vector<winrt::hstring> items) {
|
||||
RunOnUIThread([=] {
|
||||
MessageDialog msg{L"Menu"};
|
||||
MessageDialog msg{title.value_or(L"Menu")};
|
||||
for (auto i = 0; i < items.size(); i++) {
|
||||
UICommand cmd{items[i], [=](auto) {
|
||||
RunOnGLThread([=] {
|
||||
|
|
|
@ -117,7 +117,8 @@ struct ServoControl : ServoControlT<ServoControl>, public servo::ServoDelegate {
|
|||
winrt::hstring);
|
||||
virtual void OnServoMediaSessionPlaybackStateChange(int);
|
||||
virtual void OnServoPromptAlert(winrt::hstring, bool);
|
||||
virtual void OnServoShowContextMenu(std::vector<winrt::hstring>);
|
||||
virtual void OnServoShowContextMenu(std::optional<winrt::hstring>,
|
||||
std::vector<winrt::hstring>);
|
||||
virtual servo::Servo::PromptResult OnServoPromptOkCancel(winrt::hstring,
|
||||
bool);
|
||||
virtual servo::Servo::PromptResult OnServoPromptYesNo(winrt::hstring, bool);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue