Compare commits

..

No commits in common. "4cbdea954a9f39ec21171fba13da3a65f12c3f1e" and "2dff2c9934e6e477f232d39398e702d443795017" have entirely different histories.

5 changed files with 2 additions and 32 deletions

View File

@ -21,15 +21,6 @@ namespace ui
*/ */
bool contains(Point point); bool contains(Point point);
/**
* @brief Check if another rectangle is contained in this one.
*
* @param point The rectangle to check.
* @return true The other rectangle is contained inside this one.
* @return false The other rectangle is not contained inside this one.
*/
bool contains(Rect rect);
/** /**
* @brief Normalize a point to fit inside this rectangle. * @brief Normalize a point to fit inside this rectangle.
* *

View File

@ -101,7 +101,7 @@ namespace ui
{ {
u32 line = offset; u32 line = offset;
int mask = 1 << (m_psf_header.width - 1); int mask = 1 << (m_psf_header.width - 1);
for (int x = 0; x < width; x++) for (int x = 0; x < m_psf_header.width; x++)
{ {
if (*((u32*)glyph) & mask) *(u32*)(canvas.ptr + line) = color.raw; if (*((u32*)glyph) & mask) *(u32*)(canvas.ptr + line) = color.raw;
mask >>= 1; mask >>= 1;

View File

@ -8,15 +8,6 @@ namespace ui
(point.y <= (pos.y + height)); (point.y <= (pos.y + height));
} }
bool Rect::contains(Rect rect)
{
if (!contains(rect.pos)) return false;
Point rel = relative(rect.pos);
if ((rel.x + rect.width) > width) return false;
if ((rel.y + rect.height) > height) return false;
return true;
}
Point Rect::normalize(Point point) Point Rect::normalize(Point point)
{ {
if (point.x < pos.x) point.x = pos.x; if (point.x < pos.x) point.x = pos.x;

View File

@ -42,8 +42,6 @@ void Window::focus()
Window::Window(ui::Rect r, ui::Color c, StringView n) : surface(r), color(c), name(n) Window::Window(ui::Rect r, ui::Color c, StringView n) : surface(r), color(c), name(n)
{ {
auto font = ui::Font::default_font(); auto font = ui::Font::default_font();
if (surface.width < 36) surface.width = 36;
if (surface.height < (font->height() + 20)) surface.height = font->height() + 20;
titlebar = ui::Rect { 0, 0, surface.width, font->height() + 20 }; titlebar = ui::Rect { 0, 0, surface.width, font->height() + 20 };
close_button = ui::Rect { surface.width - 26, 10, 16, 16 }; close_button = ui::Rect { surface.width - 26, 10, 16, 16 };
contents = ui::Rect { 0, font->height() + 20, surface.width, surface.height - (font->height() + 20) }; contents = ui::Rect { 0, font->height() + 20, surface.width, surface.height - (font->height() + 20) };

View File

@ -11,13 +11,10 @@
#include <string.h> #include <string.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <sys/poll.h> #include <sys/poll.h>
#include <time.h>
#include <unistd.h> #include <unistd.h>
Result<int> luna_main(int argc, char** argv) Result<int> luna_main(int argc, char** argv)
{ {
srand((unsigned)time(NULL));
StringView socket_path = "/tmp/wind.sock"; StringView socket_path = "/tmp/wind.sock";
StringView user; StringView user;
@ -108,14 +105,7 @@ Result<int> luna_main(int argc, char** argv)
{ {
moon::KeyboardPacket packet; moon::KeyboardPacket packet;
TRY(keyboard->read_typed(packet)); TRY(keyboard->read_typed(packet));
if (!packet.released) background = ui::Color::from_rgb(0x00, 0x00, packet.key * 2);
{
TRY(make<Window>(ui::Rect { rand() % screen.canvas().width, rand() % screen.canvas().height,
rand() % screen.canvas().width, rand() % screen.canvas().height },
ui::Color::from_rgb(static_cast<u8>(rand() % 256), static_cast<u8>(rand() % 256),
static_cast<u8>(rand() % 256)),
strerror(packet.key)));
}
} }
if (fds[2].revents & POLLIN) if (fds[2].revents & POLLIN)
{ {