コード例 #1
0
ファイル: ac_widget.py プロジェクト: styinx/ACLIB
    def _on_id(self):
        self.size = self.size
        self.position = self.position
        self.visible = self.visible
        self.background = self.background
        self.border = self.border
        self.background_texture = self.background_texture
        self.background_color = self.background_color
        self.border_color = self.border_color
        self.parent = self._parent

        if self.has_id:
            if ac.addOnClickedListener(
                    self.id,
                    ACWidget._event_function(ACWidget.EVENT.ON_MOUSE_DOWN,
                                             self)) == -1:
                console(
                    'Failed to register onClick listener for {}.'.format(self))

        try:
            app_name = None if self.app not in ACWidget.IDS else ACWidget.IDS[
                self.app].title
            WidgetStyle.load_style_from_config(self, self.__class__.__name__,
                                               app_name)
        except Exception as e:
            console('Problems while loading style for class "{}"'.format(
                self.__class__.__name__))
            tb(e)
コード例 #2
0
ファイル: ac_widget.py プロジェクト: styinx/ACLIB
    def id(self, _id: int):
        self._id = _id

        if _id != -1:
            ACWidget.IDS[self.id] = self

            self._on_id()
        else:
            console('{}: Id could not be set.'.format(self))
コード例 #3
0
ファイル: ac_widget.py プロジェクト: styinx/ACLIB
    def background_texture(self, background_texture: str):
        self._background_texture = background_texture

        self.background = True if self.background_texture else False

        if self.background_texture:
            if self.has_id:
                self.background = True
                if ac.setBackgroundTexture(self.id, background_texture) == -1:
                    console('{}: Texture "{}" could not be set.'.format(
                        self, background_texture))
コード例 #4
0
ファイル: ac_widget.py プロジェクト: styinx/ACLIB
    def background_color(self, background_color: Color):
        self._background_color = background_color

        if not self.background:
            self.background = background_color.a > 0 or self.background_texture

        if self.has_id:
            c = background_color
            success = ac.setBackgroundColor(
                self.id, c.r, c.g, c.b) == 1 and ac.setBackgroundOpacity(
                    self.id, c.a) == 1
            if not success:
                console('{}: Background color could not be set.'.format(self))
コード例 #5
0
ファイル: ac_widget.py プロジェクト: styinx/ACLIB
    def _on_id(self):
        super()._on_id()

        if self.has_id:
            if ac.addOnAppActivatedListener(
                    self.id,
                    ACWidget._event_function(ACWidget.EVENT.ACTIVATED,
                                             self)) == -1:
                console('Failed to add activation listener for {}.'.format(
                    self.title))
            if ac.addOnAppDismissedListener(
                    self.id,
                    ACWidget._event_function(ACWidget.EVENT.DISMISSED,
                                             self)) == -1:
                console('Failed to add dismissed listener for {}.'.format(
                    self.title))
コード例 #6
0
    def __init__(self, data: ACData = None, meta: ACMeta = None):
        super().__init__('ACLIB_Camera', 200, 200, 150, 250)

        self.hide_decoration()
        self.background_color = TRANSPARENT

        self._data = data

        self._grid = ACGrid(2, 11, self)
        self._prev = ACLabel(self._grid, '<-', 'center')
        self._next = ACLabel(self._grid, '->', 'center')

        self._prev.background_color = DARKGRAY
        self._next.background_color = DARKGRAY

        self._grid.add(self._prev, 0, 0)
        self._grid.add(self._next, 1, 0)

        self._prev.on(ACWidget.EVENT.ON_MOUSE_DOWN, self.prev)
        self._next.on(ACWidget.EVENT.ON_MOUSE_DOWN, self.next)

        self._cameras = ['Cockpit', 'Car', 'Drivable', 'Track', 'Helicopter', 'OnBoardFree', 'Free', 'Random', 'ImageGeneratorCamera', 'Start']

        self._labels = []
        self._cam_id = 0

        self._active_font = Font('Roboto Mono')
        self._active_font.size = 12
        self._active_font.color = WHITE

        self._inactive_font = Font('Roboto Mono')
        self._inactive_font.size = 12
        self._inactive_font.color = WHITE

        i = 0
        for cam_id, name in enumerate(self._cameras):
            label = ACLabel(self._grid, name, 'center', self._inactive_font)
            label.background_color = BLACK
            label.on(ACWidget.EVENT.ON_MOUSE_DOWN, self.select)
            setattr(label, 'cam', cam_id)
            self._labels.append(label)

            self._grid.add(label, 0, i + 1, 2, 1)
            i += 1
            console(label.size)

        self._data.on(ACData.EVENT.READY, self.init)