| 105 | } |
| 106 | |
| 107 | void draw_window(Window* window, const FontRef& font, const Hit hit) |
| 108 | { |
| 109 | Surface* surface = window->surface(); |
| 110 | SurfaceLock lock(surface); |
| 111 | gfx::Rect rc = surface->bounds(); |
| 112 | gfx::Rect rc2 = rc; |
| 113 | Paint p; |
| 114 | p.style(Paint::Fill); |
| 115 | |
| 116 | // Draw custom title bar area |
| 117 | if (!window->isFullscreen()) { |
| 118 | rc2.h = kTitleBarSize; |
| 119 | |
| 120 | p.color(hit == Hit::TitleBar ? kTitleBarHigh : kTitleBarBase); |
| 121 | surface->drawRect(gfx::Rect(rc2).inflate(-kButtonSize * 3, 0), p); |
| 122 | |
| 123 | rc2.y += kTitleBarSize / 2 - 10; |
| 124 | |
| 125 | p.color(kTitleBarText); |
| 126 | draw_text(surface, font, "Custom Window", rc2.center(), &p, TextAlign::Center); |
| 127 | |
| 128 | // Draw buttons |
| 129 | draw_button(surface, rc.x2() - kButtonSize, Hit::CloseButton, hit); |
| 130 | draw_button(surface, rc.x2() - kButtonSize * 2, Hit::MaximizeButton, hit); |
| 131 | draw_button(surface, rc.x2() - kButtonSize * 3, Hit::MinimizeButton, hit); |
| 132 | |
| 133 | // Client area |
| 134 | rc2 = rc; |
| 135 | rc2.y += kTitleBarSize; |
| 136 | rc2.h -= kTitleBarSize; |
| 137 | } |
| 138 | |
| 139 | // Draw client area |
| 140 | p.color(hit == Hit::Content ? kContentHigh : kContentBase); |
| 141 | surface->drawRect(rc2, p); |
| 142 | |
| 143 | p.style(Paint::Style::Stroke); |
| 144 | p.color(kContentEdge); |
| 145 | surface->drawRect(rc2, p); |
| 146 | |
| 147 | p.style(Paint::Style::Fill); |
| 148 | p.color(kContentText); |
| 149 | draw_text(surface, font, "Content Rect", rc2.center(), &p, TextAlign::Center); |
| 150 | |
| 151 | if (window->isFullscreen()) { |
| 152 | auto pos = rc2.center(); |
| 153 | pos.y += 24; |
| 154 | draw_text(surface, font, "(F key or F11 to exit full screen)", pos, &p, TextAlign::Center); |
| 155 | } |
| 156 | |
| 157 | if (window->isVisible()) |
| 158 | window->invalidateRegion(gfx::Region(rc)); |
| 159 | else |
| 160 | window->setVisible(true); |
| 161 | } |
| 162 | |
| 163 | bool update_hit(Window* window, const Event& ev, Hit& hit) |
| 164 | { |
no test coverage detected