Render close, iconify and maximize buttons

This commit is contained in:
Johan Malm 2020-07-06 21:58:51 +01:00
parent e1b86555f4
commit f7fa28ab42
10 changed files with 140 additions and 53 deletions

View file

@ -5,64 +5,84 @@
*/
#include "labwc.h"
#include "theme.h"
/* Based on expected font height of Sans 8 */
#define TITLE_HEIGHT (14)
#define BORDER_WIDTH (1)
struct wlr_box deco_max_extents(struct view *view)
{
struct wlr_box box = {
.x = view->x - XWL_WINDOW_BORDER,
.y = view->y - XWL_TITLEBAR_HEIGHT - XWL_WINDOW_BORDER,
.width = view->surface->current.width + 2 * XWL_WINDOW_BORDER,
.height = view->surface->current.height + XWL_TITLEBAR_HEIGHT +
2 * XWL_WINDOW_BORDER,
.x = view->x - BORDER_WIDTH,
.y = view->y - TITLE_HEIGHT - BORDER_WIDTH,
.width = view->surface->current.width + 2 * BORDER_WIDTH,
.height = view->surface->current.height + TITLE_HEIGHT +
2 * BORDER_WIDTH,
};
return box;
}
struct wlr_box deco_box(struct view *view, enum deco_part deco_part)
{
int margin;
struct wlr_box box = { .x = 0, .y = 0, .width = 0, .height = 0 };
if (!view || !view->surface)
return box;
switch (deco_part) {
case LAB_DECO_ICON_CLOSE:
box.x = view->x + view->surface->current.width - 8 - 1;
box.y = view->y - XWL_TITLEBAR_HEIGHT + 1;
box.width = 8;
box.height = 8;
case LAB_DECO_BUTTON_CLOSE:
wlr_texture_get_size(theme.xbm_close, &box.width, &box.height);
margin = (TITLE_HEIGHT - box.height) / 2;
box.x = view->x + view->surface->current.width + margin -
TITLE_HEIGHT;
box.y = view->y - TITLE_HEIGHT + margin;
break;
case LAB_DECO_BUTTON_MAXIMIZE:
wlr_texture_get_size(theme.xbm_maximize, &box.width,
&box.height);
margin = (TITLE_HEIGHT - box.height) / 2;
box.x = view->x + view->surface->current.width + margin -
TITLE_HEIGHT * 2;
box.y = view->y - TITLE_HEIGHT + margin;
break;
case LAB_DECO_BUTTON_ICONIFY:
wlr_texture_get_size(theme.xbm_iconify, &box.width,
&box.height);
margin = (TITLE_HEIGHT - box.height) / 2;
box.x = view->x + view->surface->current.width + margin -
TITLE_HEIGHT * 3;
box.y = view->y - TITLE_HEIGHT + margin;
break;
case LAB_DECO_PART_TITLE:
box.x = view->x;
box.y = view->y - XWL_TITLEBAR_HEIGHT;
box.y = view->y - TITLE_HEIGHT;
box.width = view->surface->current.width;
box.height = XWL_TITLEBAR_HEIGHT;
box.height = TITLE_HEIGHT;
break;
case LAB_DECO_PART_TOP:
box.x = view->x - XWL_WINDOW_BORDER;
box.y = view->y - XWL_TITLEBAR_HEIGHT - XWL_WINDOW_BORDER;
box.width =
view->surface->current.width + 2 * XWL_WINDOW_BORDER;
box.height = XWL_WINDOW_BORDER;
box.x = view->x - BORDER_WIDTH;
box.y = view->y - TITLE_HEIGHT - BORDER_WIDTH;
box.width = view->surface->current.width + 2 * BORDER_WIDTH;
box.height = BORDER_WIDTH;
break;
case LAB_DECO_PART_RIGHT:
box.x = view->x + view->surface->current.width;
box.y = view->y - XWL_TITLEBAR_HEIGHT;
box.width = XWL_WINDOW_BORDER;
box.height =
view->surface->current.height + XWL_TITLEBAR_HEIGHT;
box.y = view->y - TITLE_HEIGHT;
box.width = BORDER_WIDTH;
box.height = view->surface->current.height + TITLE_HEIGHT;
break;
case LAB_DECO_PART_BOTTOM:
box.x = view->x - XWL_WINDOW_BORDER;
box.x = view->x - BORDER_WIDTH;
box.y = view->y + view->surface->current.height;
box.width =
view->surface->current.width + 2 * XWL_WINDOW_BORDER;
box.height = +XWL_WINDOW_BORDER;
box.width = view->surface->current.width + 2 * BORDER_WIDTH;
box.height = +BORDER_WIDTH;
break;
case LAB_DECO_PART_LEFT:
box.x = view->x - XWL_WINDOW_BORDER;
box.y = view->y - XWL_TITLEBAR_HEIGHT;
box.width = XWL_WINDOW_BORDER;
box.height =
view->surface->current.height + XWL_TITLEBAR_HEIGHT;
box.x = view->x - BORDER_WIDTH;
box.y = view->y - TITLE_HEIGHT;
box.width = BORDER_WIDTH;
box.height = view->surface->current.height + TITLE_HEIGHT;
break;
default:
break;