IQ.Pilot Prebuilt Release @ 27f668a
This commit is contained in:
3
iqpilot/system/ui/iqwidgets/lib/__init__.py
Normal file
3
iqpilot/system/ui/iqwidgets/lib/__init__.py
Normal file
@@ -0,0 +1,3 @@
|
||||
"""
|
||||
Copyright © IQ.Lvbs, apart of Project Teal Lvbs, All Rights Reserved, licensed under https://konn3kt.com/tos
|
||||
"""
|
||||
36
iqpilot/system/ui/iqwidgets/lib/application.py
Normal file
36
iqpilot/system/ui/iqwidgets/lib/application.py
Normal file
@@ -0,0 +1,36 @@
|
||||
"""
|
||||
Copyright © IQ.Lvbs, apart of Project Teal Lvbs, All Rights Reserved, licensed under https://konn3kt.com/tos
|
||||
"""
|
||||
import os
|
||||
|
||||
import pyray as rl
|
||||
|
||||
_UI_MODE_IQ = os.getenv("IQPILOT_UI", "1") == "1"
|
||||
|
||||
_PROBE_FS = 20
|
||||
_PROBE_MARGIN = 10
|
||||
_PROBE_COLOR = rl.Color(0x12, 0x97, 0x91, 0xFF)
|
||||
|
||||
|
||||
class IQAppHooks:
|
||||
"""IQ hooks mixed into GuiApplication: UI-mode flag + pointer debug readout."""
|
||||
|
||||
def __init__(self):
|
||||
self._pointer_probe = os.getenv("SHOW_MOUSE_COORDS") == "1"
|
||||
|
||||
@staticmethod
|
||||
def iqpilot_ui() -> bool:
|
||||
return _UI_MODE_IQ
|
||||
|
||||
def set_show_mouse_coords(self, show: bool):
|
||||
self._pointer_probe = show
|
||||
|
||||
@property
|
||||
def pointer_probe_enabled(self) -> bool:
|
||||
return self._pointer_probe
|
||||
|
||||
def draw_pointer_probe(self, font):
|
||||
readout = f"X:{rl.get_mouse_x()}, Y:{rl.get_mouse_y()}"
|
||||
width = rl.measure_text_ex(font, readout, _PROBE_FS, 0).x
|
||||
canvas_w = self._scaled_width if self._scale != 1.0 else self._width
|
||||
rl.draw_text_ex(font, readout, rl.Vector2(canvas_w - width - _PROBE_MARGIN, 6), _PROBE_FS, 0, _PROBE_COLOR)
|
||||
108
iqpilot/system/ui/iqwidgets/lib/canvas.py
Normal file
108
iqpilot/system/ui/iqwidgets/lib/canvas.py
Normal file
@@ -0,0 +1,108 @@
|
||||
"""
|
||||
Copyright © IQ.Lvbs, apart of Project Teal Lvbs, All Rights Reserved, licensed under https://konn3kt.com/tos
|
||||
|
||||
IQ.Pilot drawing surface. Onroad renderers and settings widgets paint through
|
||||
this facade instead of touching pyray directly, so the HUD has one vocabulary
|
||||
for shapes/text/textures. Each call forwards verbatim to the backing library —
|
||||
output is identical to a raw pyray call, only the call site reads in IQ terms.
|
||||
"""
|
||||
import pyray as _p
|
||||
from iqpilot.system.ui.lib.text_measure import measure_text_cached as _measure
|
||||
|
||||
Rgba = _p.Color
|
||||
Box = _p.Rectangle
|
||||
Pt = _p.Vector2
|
||||
|
||||
WHITE = _p.Color(255, 255, 255, 255)
|
||||
BLACK = _p.Color(0, 0, 0, 255)
|
||||
RED = _p.Color(230, 41, 55, 255)
|
||||
CLEAR = _p.Color(0, 0, 0, 0)
|
||||
|
||||
|
||||
def shade(r: int, g: int, b: int, a: int = 255) -> Rgba:
|
||||
return _p.Color(r, g, b, a)
|
||||
|
||||
|
||||
def with_opacity(color: Rgba, alpha: float) -> Rgba:
|
||||
r, g, b = (color.r, color.g, color.b) if hasattr(color, "r") else color[:3]
|
||||
return _p.Color(r, g, b, int(alpha))
|
||||
|
||||
|
||||
# --- filled / stroked shapes -------------------------------------------------
|
||||
|
||||
def panel(box: Box, roundness: float, segments: int, color: Rgba) -> None:
|
||||
_p.draw_rectangle_rounded(box, roundness, segments, color)
|
||||
|
||||
|
||||
def panel_outline(box: Box, roundness: float, segments: int, thickness: float, color: Rgba) -> None:
|
||||
_p.draw_rectangle_rounded_lines_ex(box, roundness, segments, thickness, color)
|
||||
|
||||
|
||||
def slab(x: float, y: float, w: float, h: float, color: Rgba) -> None:
|
||||
_p.draw_rectangle(int(x), int(y), int(w), int(h), color)
|
||||
|
||||
|
||||
def h_sweep(x: float, y: float, w: float, h: float, left: Rgba, right: Rgba) -> None:
|
||||
_p.draw_rectangle_gradient_h(int(x), int(y), int(w), int(h), left, right)
|
||||
|
||||
|
||||
def v_sweep(x: float, y: float, w: float, h: float, top: Rgba, bottom: Rgba) -> None:
|
||||
_p.draw_rectangle_gradient_v(int(x), int(y), int(w), int(h), top, bottom)
|
||||
|
||||
|
||||
def disc(cx: float, cy: float, radius: float, color: Rgba) -> None:
|
||||
_p.draw_circle(int(cx), int(cy), radius, color)
|
||||
|
||||
|
||||
def disc_at(center: Pt, radius: float, color: Rgba) -> None:
|
||||
_p.draw_circle_v(center, radius, color)
|
||||
|
||||
|
||||
def hoop(cx: float, cy: float, radius: float, color: Rgba) -> None:
|
||||
_p.draw_circle_lines(int(cx), int(cy), radius, color)
|
||||
|
||||
|
||||
def annulus(center: Pt, inner: float, outer: float, start: float, end: float, segments: int, color: Rgba) -> None:
|
||||
_p.draw_ring(center, inner, outer, start, end, segments, color)
|
||||
|
||||
|
||||
def oval(cx: float, cy: float, rx: float, ry: float, color: Rgba) -> None:
|
||||
_p.draw_ellipse(int(cx), int(cy), rx, ry, color)
|
||||
|
||||
|
||||
def hair(a: Pt, b: Pt, thickness: float, color: Rgba) -> None:
|
||||
_p.draw_line_ex(a, b, thickness, color)
|
||||
|
||||
|
||||
def hair_xy(x0: float, y0: float, x1: float, y1: float, color: Rgba) -> None:
|
||||
_p.draw_line(int(x0), int(y0), int(x1), int(y1), color)
|
||||
|
||||
|
||||
def wedge(a: Pt, b: Pt, c: Pt, color: Rgba) -> None:
|
||||
_p.draw_triangle(a, b, c, color)
|
||||
|
||||
|
||||
# --- text --------------------------------------------------------------------
|
||||
|
||||
def span(box_w, text: str, size: int, spacing: float = 0):
|
||||
"""Measured extent of a text run (Vector2)."""
|
||||
return _measure(box_w, text, size, spacing)
|
||||
|
||||
|
||||
def glyphs(font, text: str, at: Pt, size: int, color: Rgba, spacing: float = 0) -> None:
|
||||
_p.draw_text_ex(font, text, at, size, spacing, color)
|
||||
|
||||
|
||||
def glyphs_centered(font, text: str, size: int, center: Pt, color: Rgba, spacing: float = 0) -> None:
|
||||
extent = _measure(font, text, size, spacing)
|
||||
_p.draw_text_ex(font, text, _p.Vector2(center.x - extent.x / 2, center.y - extent.y / 2), size, spacing, color)
|
||||
|
||||
|
||||
# --- textures ----------------------------------------------------------------
|
||||
|
||||
def stamp(tex, x: float, y: float, tint: Rgba) -> None:
|
||||
_p.draw_texture(tex, int(x), int(y), tint)
|
||||
|
||||
|
||||
def stamp_scaled(tex, src: Box, dst: Box, origin: Pt, rotation: float, tint: Rgba) -> None:
|
||||
_p.draw_texture_pro(tex, src, dst, origin, rotation, tint)
|
||||
142
iqpilot/system/ui/iqwidgets/lib/styles.py
Normal file
142
iqpilot/system/ui/iqwidgets/lib/styles.py
Normal file
@@ -0,0 +1,142 @@
|
||||
"""
|
||||
Copyright © IQ.Lvbs, apart of Project Teal Lvbs, All Rights Reserved, licensed under https://konn3kt.com/tos
|
||||
"""
|
||||
import pyray as rl
|
||||
|
||||
|
||||
def _hex(rgb: int, alpha: int = 0xFF) -> rl.Color:
|
||||
return rl.Color((rgb >> 16) & 0xFF, (rgb >> 8) & 0xFF, rgb & 0xFF, alpha)
|
||||
|
||||
|
||||
class ink:
|
||||
"""IQ settings palette, grouped by role."""
|
||||
|
||||
# surfaces
|
||||
PANEL = _hex(0x393939)
|
||||
PANEL_MUTED = _hex(0x272727)
|
||||
PANEL_PRESSED = _hex(0x151515)
|
||||
|
||||
# accent (selection / "on")
|
||||
ACCENT = _hex(0x1C65BA)
|
||||
ACCENT_PRESSED = _hex(0x114E96)
|
||||
ACCENT_FADED = _hex(0x25466B)
|
||||
|
||||
# text
|
||||
TITLE = rl.WHITE
|
||||
READOUT = _hex(0xAAAAAA)
|
||||
CAPTION = _hex(0x808080)
|
||||
DISABLED = _hex(0x585858)
|
||||
|
||||
# toggle knob
|
||||
KNOB = rl.WHITE
|
||||
KNOB_DISABLED = _hex(0x585858)
|
||||
|
||||
# chips / segmented controls
|
||||
CHIP_PRESSED = _hex(0x696868)
|
||||
FAINT = rl.Color(255, 255, 255, 0x33)
|
||||
CLEAR = rl.Color(255, 255, 255, 0)
|
||||
VOID = rl.Color(0, 0, 0, 0)
|
||||
|
||||
# dialog key buttons
|
||||
KEY_ACTION = _hex(0x465BEA)
|
||||
KEY_NEUTRAL = _hex(0x333333)
|
||||
KEY_SUNKEN = _hex(0x1E1E1E)
|
||||
OUTLINE = _hex(0x969696, 200)
|
||||
|
||||
# status colours (vehicle fingerprint legend etc.)
|
||||
STATUS_GOOD = _hex(0x129791)
|
||||
STATUS_INFO = _hex(0x0086E9)
|
||||
STATUS_WARN = _hex(0xFFD500)
|
||||
|
||||
# push buttons
|
||||
PUSH = _hex(0x34373E)
|
||||
PUSH_PRESSED = _hex(0x464A52)
|
||||
PUSH_DISABLED = _hex(0x121212)
|
||||
PUSH_TEXT_DISABLED = _hex(0x5C5C5C)
|
||||
|
||||
|
||||
class metrics:
|
||||
"""Row and control geometry for the IQ settings surfaces."""
|
||||
|
||||
ROW = 170
|
||||
GUTTER = 20
|
||||
TITLE_FS = 50
|
||||
CAPTION_FS = 40
|
||||
CAPTION_DY = 150
|
||||
TEXT_PAD = 20
|
||||
CLOSE_BTN = 160
|
||||
|
||||
TOGGLE_H = 120
|
||||
TOGGLE_W = int(TOGGLE_H * 2.2)
|
||||
TOGGLE_TRACK_H = TOGGLE_H - 20
|
||||
|
||||
ACTION_W = 300
|
||||
ROW_BTN_H = 120
|
||||
WIDE_BTN_W = 800
|
||||
WIDE_BTN_H = 150
|
||||
|
||||
|
||||
class style:
|
||||
"""Transitional facade for panels not yet ported to ink/metrics; shrink as ports land."""
|
||||
|
||||
ITEM_BASE_HEIGHT = metrics.ROW
|
||||
ITEM_PADDING = metrics.GUTTER
|
||||
ITEM_TEXT_FONT_SIZE = metrics.TITLE_FS
|
||||
ITEM_DESC_FONT_SIZE = metrics.CAPTION_FS
|
||||
ITEM_DESC_V_OFFSET = metrics.CAPTION_DY
|
||||
ITEM_TEXT_VALUE_COLOR = ink.READOUT
|
||||
CLOSE_BTN_SIZE = metrics.CLOSE_BTN
|
||||
TEXT_PADDING = metrics.TEXT_PAD
|
||||
TOGGLE_HEIGHT = metrics.TOGGLE_H
|
||||
TOGGLE_WIDTH = metrics.TOGGLE_W
|
||||
TOGGLE_BG_HEIGHT = metrics.TOGGLE_TRACK_H
|
||||
BUTTON_ACTION_WIDTH = metrics.ACTION_W
|
||||
BUTTON_HEIGHT = metrics.ROW_BTN_H
|
||||
SIMPLE_BUTTON_WIDTH = metrics.WIDE_BTN_W
|
||||
SIMPLE_BUTTON_HEIGHT = metrics.WIDE_BTN_H
|
||||
|
||||
BASE_BG_COLOR = ink.PANEL
|
||||
ON_BG_COLOR = ink.ACCENT
|
||||
OFF_BG_COLOR = ink.PANEL
|
||||
ON_HOVER_BG_COLOR = ink.ACCENT_PRESSED
|
||||
OFF_HOVER_BG_COLOR = ink.PANEL_PRESSED
|
||||
DISABLED_ON_BG_COLOR = ink.ACCENT_FADED
|
||||
DISABLED_OFF_BG_COLOR = ink.PANEL_MUTED
|
||||
ITEM_TEXT_COLOR = ink.TITLE
|
||||
ITEM_DISABLED_TEXT_COLOR = ink.DISABLED
|
||||
ITEM_DESC_TEXT_COLOR = ink.CAPTION
|
||||
|
||||
TOGGLE_ON_COLOR = ink.ACCENT
|
||||
TOGGLE_OFF_COLOR = ink.PANEL
|
||||
TOGGLE_KNOB_COLOR = ink.KNOB
|
||||
TOGGLE_DISABLED_ON_COLOR = ink.ACCENT_FADED
|
||||
TOGGLE_DISABLED_OFF_COLOR = ink.PANEL_MUTED
|
||||
TOGGLE_DISABLED_KNOB_COLOR = ink.KNOB_DISABLED
|
||||
|
||||
MBC_TRANSPARENT = ink.CLEAR
|
||||
MBC_BG_CHECKED_ENABLED = ink.CHIP_PRESSED
|
||||
MBC_DISABLED = ink.FAINT
|
||||
|
||||
OPTION_CONTROL_CONTAINER_BG = ink.PANEL
|
||||
OPTION_CONTROL_BTN_ENABLED = ink.KNOB_DISABLED
|
||||
OPTION_CONTROL_BTN_PRESSED = ink.CHIP_PRESSED
|
||||
OPTION_CONTROL_BTN_DISABLED = ink.PANEL_MUTED
|
||||
OPTION_CONTROL_TEXT_ENABLED = ink.TITLE
|
||||
OPTION_CONTROL_TEXT_PRESSED = ink.TITLE
|
||||
OPTION_CONTROL_TEXT_DISABLED = ink.DISABLED
|
||||
|
||||
BUTTON_PRIMARY_COLOR = ink.KEY_ACTION
|
||||
BUTTON_NEUTRAL_GRAY = ink.KEY_NEUTRAL
|
||||
BUTTON_DISABLED_BG_COLOR = ink.KEY_SUNKEN
|
||||
TREE_DIALOG_TRANSPARENT = ink.VOID
|
||||
TREE_DIALOG_SEARCH_BUTTON_PRESSED = ink.CHIP_PRESSED
|
||||
TREE_DIALOG_SEARCH_BUTTON_BORDER = ink.OUTLINE
|
||||
|
||||
GREEN = ink.STATUS_GOOD
|
||||
BLUE = ink.STATUS_INFO
|
||||
YELLOW = ink.STATUS_WARN
|
||||
|
||||
BUTTON_ENABLED_OFF = ink.PUSH
|
||||
BUTTON_OFF_PRESSED = ink.PUSH_PRESSED
|
||||
BUTTON_DISABLED = ink.PUSH_DISABLED
|
||||
BUTTON_TEXT_DISABLED = ink.PUSH_TEXT_DISABLED
|
||||
9
iqpilot/system/ui/iqwidgets/lib/utils.py
Normal file
9
iqpilot/system/ui/iqwidgets/lib/utils.py
Normal file
@@ -0,0 +1,9 @@
|
||||
"""
|
||||
Copyright © IQ.Lvbs, apart of Project Teal Lvbs, All Rights Reserved, licensed under https://konn3kt.com/tos
|
||||
"""
|
||||
from iqpilot.system.ui.iqwidgets.widgets.list_view import IQButtonAction
|
||||
|
||||
|
||||
class WideButtonAction(IQButtonAction):
|
||||
def get_width_hint(self):
|
||||
return super().get_width_hint() + 1
|
||||
Reference in New Issue
Block a user