| 29 | } |
| 30 | |
| 31 | void WMWindow::Draw(surface_t* surface){ |
| 32 | if(minimized) return; |
| 33 | |
| 34 | if(flags & WINDOW_FLAGS_NODECORATION){ |
| 35 | surface_t wSurface = {.width = size.x, .height = size.y, .buffer = ((windowBufferInfo->currentBuffer == 0) ? buffer1 : buffer2)}; |
| 36 | Lemon::Graphics::surfacecpy(surface, &wSurface, pos); |
| 37 | return; |
| 38 | } |
| 39 | |
| 40 | Lemon::Graphics::DrawRectOutline(pos.x, pos.y, size.x + WINDOW_BORDER_THICKNESS * 2, size.y + WINDOW_TITLEBAR_HEIGHT + WINDOW_BORDER_THICKNESS * 2, WINDOW_BORDER_COLOUR, surface); |
| 41 | Lemon::Graphics::DrawRectOutline(pos.x + (WINDOW_BORDER_THICKNESS / 2), pos.y + WINDOW_TITLEBAR_HEIGHT + (WINDOW_BORDER_THICKNESS / 2), size.x + WINDOW_BORDER_THICKNESS, size.y + WINDOW_BORDER_THICKNESS, {42, 50, 64}, surface); |
| 42 | Lemon::Graphics::DrawGradientVertical({pos + (vector2i_t){1,1}, {size.x + WINDOW_BORDER_THICKNESS, WINDOW_TITLEBAR_HEIGHT}}, {0x33, 0x2c, 0x29, 255}, {0x2e, 0x29, 0x29, 255}, surface); |
| 43 | |
| 44 | Lemon::Graphics::DrawString(title.c_str(), pos.x + 6, pos.y + 6, 255, 255, 255, surface); |
| 45 | |
| 46 | surface_t* buttons = &wm->compositor.windowButtons; |
| 47 | |
| 48 | if(Lemon::Graphics::PointInRect({{closeRect.x + pos.x, closeRect.y + pos.y}, closeRect.size}, wm->input.mouse.pos)){ |
| 49 | Lemon::Graphics::surfacecpy(surface, buttons, pos + closeRect.pos, {{0, 19}, {19, 19}}); // Close button |
| 50 | } else { |
| 51 | Lemon::Graphics::surfacecpyTransparent(surface, buttons, pos + closeRect.pos, {{0, 0}, {19, 19}}); // Close button |
| 52 | } |
| 53 | |
| 54 | if(Lemon::Graphics::PointInRect({{pos.x + minimizeRect.x, pos.y + minimizeRect.y}, minimizeRect.size}, wm->input.mouse.pos)){ |
| 55 | Lemon::Graphics::surfacecpy(surface, buttons, pos + minimizeRect.pos, {{19, 19}, {19, 19}}); // Minimize button |
| 56 | } else { |
| 57 | Lemon::Graphics::surfacecpyTransparent(surface, buttons, pos + minimizeRect.pos, {{19, 0}, {19, 19}}); // Minimize button |
| 58 | } |
| 59 | |
| 60 | windowBufferInfo->drawing = 1; |
| 61 | surface_t wSurface = {.width = size.x, .height = size.y, .buffer = ((windowBufferInfo->currentBuffer == 0) ? buffer1 : buffer2)}; |
| 62 | |
| 63 | vector2i_t clipOffset = pos + (vector2i_t){WINDOW_BORDER_THICKNESS, WINDOW_BORDER_THICKNESS + WINDOW_TITLEBAR_HEIGHT}; |
| 64 | |
| 65 | #ifdef LEMONWM_USE_CLIPPING |
| 66 | for(rect_t& clip : clips){ |
| 67 | Lemon::Graphics::surfacecpy(surface, &wSurface, clip.pos, {clip.pos - clipOffset, clip.size}); |
| 68 | } |
| 69 | #else |
| 70 | Lemon::Graphics::surfacecpy(surface, &wSurface, clipOffset); |
| 71 | #endif |
| 72 | |
| 73 | windowBufferInfo->drawing = 0; |
| 74 | } |
| 75 | |
| 76 | void WMWindow::Minimize(bool state){ |
| 77 | minimized = state; |
no test coverage detected