Initial commit.
This commit is contained in:
commit
59c6161fdb
134 changed files with 4751 additions and 0 deletions
50
src/windows/ui_interfaces/x11/XcbLayerInterface.cpp
Normal file
50
src/windows/ui_interfaces/x11/XcbLayerInterface.cpp
Normal file
|
@ -0,0 +1,50 @@
|
|||
#include "XcbLayerInterface.h"
|
||||
#include "XcbTextInterface.h"
|
||||
#include "RectangleElement.h"
|
||||
#include <memory>
|
||||
|
||||
uint32_t XcbLayerInterface::GetColor(ColorPtr color)
|
||||
{
|
||||
return XcbLayerInterface::GetColor(color->GetR(),
|
||||
color->GetG(), color->GetB());
|
||||
}
|
||||
|
||||
uint32_t XcbLayerInterface::GetColor(int r, int g, int b)
|
||||
{
|
||||
return b + (g<<8) + (r<<16);
|
||||
}
|
||||
|
||||
void XcbLayerInterface::ModifyGcColor(xcb_connection_t* connection, xcb_gcontext_t gc,
|
||||
ColorPtr color)
|
||||
{
|
||||
uint32_t mask = XCB_GC_FOREGROUND | XCB_GC_GRAPHICS_EXPOSURES;
|
||||
uint32_t values[2] = {XcbLayerInterface::GetColor(color), 0};
|
||||
|
||||
xcb_change_gc(connection, gc, mask, values);
|
||||
}
|
||||
|
||||
void XcbLayerInterface::AddLayer(xcb_connection_t* connection,
|
||||
xcb_screen_t* screen, xcb_window_t window, xcb_gcontext_t gc,
|
||||
VisualLayerPtr layer)
|
||||
{
|
||||
if(layer->HasText())
|
||||
{
|
||||
XcbTextInterface::AddTextElement(connection, screen, window, layer->GetText());
|
||||
}
|
||||
else if(layer->HasShape())
|
||||
{
|
||||
auto shape = layer->GetShape();
|
||||
if(shape->GetType() == GeometryElement::Type::Rectangle)
|
||||
{
|
||||
auto rectangle = std::dynamic_pointer_cast<RectangleElement>(shape);
|
||||
Pixel loc = rectangle->GetLocation();
|
||||
auto width = static_cast<uint16_t>(rectangle->GetWidth());
|
||||
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());
|
||||
xcb_poly_fill_rectangle(connection, window, gc, 1, rectangles);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue