MCPcopy Create free account
hub / github.com/aseprite/laf / draw_window

Function draw_window

examples/custom_window.cpp:107–161  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

105}
106
107void 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
163bool update_hit(Window* window, const Event& ev, Hit& hit)
164{

Callers 1

app_mainFunction · 0.70

Calls 14

draw_buttonFunction · 0.85
x2Method · 0.80
draw_textFunction · 0.50
RegionClass · 0.50
surfaceMethod · 0.45
boundsMethod · 0.45
styleMethod · 0.45
isFullscreenMethod · 0.45
colorMethod · 0.45
drawRectMethod · 0.45
centerMethod · 0.45
isVisibleMethod · 0.45

Tested by

no test coverage detected