()
| 2237 | } |
| 2238 | |
| 2239 | func (label *Label) Draw() { |
| 2240 | |
| 2241 | // Recreating the texture is only necessary of the texture is dirty; this flag ensures that |
| 2242 | // doing two operations on the Label (i.e. setting the Label's Rectangle size and setting its text) |
| 2243 | // don't necessitate two recreations of its underlying texture |
| 2244 | if label.TextureDirty { |
| 2245 | label.RecreateTexture() |
| 2246 | if label.OnChange != nil && label.textChanged { |
| 2247 | label.OnChange() |
| 2248 | } |
| 2249 | } |
| 2250 | |
| 2251 | mousePos := globals.Mouse.Position() |
| 2252 | |
| 2253 | if label.WorldSpace { |
| 2254 | mousePos = globals.Mouse.WorldPosition() |
| 2255 | } |
| 2256 | |
| 2257 | if label.Editable && label.RendererResult != nil && label.DrawLineUnderTitle { |
| 2258 | |
| 2259 | thickness := float32(2) |
| 2260 | |
| 2261 | lineY := float32(0) |
| 2262 | |
| 2263 | // if nextBreak := strings.Index(label.TextAsString(), "\n"); nextBreak >= 0 { |
| 2264 | |
| 2265 | if nextBreak := label.IndexOfRunes(0, "\n"); nextBreak >= 0 { |
| 2266 | lineY = label.IndexToWorld(nextBreak).Y + globals.GridSize |
| 2267 | } else { |
| 2268 | lineY = label.Rect.Y + label.RendererResult.TextSize.Y + thickness |
| 2269 | } |
| 2270 | |
| 2271 | if lineY > label.Rect.Y+label.Rect.H { |
| 2272 | lineY = label.Rect.Y + label.Rect.H |
| 2273 | } |
| 2274 | |
| 2275 | start := Vector{label.Rect.X, lineY + thickness} |
| 2276 | end := start.AddF(label.Rect.W-8, 0) |
| 2277 | if label.WorldSpace { |
| 2278 | start = globals.Project.Camera.TranslatePoint(start) |
| 2279 | end = globals.Project.Camera.TranslatePoint(end) |
| 2280 | } |
| 2281 | |
| 2282 | ThickLine(start, end, thickness, getThemeColor(GUIFontColor)) |
| 2283 | |
| 2284 | } |
| 2285 | |
| 2286 | // We need this to be on if we are going to draw a blended alpha rectangle; this should be on automatically, but it seems like gfx functions may turn it off if you draw an opaque shape. |
| 2287 | // See line 621 of: https://www.ferzkopp.net/Software/SDL2_gfx/Docs/html/_s_d_l2__gfx_primitives_8c_source.html |
| 2288 | globals.Renderer.SetDrawBlendMode(sdl.BLENDMODE_BLEND) |
| 2289 | |
| 2290 | if label.Editing { |
| 2291 | |
| 2292 | if label.Selection.Length() > 0 { |
| 2293 | |
| 2294 | color := getThemeColor(GUIFontColor) |
| 2295 | color[3] = 64 |
| 2296 | start, end := label.Selection.ContiguousRange() |
nothing calls this directly
no test coverage detected