def show(self, screen): pygame.draw.rect( screen, Color.from_name("BLACK").get_rgba(), pygame.Rect(-1, self.naos.height - 33, self.naos.width + 2, 34)) pygame.draw.rect( screen, Color.from_name("GRAY").get_rgba(), pygame.Rect(0, self.naos.height - 32, self.naos.width, 32)) screen.blit(self.logo, (6, self.naos.height - 28)) pygame.draw.line(screen, Color.from_name("BLACK").get_rgba(), (38, self.naos.height - 33), (38, self.naos.height), 3) for i, window in enumerate(self.naos.windows): pygame.draw.rect( screen, Color.from_name("GRAY").darker(3).get_rgba(), pygame.Rect(50 + 27 * i, self.naos.height - 27, 22, 22)) screen.blit( self.font.render(window.title[0]), (50 + 27 * i + (11 - self.font.rendered_size(window.title[0])[0] / 2), self.naos.height - 27 + (11 - self.font.rendered_size(window.title[0])[1] / 2))) pygame.draw.line(screen, Color.from_name("BLACK").get_rgba(), (self.naos.width - self.hour.get_rect().width - 10, self.naos.height - 33), (self.naos.width - self.hour.get_rect().width - 10, self.naos.height), 3) screen.blit(self.hour, (self.naos.width - self.hour.get_rect().width - 5, self.naos.height - 16 - self.hour.get_rect().height / 2))
def show(self, screen): if self.is_showed: pygame.draw.rect( screen, Color.from_name("GRAY").darker(2).get_rgba(), pygame.Rect(self.x, self.y, self.width, self.height)) pygame.draw.rect( screen, Color.from_name("GRAY").darker(4).get_rgba(), pygame.Rect(self.x + self.width - 20, self.y, 20, self.height)) pygame.draw.rect( screen, Color.from_name("GRAY").darker(6).get_rgba(), pygame.Rect(self.x + self.width - 20, self.y, 20, 20)) screen.blit(self.font.render("^"), (self.x + self.width - 14, self.y + 5)) pygame.draw.rect( screen, Color.from_name("GRAY").darker(6).get_rgba(), pygame.Rect(self.x + self.width - 20, self.y + self.height - 20, 20, 20)) screen.blit(self.font.render("v"), (self.x + self.width - 14, self.y + self.height - 20)) x = clamp(self.x, 0, self.width) y = clamp(self.y, 0, self.height) width = clamp(self.width, 0, self.width - x) height = clamp(self.height, 0, self.height - y) intra_canvas = screen.subsurface(pygame.Rect(x, y, width, height)) for i in self.widgets: i.show(intra_canvas)
def __init__(self): self.logo = pygame.image.load( os.path.join(os.path.dirname(__file__), "..", "..", "files", "images", "logo.png")).convert() self.logo = pygame.transform.scale(self.logo, (26, 26)) self.naos = None self.font = Font(size=17, bold=True, color=Color.from_name("BLACK")) self.hour = self.font.render(datetime.now().strftime("%H:%M:%S"))
def __init__(self, x, y, xlength=0, ylength=0, width=2, color=Color.from_name("BLACK")): super().__init__(x, y) self.endx = x + xlength self.endy = y + ylength self.width = width self.color = color
def __init__(self, x, y, text, command=None, font=Font(), size=(100, 40), background=Color.from_name("GRAY").darker(5)): super().__init__(x, y) self.text = text self.command = command self.font = font self.background = background self.size = size self.is_hover = False self.update_render()
def __init__(self, x, y, width=100, font=Font(color=Color.from_name("BLACK")), accepted="èàçù€ " + string.digits + string.ascii_letters + string.punctuation, image=None): super(Entry, self).__init__(x, y) self.width = width self.image = image self.label = Label(0, 0, "", font) self.text = "" self.focus = False self.accepted = accepted self.render = None self.update_render()
def __init__(self, debug=False): self.paths = { "files": os.path.join(os.getenv('APPDATA'), "NaOS"), "system": os.path.join(os.getenv('APPDATA'), "NaOS", "system"), "user": os.path.join(os.getenv('APPDATA'), "NaOS", "user"), "programs": os.path.join(os.getenv('APPDATA'), "NaOS", "programs"), } self.fs = FileSystem(self) for v in self.paths.values(): if not os.path.exists(v): os.makedirs(v) self.db = Database(os.path.join(self.paths["system"], "data.db")) self.db.createdb() self.width = 1920 self.height = 1080 pygame.display.set_caption("NaOS") self.screen = pygame.display.set_mode((self.width, self.height), pygame.FULLSCREEN | pygame.SCALED) self.clock = pygame.time.Clock() self.is_running = False self.bg_color = Color.from_name("BLACK") self.debug = debug if self.debug: self.debug_font = Font() background = self.db.executewithreturn("""SELECT background FROM parameters""")[0][0] self.bg = None self.set_background(background) self.naosbar = NaOSBar() self.startmenu = StartMenu(self) self.windows = [] self.focused_window = None self.startmenu.naos = self self.naosbar.naos = self self.program_manager = ProgramManager()
def show(self, screen): if self.open: pygame.draw.rect( screen, Color.from_name("BLACK").get_rgba(), pygame.Rect(self.x - 1, self.y - 21, self.width + 2, self.height + 22)) pygame.draw.rect(screen, Color.from_name("GRAY").darker(2).get_rgba(), pygame.Rect(self.x, self.y - 20, self.width, 20)) pygame.draw.rect( screen, Color.from_name("GRAY").get_rgba(), pygame.Rect(self.x, self.y, self.width, self.height)) temp = self.title while temp != "..." and self.font.rendered_size( temp)[0] > self.width - 44: temp = temp[:-1] if temp == self.title else temp[:-4] + "..." screen.blit(self.font.render(temp), (self.x + 4, self.y - 18)) pygame.draw.rect( screen, Color.from_name("GRAY").darker(5).get_rgba(), pygame.Rect(self.x + self.width - 36, self.y - 18, 16, 16)) pygame.draw.line(screen, Color.from_name("BLACK").get_rgba(), (self.x + self.width - 32, self.y - 11), (self.x + self.width - 24, self.y - 11), 2) pygame.draw.rect( screen, Color.from_name("RED").get_rgba(), pygame.Rect(self.x + self.width - 18, self.y - 18, 16, 16)) x = clamp(self.x, 0, self.naos.width) y = clamp(self.y, 0, self.naos.height) width = clamp(self.width, 0, self.naos.width - x) height = clamp(self.height, 0, self.naos.height - y) intra_canvas = screen.subsurface(pygame.Rect(x, y, width, height)) for i in self.widgets: i.show(intra_canvas)
def __init__(self, x, y, width, height, color=Color.from_name("BLACK")): super().__init__(x, y) self.width = width self.height = height self.color = color