Files
autoPlanner/main.py
T

70 lines
1.8 KiB
Python
Raw Normal View History

2024-03-12 15:36:46 -06:00
import math
import pygame as pg
from pygame.locals import *
from sys import exit
import numpy as np
2024-03-13 13:10:09 -07:00
import src.pathRenderer as pathRenderer
import src.pathEditor as pathEditor
2024-03-12 15:36:46 -06:00
2024-03-13 13:10:09 -07:00
doubleClickDuration = 200
2024-03-12 15:36:46 -06:00
pg.init()
2024-03-13 13:10:09 -07:00
topBarHeight = 40
bottomBarHeight = 40
2024-03-12 15:36:46 -06:00
2024-03-13 13:10:09 -07:00
screen_width = 1200
screen_height = (screen_width * (643/1286)) + topBarHeight + bottomBarHeight
2024-03-12 15:36:46 -06:00
screen = pg.display.set_mode((screen_width, screen_height))
pg.display.set_caption("Auto Planner")
2024-03-13 13:10:09 -07:00
pathR = pathRenderer.pathRenderer(pg, screen, topBarHeight)
2024-03-12 15:36:46 -06:00
2024-03-13 13:10:09 -07:00
tabIndex = 0
2024-03-12 15:36:46 -06:00
2024-03-13 13:10:09 -07:00
tabs = [
pathEditor.pathEditor(pg, pathR)
]
2024-03-12 15:36:46 -06:00
def refresh():
2024-03-13 13:10:09 -07:00
pass
2024-03-12 15:36:46 -06:00
running = True
last_click = -1
2024-03-13 13:10:09 -07:00
# clickType = -1
# clickIndex = -1
def offsetPos(pos):
return (pos[0],pos[1])
2024-03-12 15:36:46 -06:00
while running:
for event in pg.event.get():
if event.type == pg.MOUSEBUTTONDOWN:
2024-03-13 13:10:09 -07:00
pos = pg.mouse.get_pos()
if pos[1] > topBarHeight and pos[1] < (screen.get_width()-bottomBarHeight):
now = pg.time.get_ticks()
if now - last_click <= doubleClickDuration:
tabs[tabIndex].doubleClick(offsetPos(pos))
else:
tabs[tabIndex].mouseDown(offsetPos(pos))
last_click = pg.time.get_ticks()
2024-03-12 15:36:46 -06:00
2024-03-13 13:10:09 -07:00
if event.type == pg.MOUSEMOTION:
pos = pg.mouse.get_pos()
if pos[1] > topBarHeight and pos[1] < (screen.get_width()-bottomBarHeight):
tabs[tabIndex].mouseMove(offsetPos(pos))
2024-03-12 15:36:46 -06:00
if event.type == pg.MOUSEBUTTONUP:
2024-03-13 13:10:09 -07:00
pos = pg.mouse.get_pos()
if pos[1] > topBarHeight and pos[1] < (screen.get_width()-bottomBarHeight):
tabs[tabIndex].mouseUp(offsetPos(pos))
2024-03-12 15:36:46 -06:00
if event.type == pg.QUIT:
running = False
2024-03-13 13:10:09 -07:00
2024-03-12 15:36:46 -06:00
pg.quit()