Running on Linux again and small clean up.

This commit is contained in:
jmsgrogan 2021-03-06 16:02:13 -05:00
parent 683ba5447f
commit 2bde5567be
24 changed files with 113 additions and 60 deletions

View file

@ -1,6 +1,9 @@
#include "XcbLayerInterface.h"
#include "XcbTextInterface.h"
#include "RectangleElement.h"
#include "VisualLayer.h"
#include <memory>
uint32_t XcbLayerInterface::GetColor(const Color* color)
@ -36,10 +39,10 @@ void XcbLayerInterface::AddLayer(xcb_connection_t* connection,
auto shape = layer->GetShape();
if(shape->GetType() == GeometryElement::Type::Rectangle)
{
auto rectangle = dynamic_cast<RectangleElement*>(shape);
Pixel loc = rectangle->GetLocation();
auto width = static_cast<uint16_t>(rectangle->GetWidth());
auto height = static_cast<uint16_t>(rectangle->GetHeight());
const auto rectangle = dynamic_cast<RectangleElement*>(shape);
const auto loc = rectangle->GetLocation();
const auto width = static_cast<uint16_t>(rectangle->GetWidth());
const auto height = static_cast<uint16_t>(rectangle->GetHeight());
xcb_rectangle_t rectangles[] = { { static_cast<int16_t>(loc.GetX()),
static_cast<int16_t>(loc.GetY()), width, height} };
XcbLayerInterface::ModifyGcColor(connection, gc, rectangle->GetFillColor());

View file

@ -1,8 +1,9 @@
#pragma once
#include <xcb/xcb.h>
#include "VisualLayer.h"
#include "Color.h"
class Color;
class VisualLayer;
class XcbLayerInterface
{

View file

@ -1,12 +1,15 @@
#include "XcbTextInterface.h"
#include "XcbLayerInterface.h"
#include "VisualLayer.h"
#include "Color.h"
#include "RectangleElement.h"
#include <string.h>
xcb_gcontext_t XcbTextInterface::GetFontGC(xcb_connection_t *connection,
xcb_screen_t *screen, xcb_window_t window, const char*font_name,
xcb_screen_t *screen, xcb_window_t window, const char* font_name,
const TextElement* textElement)
{
/* get font */
xcb_font_t font = xcb_generate_id(connection);
xcb_open_font(connection, font, strlen(font_name), font_name);
@ -28,11 +31,11 @@ void XcbTextInterface::AddTextElement(xcb_connection_t* connection,
const TextElement* textElement)
{
/* get graphics context */
xcb_gcontext_t gc = XcbTextInterface::GetFontGC(connection, screen, window,
auto gc = XcbTextInterface::GetFontGC(connection, screen, window,
textElement->GetFontLabel().c_str(), textElement);
/* draw the text */
std::string content = textElement->GetContent();
const auto content = textElement->GetContent();
Pixel loc = textElement->GetLocation();
xcb_image_text_8(connection, content.length(), window, gc,
loc.GetX(), loc.GetY(), content.c_str());