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

Method scrollAndDrawLog

examples/allevents.cpp:147–191  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

145 void recalcMaxLines() { m_maxlines = (m_window->height() - m_lineHeight) / m_lineHeight; }
146
147 void scrollAndDrawLog(const int newlines)
148 {
149 Surface* surface = m_window->surface();
150 const gfx::Rect rc = surface->bounds();
151
152 Paint p;
153 p.style(Paint::Fill);
154 p.color(gfx::rgba(0, 0, 0, 8));
155
156 // Scroll old lines
157 int i;
158 if (m_textLog.size() >= m_maxlines) {
159 int h = m_lineHeight * newlines;
160 surface->scrollTo(rc, 0, -h);
161
162 surface->drawRect(gfx::Rect(rc.x, rc.y, rc.w, rc.h - h), p);
163 p.color(gfx::rgba(0, 0, 0));
164 surface->drawRect(gfx::Rect(rc.x, rc.y + rc.h - h, rc.w, h), p);
165
166 i = (m_textLog.size() - newlines);
167 }
168 // First lines without scroll
169 else {
170 i = m_oldLogSize;
171 surface->drawRect(gfx::Rect(rc.x, rc.y, rc.w, i * m_lineHeight), p);
172 }
173
174 Paint paint;
175 paint.color(gfx::rgba(255, 255, 255));
176 for (; i < m_textLog.size(); ++i) {
177 // Use shaper so we can paint emojis in the log
178 draw_text(surface, m_textLog[i], gfx::PointF(0, i * m_lineHeight), &paint);
179 }
180
181 gfx::Rgb rgb(gfx::Hsv(m_hue, 1.0, 1.0));
182 paint.color(gfx::rgba(rgb.red(), rgb.green(), rgb.blue()));
183 paint.antialias(true);
184 surface->drawCircle(m_mousePos.x, m_mousePos.y, m_brushSize, paint);
185
186 // Invalidates the whole window to show it on the screen.
187 if (m_window->isVisible())
188 m_window->invalidateRegion(gfx::Region(rc));
189 else
190 m_window->setVisible(true);
191 }
192
193 void logMouseEvent(const Event& ev, const char* eventName)
194 {

Callers

nothing calls this directly

Calls 15

rgbaFunction · 0.85
scrollToMethod · 0.80
redMethod · 0.80
greenMethod · 0.80
blueMethod · 0.80
draw_textFunction · 0.50
HsvClass · 0.50
RegionClass · 0.50
surfaceMethod · 0.45
boundsMethod · 0.45
styleMethod · 0.45
colorMethod · 0.45

Tested by

no test coverage detected