// SPDX-License-Identifier: MIT // Copyright (c) 2021 KikooDX // This file is part of [KBLE](https://sr.ht/~kikoodx/kble), which is // MIT licensed. The MIT license requires this copyright notice to be // included in all copies and substantial portions of the software. const ray = @import("raylib.zig"); const conf = @import("conf.zig"); const Vec2 = @import("vec2.zig"); const Rect = @import("rect.zig"); const scaling = @import("scaling.zig"); const Mode = @import("modes.zig").Mode; /// Draw cursor. pub fn cursor(scale: scaling.scale_type, offset: Vec2, pos: Vec2, mode: Mode) void { const x = (pos.x - offset.y) * scale; const y = (pos.y - offset.y) * scale; const color: ray.Color = switch (mode) { .normal => conf.theme.mode.normal, .select => conf.theme.mode.select, .rectangle => conf.theme.mode.select_rect, .unselect => conf.theme.mode.unselect, .unrectangle => conf.theme.mode.unrectangle, .camera => conf.theme.mode.camera, }; ray.DrawRectangleLines(x, y, scale, scale, color); } /// Draw rectangle selection preview. pub fn rectangle_selection(scale: scaling.scale_type, offset: Vec2, rect: Rect, sel: bool) void { const x = (rect.left_x - offset.x) * scale; const w = (rect.right_x - rect.left_x + 1) * scale; const y = (rect.top_y - offset.y) * scale; const h = (rect.bottom_y - rect.top_y + 1) * scale; ray.DrawRectangleLines(x, y, w, h, if (sel) conf.theme.mode.select_rect else conf.theme.mode.unrectangle); }