1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-24 18:57:42 +00:00

Snazz up the windows with some title bar gradients. :^)

This commit is contained in:
Andreas Kling 2019-01-25 05:01:27 +01:00
parent c6b7b92625
commit 0db72786cf
7 changed files with 95 additions and 9 deletions

View file

@ -150,6 +150,35 @@ void exception_6_handler(RegisterDump& regs)
current->crash(); current->crash();
} }
// 7: FPU exception
EH_ENTRY_NO_CODE(7);
void exception_7_handler(RegisterDump& regs)
{
(void)regs;
#ifdef FPU_EXCEPTION_DEBUG
kprintf("%s FPU exception: %u(%s)\n", current->isRing0() ? "Kernel" : "Process", current->pid(), current->name().characters());
word ss;
dword esp;
if (current->isRing0()) {
ss = regs.ds;
esp = regs.esp;
} else {
ss = regs.ss_if_crossRing;
esp = regs.esp_if_crossRing;
}
kprintf("pc=%w:%x ds=%w es=%w fs=%w gs=%w\n", regs.cs, regs.eip, regs.ds, regs.es, regs.fs, regs.gs);
kprintf("stk=%w:%x\n", ss, esp);
kprintf("eax=%x ebx=%x ecx=%x edx=%x\n", regs.eax, regs.ebx, regs.ecx, regs.edx);
kprintf("ebp=%x esp=%x esi=%x edi=%x\n", regs.ebp, esp, regs.esi, regs.edi);
#endif
// FIXME: Do stuff.
asm volatile("clts");
}
// 13: General Protection Fault // 13: General Protection Fault
EH_ENTRY(13); EH_ENTRY(13);
void exception_13_handler(RegisterDumpWithExceptionCode& regs) void exception_13_handler(RegisterDumpWithExceptionCode& regs)
@ -280,7 +309,6 @@ EH(2, "Unknown error")
EH(3, "Breakpoint") EH(3, "Breakpoint")
EH(4, "Overflow") EH(4, "Overflow")
EH(5, "Bounds check") EH(5, "Bounds check")
EH(7, "Coprocessor not available")
EH(8, "Double fault") EH(8, "Double fault")
EH(9, "Coprocessor segment overrun") EH(9, "Coprocessor segment overrun")
EH(10, "Invalid TSS") EH(10, "Invalid TSS")
@ -408,7 +436,7 @@ void idt_init()
register_interrupt_handler(0x04, _exception4); register_interrupt_handler(0x04, _exception4);
register_interrupt_handler(0x05, _exception5); register_interrupt_handler(0x05, _exception5);
register_interrupt_handler(0x06, exception_6_entry); register_interrupt_handler(0x06, exception_6_entry);
register_interrupt_handler(0x07, _exception7); register_interrupt_handler(0x07, exception_7_entry);
register_interrupt_handler(0x08, _exception8); register_interrupt_handler(0x08, _exception8);
register_interrupt_handler(0x09, _exception9); register_interrupt_handler(0x09, _exception9);
register_interrupt_handler(0x0a, _exception10); register_interrupt_handler(0x0a, _exception10);

View file

@ -138,6 +138,10 @@ void init()
gdt_init(); gdt_init();
idt_init(); idt_init();
#ifndef NO_FPU
asm volatile("fninit");
#endif
VFS::initialize_globals(); VFS::initialize_globals();
vfs = new VFS; vfs = new VFS;

View file

@ -29,6 +29,10 @@ public:
Color(byte r, byte g, byte b) : m_value((r << 16) | (g << 8) | b) { } Color(byte r, byte g, byte b) : m_value((r << 16) | (g << 8) | b) { }
Color(RGBA32 rgba) : m_value(rgba) { } Color(RGBA32 rgba) : m_value(rgba) { }
int red() const { return (m_value >> 16) & 0xff; }
int green() const { return (m_value >> 8) & 0xff; }
int blue() const { return m_value & 0xff; }
RGBA32 value() const { return m_value; } RGBA32 value() const { return m_value; }
private: private:

View file

@ -74,6 +74,45 @@ void Painter::fill_rect(const Rect& a_rect, Color color)
} }
} }
void Painter::fill_rect_with_gradient(const Rect& a_rect, Color gradient_start, Color gradient_end)
{
#ifdef NO_FPU
return fill_rect(a_rect, gradient_start);
#endif
auto rect = a_rect;
rect.move_by(m_translation);
auto clipped_rect = Rect::intersection(rect, m_clip_rect);
if (clipped_rect.is_empty())
return;
int x_offset = clipped_rect.x() - rect.x();
RGBA32* dst = m_target->scanline(clipped_rect.top()) + clipped_rect.left();
const unsigned dst_skip = m_target->width();
float increment = (1.0/((rect.width())/255.0));
int r2 = gradient_start.red();
int g2 = gradient_start.green();
int b2 = gradient_start.blue();
int r1 = gradient_end.red();
int g1 = gradient_end.green();
int b1 = gradient_end.blue();
for (int i = clipped_rect.height() - 1; i >= 0; --i) {
float c = x_offset * increment;
for (int j = 0; j < clipped_rect.width(); ++j) {
dst[j] = Color(
r1 / 255.0 * c + r2 / 255.0 * (255 - c),
g1 / 255.0 * c + g2 / 255.0 * (255 - c),
b1 / 255.0 * c + b2 / 255.0 * (255 - c)
).value();
c += increment;
}
dst += dst_skip;
}
}
void Painter::draw_rect(const Rect& a_rect, Color color) void Painter::draw_rect(const Rect& a_rect, Color color)
{ {
Rect rect = a_rect; Rect rect = a_rect;

View file

@ -23,6 +23,7 @@ public:
explicit Painter(GraphicsBitmap&); explicit Painter(GraphicsBitmap&);
~Painter(); ~Painter();
void fill_rect(const Rect&, Color); void fill_rect(const Rect&, Color);
void fill_rect_with_gradient(const Rect&, Color gradient_start, Color gradient_end);
void draw_rect(const Rect&, Color); void draw_rect(const Rect&, Color);
void draw_bitmap(const Point&, const CharacterBitmap&, Color = Color()); void draw_bitmap(const Point&, const CharacterBitmap&, Color = Color());
void set_pixel(const Point&, Color); void set_pixel(const Point&, Color);

View file

@ -121,12 +121,15 @@ WSWindowManager::WSWindowManager()
m_front_painter = make<Painter>(*m_front_bitmap); m_front_painter = make<Painter>(*m_front_bitmap);
m_back_painter = make<Painter>(*m_back_bitmap); m_back_painter = make<Painter>(*m_back_bitmap);
m_background_color = Color(0, 72, 96); m_background_color = Color(50, 50, 50);
m_active_window_border_color = Color(0, 64, 192); m_active_window_border_color = Color(110, 34, 9);
m_active_window_border_color2 = Color(244, 202, 158);
m_active_window_title_color = Color::White; m_active_window_title_color = Color::White;
m_inactive_window_border_color = Color(64, 64, 64); m_inactive_window_border_color = Color(128, 128, 128);
m_inactive_window_title_color = Color::White; m_inactive_window_border_color2 = Color(192, 192, 192);
m_dragging_window_border_color = Color(32, 96, 216); m_inactive_window_title_color = Color(213, 208, 199);
m_dragging_window_border_color = Color(161, 50, 13);
m_dragging_window_border_color2 = Color(250, 220, 187);
m_dragging_window_title_color = Color::White; m_dragging_window_title_color = Color::White;
m_cursor_bitmap_inner = CharacterBitmap::create_from_ascii(cursor_bitmap_inner_ascii, 12, 17); m_cursor_bitmap_inner = CharacterBitmap::create_from_ascii(cursor_bitmap_inner_ascii, 12, 17);
@ -161,25 +164,29 @@ void WSWindowManager::paint_window_frame(WSWindow& window)
Color title_color; Color title_color;
Color border_color; Color border_color;
Color border_color2;
if (&window == m_drag_window.ptr()) { if (&window == m_drag_window.ptr()) {
border_color = m_dragging_window_border_color; border_color = m_dragging_window_border_color;
border_color2 = m_dragging_window_border_color2;
title_color = m_dragging_window_title_color; title_color = m_dragging_window_title_color;
} else if (&window == m_active_window.ptr()) { } else if (&window == m_active_window.ptr()) {
border_color = m_active_window_border_color; border_color = m_active_window_border_color;
border_color2 = m_active_window_border_color2;
title_color = m_active_window_title_color; title_color = m_active_window_title_color;
} else { } else {
border_color = m_inactive_window_border_color; border_color = m_inactive_window_border_color;
border_color2 = m_inactive_window_border_color2;
title_color = m_inactive_window_title_color; title_color = m_inactive_window_title_color;
} }
m_back_painter->fill_rect(titleBarRect, border_color); m_back_painter->fill_rect_with_gradient(titleBarRect, border_color, border_color2);
m_back_painter->draw_rect(borderRect, Color::MidGray); m_back_painter->draw_rect(borderRect, Color::MidGray);
m_back_painter->draw_rect(outerRect, border_color); m_back_painter->draw_rect(outerRect, border_color);
m_back_painter->draw_rect(inner_border_rect, border_color); m_back_painter->draw_rect(inner_border_rect, border_color);
m_back_painter->draw_text(titleBarTitleRect, window.title(), Painter::TextAlignment::CenterLeft, title_color); m_back_painter->draw_text(titleBarTitleRect, window.title(), Painter::TextAlignment::CenterLeft, title_color);
Color metadata_color(204, 204, 204); Color metadata_color(96, 96, 96);
char buffer[64]; char buffer[64];
ksprintf(buffer, "%d:%d", window.pid(), window.window_id()); ksprintf(buffer, "%d:%d", window.pid(), window.window_id());
m_back_painter->draw_text(titleBarTitleRect, buffer, Painter::TextAlignment::CenterRight, metadata_color); m_back_painter->draw_text(titleBarTitleRect, buffer, Painter::TextAlignment::CenterRight, metadata_color);

View file

@ -58,10 +58,13 @@ private:
Color m_background_color; Color m_background_color;
Color m_active_window_border_color; Color m_active_window_border_color;
Color m_active_window_border_color2;
Color m_active_window_title_color; Color m_active_window_title_color;
Color m_inactive_window_border_color; Color m_inactive_window_border_color;
Color m_inactive_window_border_color2;
Color m_inactive_window_title_color; Color m_inactive_window_title_color;
Color m_dragging_window_border_color; Color m_dragging_window_border_color;
Color m_dragging_window_border_color2;
Color m_dragging_window_title_color; Color m_dragging_window_title_color;
HashTable<WSWindow*> m_windows; HashTable<WSWindow*> m_windows;