wlmaker
|
#include "menu.h"
#include "config.h"
#include <libbase/libbase.h>
#include <linux/input-event-codes.h>
#include <wlr/types/wlr_cursor.h>
#include <wlr/types/wlr_scene.h>
#include <wlr/types/wlr_xcursor_manager.h>
Classes | |
struct | wlmaker_menu_t |
Functions | |
static wlmaker_menu_t * | menu_from_interactive (wlmaker_interactive_t *interactive_ptr) |
static void | _menu_enter (wlmaker_interactive_t *interactive_ptr) |
static void | _menu_leave (wlmaker_interactive_t *interactive_ptr) |
static void | _menu_motion (wlmaker_interactive_t *interactive_ptr, double x, double y) |
static void | _menu_focus (wlmaker_interactive_t *interactive_ptr) |
static void | _menu_button (wlmaker_interactive_t *interactive_ptr, double x, double y, struct wlr_pointer_button_event *wlr_pointer_button_event_ptr) |
static void | _menu_destroy (wlmaker_interactive_t *interactive_ptr) |
static cairo_surface_t * | create_background (wlmaker_menu_t *menu_ptr) |
static bool | items_init (wlmaker_menu_t *menu_ptr, const wlmaker_menu_item_descriptor_t *descriptor_ptr, void *callback_ud_ptr) |
static struct wlr_buffer * | create_drawn_buffer (wlmaker_menu_t *menu_ptr) |
static void | redraw_if_needed (wlmaker_menu_t *menu_ptr) |
static void | focus_item (wlmaker_menu_t *menu_ptr, wlmaker_menu_item_t *menu_item_ptr) |
static void | dlnode_draw (bs_dllist_node_t *node_ptr, void *ud_ptr) |
static bool | dlnode_contains (bs_dllist_node_t *node_ptr, void *ud_ptr) |
static bool | dlnode_needs_redraw (bs_dllist_node_t *dlnode_ptr, void *ud_ptr) |
wlmaker_interactive_t * | wlmaker_menu_create (struct wlr_scene_buffer *wlr_scene_buffer_ptr, wlmaker_cursor_t *cursor_ptr, wlmaker_view_t *view_ptr, const wlmaker_menu_item_descriptor_t *descriptor_ptr, void *callback_ud_ptr) |
void | wlmaker_menu_get_size (wlmaker_interactive_t *interactive_ptr, uint32_t *width_ptr, uint32_t *height_ptr) |
static void | test_create (bs_test_t *test_ptr) |
static void | test_select (bs_test_t *test_ptr) |
Variables | |
static const wlmaker_interactive_impl_t | wlmaker_interactive_menu_impl |
const bs_test_case_t | wlmaker_menu_test_cases [] |
static const wlmaker_menu_item_descriptor_t | test_descriptors [] |
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
|
static |
Interactive callback: Handle cursor button, ie. button press or release.
TODO: Identify menu item that was activated, forward the call.
interactive_ptr | |
x | |
y | |
wlr_pointer_button_event_ptr |
|
static |
Destroys the menu interactive.
interactive_ptr |
|
static |
Interactive callback: Cursor enters the menu area.
Will adjust the cursor image to a |left_ptr|. Actual highlighting is done by the _menu_motion call.
interactive_ptr |
|
static |
Interactive callback: Focus state changes.
TODO: Disable the menu when the focus is lost.
interactive_ptr |
|
static |
Interactive callback: Cursor leaves the button area.
Will blur (de-select) any currently focussed menu item.
interactive_ptr |
|
static |
Interactive callback: Handle cursor motion.
interactive_ptr | |
x | New cursor x pos, relative to the interactive. |
y | New cursor y pos, relative to the interactive. |
|
static |
Creates the menu's background. Expects menu_items
to be populated.
menu_ptr |
cairo_surface_t
holding the background. Must be destroyed via cairo_surface_destroy().
|
static |
Creates a struct wlr_buffer
of suitable size and draws the menu into it.
menu_ptr |
struct wlr_buffer
.
|
static |
Whether the item at |node_ptr| contains the coordinates at |ud_ptr|.
|
static |
Draws |node_ptr| into the cairo_t
at |ud_ptr|.
|
static |
Whether the item at |node_ptr| needs to be redrawn.
|
static |
Sets |menu_item_ptr| as the focussed (selected) item, and de-selects any previously selected item.
menu_ptr | |
menu_item_ptr | May be NULL. |
|
static |
Initializes the menu items, width and height from the given descriptor.
menu_ptr | |
desc_ptr | |
callback_ud_ptr | Argument to provide to item's callbacks. |
|
static |
Cast (with assertion) the |interactive_ptr| to the wlmaker_menu_t
.
interactive_ptr |
wlmaker_menu_t
|
static |
Determines whether any menu item needs a redraw, then redraws if needed.
menu_ptr |
|
static |
Tests create and destroy methods of the menu, useful for leak checks.
|
static |
Tests that the items are selected as desired.
wlmaker_interactive_t * wlmaker_menu_create | ( | struct wlr_scene_buffer * | wlr_scene_buffer_ptr, |
wlmaker_cursor_t * | cursor_ptr, | ||
wlmaker_view_t * | view_ptr, | ||
const wlmaker_menu_item_descriptor_t * | descriptor_ptr, | ||
void * | callback_ud_ptr ) |
Creates a menu interactive.
wlr_scene_buffer_ptr | Buffer scene node to contain the button. |
cursor_ptr | |
view_ptr | |
descriptor_ptr | |
callback_ud_ptr | Argument to provide to item's callbacks. |
void wlmaker_menu_get_size | ( | wlmaker_interactive_t * | interactive_ptr, |
uint32_t * | width_ptr, | ||
uint32_t * | height_ptr ) |
Retrieves the size of the menu.
interactive_ptr | |
width_ptr | |
height_ptr |
|
static |
Menu descriptor for unit tests.
|
static |
Implementation: callbacks for the interactive.
const bs_test_case_t wlmaker_menu_test_cases[] |
Unit tests.