somebar/src/bar.hpp

40 lines
1009 B
C++
Raw Normal View History

2021-10-20 20:20:27 +02:00
// somebar - dwl bar
// See LICENSE file for copyright and license details.
#pragma once
2021-10-20 20:45:23 +02:00
#include <optional>
2021-10-22 15:34:19 +02:00
#include <vector>
2021-10-20 20:20:27 +02:00
#include <wayland-client.h>
2021-10-22 15:34:19 +02:00
#include <QString>
#include <QFontMetrics>
2021-10-22 15:42:42 +02:00
#include <QPainter>
2021-10-20 20:20:27 +02:00
#include "wlr-layer-shell-unstable-v1-client-protocol.h"
#include "common.hpp"
#include "shm_buffer.hpp"
2021-10-22 15:34:19 +02:00
struct Tag {
QString name;
bool active;
};
2021-10-20 20:20:27 +02:00
class Bar {
2021-10-20 20:45:23 +02:00
static const zwlr_layer_surface_v1_listener _layerSurfaceListener;
2021-10-20 20:20:27 +02:00
wl_surface *_surface {nullptr};
zwlr_layer_surface_v1 *_layerSurface {nullptr};
2021-10-22 15:42:42 +02:00
QPainter *_painter {nullptr};
2021-10-22 15:34:19 +02:00
std::optional<QFontMetrics> _fontMetrics;
2021-10-20 20:45:23 +02:00
std::optional<ShmBuffer> _bufs;
2021-10-22 15:34:19 +02:00
std::vector<Tag> _tags;
int _textY;
2021-10-20 20:45:23 +02:00
void layerSurfaceConfigure(uint32_t serial, uint32_t width, uint32_t height);
2021-10-20 21:09:19 +02:00
void render();
2021-10-22 15:34:19 +02:00
void renderTags(QPainter &painter);
int textWidth(const QString &text);
2021-10-22 15:42:42 +02:00
void setColorScheme(const ColorScheme &scheme);
2021-10-20 20:20:27 +02:00
public:
2021-10-20 20:45:23 +02:00
explicit Bar(const wl_output *output);
~Bar();
2021-10-20 20:20:27 +02:00
};