|
| 1 | +/* |
| 2 | + * Copyright (c) Microsoft Corporation. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +package com.microsoft.playwright; |
| 18 | + |
| 19 | + |
| 20 | +/** |
| 21 | + * Interface for managing page overlays that display persistent visual indicators on top of the page. |
| 22 | + */ |
| 23 | +public interface Overlay { |
| 24 | + class ShowOptions { |
| 25 | + /** |
| 26 | + * Duration in milliseconds after which the overlay is automatically removed. Overlay stays until dismissed if not |
| 27 | + * provided. |
| 28 | + */ |
| 29 | + public Double duration; |
| 30 | + |
| 31 | + /** |
| 32 | + * Duration in milliseconds after which the overlay is automatically removed. Overlay stays until dismissed if not |
| 33 | + * provided. |
| 34 | + */ |
| 35 | + public ShowOptions setDuration(double duration) { |
| 36 | + this.duration = duration; |
| 37 | + return this; |
| 38 | + } |
| 39 | + } |
| 40 | + class ChapterOptions { |
| 41 | + /** |
| 42 | + * Optional description text displayed below the title. |
| 43 | + */ |
| 44 | + public String description; |
| 45 | + /** |
| 46 | + * Duration in milliseconds after which the overlay is automatically removed. Defaults to {@code 2000}. |
| 47 | + */ |
| 48 | + public Double duration; |
| 49 | + |
| 50 | + /** |
| 51 | + * Optional description text displayed below the title. |
| 52 | + */ |
| 53 | + public ChapterOptions setDescription(String description) { |
| 54 | + this.description = description; |
| 55 | + return this; |
| 56 | + } |
| 57 | + /** |
| 58 | + * Duration in milliseconds after which the overlay is automatically removed. Defaults to {@code 2000}. |
| 59 | + */ |
| 60 | + public ChapterOptions setDuration(double duration) { |
| 61 | + this.duration = duration; |
| 62 | + return this; |
| 63 | + } |
| 64 | + } |
| 65 | + /** |
| 66 | + * Adds an overlay with the given HTML content. The overlay is displayed on top of the page until removed. Returns a |
| 67 | + * disposable that removes the overlay when disposed. |
| 68 | + * |
| 69 | + * @param html HTML content for the overlay. |
| 70 | + * @since v1.59 |
| 71 | + */ |
| 72 | + default AutoCloseable show(String html) { |
| 73 | + return show(html, null); |
| 74 | + } |
| 75 | + /** |
| 76 | + * Adds an overlay with the given HTML content. The overlay is displayed on top of the page until removed. Returns a |
| 77 | + * disposable that removes the overlay when disposed. |
| 78 | + * |
| 79 | + * @param html HTML content for the overlay. |
| 80 | + * @since v1.59 |
| 81 | + */ |
| 82 | + AutoCloseable show(String html, ShowOptions options); |
| 83 | + /** |
| 84 | + * Shows a chapter overlay with a title and optional description, centered on the page with a blurred backdrop. Useful for |
| 85 | + * narrating video recordings. The overlay is removed after the specified duration, or 2000ms. |
| 86 | + * |
| 87 | + * @param title Title text displayed prominently in the overlay. |
| 88 | + * @since v1.59 |
| 89 | + */ |
| 90 | + default void chapter(String title) { |
| 91 | + chapter(title, null); |
| 92 | + } |
| 93 | + /** |
| 94 | + * Shows a chapter overlay with a title and optional description, centered on the page with a blurred backdrop. Useful for |
| 95 | + * narrating video recordings. The overlay is removed after the specified duration, or 2000ms. |
| 96 | + * |
| 97 | + * @param title Title text displayed prominently in the overlay. |
| 98 | + * @since v1.59 |
| 99 | + */ |
| 100 | + void chapter(String title, ChapterOptions options); |
| 101 | + /** |
| 102 | + * Sets visibility of all overlays without removing them. |
| 103 | + * |
| 104 | + * @param visible Whether overlays should be visible. |
| 105 | + * @since v1.59 |
| 106 | + */ |
| 107 | + void setVisible(boolean visible); |
| 108 | +} |
| 109 | + |
0 commit comments