Exemplo n.º 1
0
    def add_database_option(self, platform, name, description=""):
        # self.options_on_page.add(name)
        group = OptionUI.create_group(
            self, name, description=description, help_button=False
        )

        if self.hori_counter % 2 == 0:
            self.hori_layout = HorizontalLayout()
            self.layout.add(
                self.hori_layout,
                fill=True,
                margin_top=10,
                margin_bottom=10,
                margin_left=-10,
                margin_right=-10,
            )

        self.hori_layout.add(
            group,
            fill=True,
            expand=-1,
            margin=10,
            margin_top=0,
            margin_bottom=0,
        )
        self.hori_layout.add(
            PlatformSettingsButton(self, platform), margin_right=10
        )

        if self.hori_counter % 2 == 0:
            self.hori_layout.add_spacer(0)
        self.hori_counter += 1
 def __init__(self, parent, option):
     super().__init__(parent)
     self.option = option
     self.layout = HorizontalLayout()
     self.layout.add(ColorSettingIndicator(self, option))
     self.layout.add(ColorTextField(self, option), margin_left=5)
     self.layout.add(ColorSettingButton(self, option), margin_left=5)
Exemplo n.º 3
0
    def __init__(self, parent):
        Panel.__init__(self, parent, paintable=True)
        self.set_min_height(29)
        # self.set_background_color(Color(0xd8, 0xd8, 0xd8))
        self.layout = VerticalLayout()
        self.hori_layout = HorizontalLayout()
        if Skin.fws():
            self.top_border_size = 2
        else:
            self.top_border_size = 1
        self.layout.add(self.hori_layout,
                        fill=True,
                        expand=True,
                        margin_top=self.top_border_size)

        element = ProtectionElement(self)
        self.hori_layout.add(element, fill=True)

        element = WarningsElement(self)
        self.hori_layout.add(element, fill=True, expand=True)
        self.hori_layout.add_spacer(16)

        for language, icon_name in reversed([
            ("en", "flag-gb"),
            ("de", "flag-de"),
            ("fr", "flag-fr"),
            ("es", "flag-es"),
            ("it", "flag-it"),
            ("ja", "flag-jp"),
                # ("", "flag-unknown"),
        ]):
            icon = Image("workspace:res/16/" + icon_name + ".png")
            element = LanguageElement(self, language, icon)
            self.hori_layout.add(element, fill=True)
        self.hori_layout.add_spacer(16)

        element = PlayersElement(self)
        self.hori_layout.add(element, fill=True)

        # for config_key, icon_name in [
        #     ("database_url", "database_url_16"),
        #     ("hol_url", "hol_url_16"),
        #     ("lemonamiga_url", "lemon_url_16"),
        #     ("mobygames_url", "mobygames_url_16"),
        #     ("wikipedia_url", "wikipedia_url_16"),
        # ]:
        #     icon = Image("launcher:res/" + icon_name + ".png")
        #     element = LinkButtonElement(self, config_key, icon)
        #     self.hori_layout.add(element)

        element = WebLinkElement(self)
        self.hori_layout.add(element, fill=True)

        # this listener is added after all status bar children have
        # added their listeners, this is important for re-layout...
        LauncherConfig.add_listener(self)
Exemplo n.º 4
0
    def __init__(self, parent, spacing=10):
        unused(spacing)
        Panel.__init__(self, parent, paintable=True)
        Skin.set_background_color(self)
        self.layout = HorizontalLayout()
        self.layout.add_spacer(20)
        # self.layout.add_spacer(spacing)
        # self.layout.padding_left = 10
        # self.layout.padding_right = 10

        # self.set_background_color(Color(0xAEAEAE))
        # self.set_min_height(Constants.TAB_HEIGHT)

        self.bgcolor = get_theme(self).window_bgcolor()
        self.set_background_color(self.bgcolor)
    def __init__(self, parent, *, path, placeholder=""):
        super().__init__(parent)
        self.layout = HorizontalLayout()

        self.text_field = TextField(self,
                                    text=path,
                                    placeholder=placeholder,
                                    clearbutton=True)
        self.text_field.changed.connect(self.__on_text_field_changed)
        self.layout.add(self.text_field, expand=True)

        self.browse_button = IconButton(self, "browse_folder_16.png")
        self.browse_button.set_tooltip(gettext("Browse for File"))
        self.browse_button.activated.connect(self.__on_browse_button)
        # FIXME: Scale 5 here
        self.layout.add(self.browse_button, fill=True, margin_left=5)
class FilePickerField(Group):
    changed = Signal()

    def __init__(self, parent, *, path, placeholder=""):
        super().__init__(parent)
        self.layout = HorizontalLayout()

        self.text_field = TextField(self,
                                    text=path,
                                    placeholder=placeholder,
                                    clearbutton=True)
        self.text_field.changed.connect(self.__on_text_field_changed)
        self.layout.add(self.text_field, expand=True)

        self.browse_button = IconButton(self, "browse_folder_16.png")
        self.browse_button.set_tooltip(gettext("Browse for File"))
        self.browse_button.activated.connect(self.__on_browse_button)
        # FIXME: Scale 5 here
        self.layout.add(self.browse_button, fill=True, margin_left=5)

    def path(self):
        return self.text_field.text()

    def __on_text_field_changed(self):
        self.changed.emit()

    def __on_browse_button(self):
        # FIXME: Show file picker dialog
        # dialog = FileDialog()
        # dialog.show()

        # FIXME: Choose initial directory based on directory of existing path,
        # if any

        dialog = LauncherFilePicker(
            get_window(self),
            # FIXME
            gettext("Select file"),
            # FIXME
            "floppy",
        )
        if not dialog.show_modal():
            print("dialog.show returned false")
            return
        print("dialog.show returned true")
        path = dialog.get_path()
        self.text_field.set_text(path)
Exemplo n.º 7
0
    def __init__(self, parent):
        Panel.__init__(self, parent, paintable=True)
        self.set_min_height(29)
        # self.set_background_color(Color(0xd8, 0xd8, 0xd8))
        self.layout = VerticalLayout()
        self.hori_layout = HorizontalLayout()
        if Skin.fws():
            self.top_border_size = 2
        else:
            self.top_border_size = 1
        self.layout.add(self.hori_layout, fill=True, expand=True,
                        margin_top=self.top_border_size)

        element = ProtectionElement(self)
        self.hori_layout.add(element, fill=True)

        element = WarningsElement(self)
        self.hori_layout.add(element, fill=True, expand=True)
        self.hori_layout.add_spacer(16)

        for language, icon_name in reversed([
            ("en", "flag-gb"),
            ("de", "flag-de"),
            ("fr", "flag-fr"),
            ("es", "flag-es"),
            ("it", "flag-it"),
            ("ja", "flag-jp"),
            # ("", "flag-unknown"),
        ]):
            icon = Image("workspace:res/16/" + icon_name + ".png")
            element = LanguageElement(self, language, icon)
            self.hori_layout.add(element, fill=True)
        self.hori_layout.add_spacer(16)

        element = PlayersElement(self)
        self.hori_layout.add(element, fill=True)

        # for config_key, icon_name in [
        #     ("database_url", "database_url_16"),
        #     ("hol_url", "hol_url_16"),
        #     ("lemonamiga_url", "lemon_url_16"),
        #     ("mobygames_url", "mobygames_url_16"),
        #     ("wikipedia_url", "wikipedia_url_16"),
        # ]:
        #     icon = Image("launcher:res/" + icon_name + ".png")
        #     element = LinkButtonElement(self, config_key, icon)
        #     self.hori_layout.add(element)

        element = WebLinkElement(self)
        self.hori_layout.add(element, fill=True)

        # this listener is added after all status bar children have
        # added their listeners, this is important for re-layout...
        LauncherConfig.add_listener(self)
    def __init__(self, parent):
        super().__init__(parent)
        horilayout = HorizontalLayout()
        self.layout.add(
            horilayout,
            fill=True,
            expand=True,
            margin_top=10,
            margin_right=20,
            margin_bottom=10,
            margin_left=10,
        )
        # self.set_background_color(Color(0xC0C0C0))

        horilayout.add(VariantChoice(self),
                       fill=True,
                       expand=True,
                       margin_left=10)
        horilayout.add(RatingChoice(self), fill=True, margin_left=10)
        horilayout.add(OpenRetroEditButton(self), fill=True, margin_left=10)
        horilayout.add(CustomConfigButton(self), fill=True, margin_left=10)
Exemplo n.º 9
0
    def __init__(self, parent):
        super().__init__(parent)
        # self.set_background_color(Color(0xFF0000))
        image_loader = get_window(self).image_loader
        self.front_panel = FrontCoverPanel(self, image_loader)
        self.layout.add(
            self.front_panel,
            margin_top=20,
            margin_right=20,
            margin_bottom=20,
            margin_left=20,
        )

        hori_layout = HorizontalLayout()
        self.layout.add(hori_layout, fill=True)

        self.year_label = Label(self)
        font = self.year_label.font()
        font.set_bold()
        self.year_label.set_font(font)
        self.year_label.set_min_width(40)
        hori_layout.add(self.year_label, margin_left=20)

        self.publisher_label = Label(self)
        hori_layout.add(self.publisher_label, expand=True, margin_left=10)

        self._publisher = ""
        self._year = ""
        ConfigDispatch(
            self,
            {
                "publisher": self.__on_publisher_config,
                "year": self.__on_year_config,
            },
        )
Exemplo n.º 10
0
    def __init__(self, parent):
        super().__init__(parent)
        # self.set_background_color(fsui.Color(0x999900))
        # This min width is not important
        # self.set_min_width(400)

        horilayout = HorizontalLayout()
        self.layout.add(horilayout, fill=True, expand=True)

        vertlayout = VerticalLayout()
        horilayout.add(vertlayout, fill=True, expand=True)

        self.top_panel = Launcher2TopPanel(self)
        vertlayout.add(self.top_panel, fill=True)

        # self.running_panel = Launcher2RunningPanel(self)
        # vertlayout.add(self.running_panel, fill=True)
        # self.running_panel.set_visible(False)

        self.configpanel = ConfigPanel(self)
        # FIXME: Refer to theme? dialog_bg_color?
        self.configpanel.set_background_color(
            Color(Launcher2Colors.CONFIG_PANEL_COLOR)
        )
        # self.configpanel.set_background_color(Color(0xBBBBBB))
        vertlayout.add(self.configpanel, fill=True, expand=True)

        self.bottom_panel = Launcher2BottomPanel(self)
        self.layout.add(self.bottom_panel, fill=True)

        design_test = True
        if design_test:
            self.side = Launcher2SidePanel(self)
            horilayout.add(self.side, fill=True)

            # The Launcher should fit into a 1280x720 display, with
            # common/reasonable GUI elements such as a task bar.
            # Or maybe use 1366x768
            # Or maybe 1280x768 to support 1280x1024 and 1366x768.
            # Windows 10 taskbar width/side: 62 pixels
            # Windows 10 taskbar height/bottom: 40 pixels
            # screen_size = (1280, 720)
            screen_size = (1366, 768)

            min_width = screen_size[0] - 62
            # Subtracting an additional 40 For Launcher title bar
            min_height = screen_size[1] - 40 - 40

            self.parent().set_min_size((min_width, min_height))
            self.parent().left.set_min_width(380)

            self.parent().set_min_size((1280, 720 - 40))

            # For now, make the minimum _client size_ 1280x720 which will cause
            # the window with decorations to be 1280x740. This should not be
            # the min. required size going forward though. Too big for
            # 768-height screens with bottom Windows 10 taskbar...
            # self.parent().set_min_size((1280, 720))

        ConfigDispatch(self, {"__running": self.__on_running_config})
Exemplo n.º 11
0
    def __init__(self, parent):
        super().__init__(parent, paintable=True)
        self.set_min_height(40)
        self.set_background_color(Color(0xFF, 0xFF, 0xFF))

        self.menu_button = Button(self, "=")
        self.minimize_button = Button(self, "_")
        self.minimize_button.activated.connect(self.on_minimize_button)
        self.maximize_button = Button(self, "^")
        self.maximize_button.activated.connect(self.on_maximize_button)
        self.close_button = Button(self, "X")
        self.close_button.activated.connect(self.on_close_button)

        self.layout = HorizontalLayout()
        self.layout.add(self.menu_button, fill=True)
        self.layout.add_spacer(0, expand=True)
        self.layout.add(self.minimize_button, fill=True)
        self.layout.add(self.maximize_button, fill=True)
        self.layout.add(self.close_button, fill=True)

        self.window_pos = (-1, -1)
        self.mouse_pos = (-1, -1)
Exemplo n.º 12
0
 def __init__(self, parent):
     super().__init__(parent)
     horilayout = HorizontalLayout()
     self.layout.add(horilayout, fill=True, expand=True, margin=10)
     # self.set_background_color(Color(0xAEAEAE))
     self.set_background_color(Color(0xB8B8B8))
     horilayout.add(NewConfigButton(self), fill=True, margin_right=10)
     horilayout.add(SearchField(self), fill=True, expand=True)
Exemplo n.º 13
0
    def __init__(self, parent):
        StatusElement.__init__(self, parent)
        # self.set_min_width(140)
        self.layout = HorizontalLayout()
        self.icon = Image("launcher:res/16x16/world_link.png")
        self.right_icon = Image("launcher:res/16x16/drop_down_arrow.png")
        self.right_icon_disabled = Image(
            "launcher:res/16x16/drop_down_arrow_disabled.png")
        # self.inactive_icon = self.active_icon.grey_scale()

        self.text = gettext("Web Links")

        LauncherConfig.add_listener(self)
        self.on_config("protection", LauncherConfig.get("protection"))

        self.have = set()
        for key in url_keys:
            self.on_config(key, LauncherConfig.get(key))
    def __init__(self, parent):
        super().__init__(parent)
        horilayout = HorizontalLayout()
        self.layout.add(horilayout, fill=True, expand=True)

        self.left = Launcher2LeftPanel(self)

        self.left.set_min_width(420)
        # - 40 for titlebar, - 40 for windows taskbar
        self.set_min_size((1100, 768 - 40 - 40))

        horilayout.add(self.left, fill=True)
        self.right = Launcher2RightPanel(self)
        horilayout.add(self.right, fill=True, expand=True)
Exemplo n.º 15
0
class TabPanel(Panel):
    def __init__(self, parent, spacing=10):
        unused(spacing)
        Panel.__init__(self, parent, paintable=True)
        Skin.set_background_color(self)
        self.layout = HorizontalLayout()
        self.layout.add_spacer(20)
        # self.layout.add_spacer(spacing)
        # self.layout.padding_left = 10
        # self.layout.padding_right = 10

        # self.set_background_color(Color(0xAEAEAE))
        # self.set_min_height(Constants.TAB_HEIGHT)

        self.bgcolor = get_theme(self).window_bgcolor()
        self.set_background_color(self.bgcolor)

    def select_tab(self, index):
        counter = 0
        for child in self.layout.children:
            child = child.element
            if hasattr(child, "type"):
                if child.type == child.TYPE_TAB:
                    if counter == index:
                        child.select()
                    counter += 1

    def set_selected_tab(self, tab):
        for child in self.layout.children:
            child = child.element
            if hasattr(child, "type"):
                if child.type == child.TYPE_TAB:
                    if child == tab:
                        child.state = child.STATE_SELECTED
                        child.refresh()
                    elif child.state == child.STATE_SELECTED:
                        if child.group_id == tab.group_id:
                            child.state = child.STATE_NORMAL
                            child.refresh()

    def add(self, button, expand=False):
        self.layout.add(button, expand=expand)

    def add_spacer(self, spacer=0, expand=False):
        self.layout.add_spacer(spacer, 0, expand=expand)
Exemplo n.º 16
0
    def __init__(self, parent):
        super().__init__(parent)
        self.set_background_color(Color(Launcher2Colors.SIDE_PANEL_COLOR))
        # self.set_min_width(300)
        self.set_min_width(252 + 20 * 2)

        hori_layout = HorizontalLayout()
        self.layout.add(
            hori_layout,
            fill=True,
            margin_top=10,
            margin_right=20,
            margin_left=20,
            margin_bottom=0,
        )

        self.choice = Choice(
            self,
            [
                "Game front cover",
            ],
        )
        hori_layout.add(self.choice, expand=True)
        self.choice.disable()  # Currently not implemented

        # FIXME: Only enable button if screen is big enough for expanded
        # window?
        self.add_button = IconButton(self, "add_button.png")
        hori_layout.add(self.add_button, margin_left=10)
        self.add_button.disable()  # Currently not implemented

        self.book = Book(self)
        self.layout.add(self.book, expand=True, fill=True)
        self.pages = []
        self.pages.append(GameFrontCoverPanel(self.book))
        for page in self.pages:
            self.book.add_page(page)
        self.book.set_page(self.pages[0])
Exemplo n.º 17
0
    def __init__(self, parent, *, close=False, quit=False):
        super().__init__(parent)

        panel = Panel(self)
        panel.set_min_height(1)
        panel.set_background_color(Color(0x888888))
        self.layout.add(panel, fill=True)

        horilayout = HorizontalLayout()
        self.layout.add(
            horilayout,
            fill=True,
            expand=True,
            margin_top=10,
            margin_right=10,
            margin_bottom=10,
        )

        if close:
            button = Button(self, label="Close")
            button.activated.connect(self.__on_close)
            horilayout.add(button, margin_left=10)
        if quit:
            button = Button(self, label="Quit")
            button.activated.connect(self.__on_quit)
            horilayout.add(button, margin_left=10)

        button = Button(self, label="Settings")
        button.activated.connect(self.__on_settings)
        horilayout.add(button, margin_left=10)

        button = Button(self, label="Launcher")
        button.activated.connect(self.__on_launcher)
        horilayout.add(button, margin_left=10)

        button = Button(self, label="Prefs")
        button.activated.connect(self.__on_prefs)
        horilayout.add(button, margin_left=10)

        button = Button(self, label="Advanced")
        button.activated.connect(self.__on_advanced_prefs)
        horilayout.add(button, margin_left=10)

        button = Button(self, label="Appearance")
        button.activated.connect(self.__on_appearance_prefs)
        horilayout.add(button, margin_left=10)

        button = Button(self, label="WHDLoad")
        button.activated.connect(self.__on_whdload_prefs)
        horilayout.add(button, margin_left=10)

        button = Button(self, label="LoadWB")
        button.activated.connect(self.__on_loadwb)
        horilayout.add(button, margin_left=10)

        button = Button(self, label="UH")
        button.activated.connect(self.__on_unhandled_exception)
        horilayout.add(button, margin_left=10)

        button = Button(self, label="UH2")
        button.activated.connect(self.__on_unhandled_exception_2)
        horilayout.add(button, margin_left=10)

        button = Button(self, label="UH3")
        button.activated.connect(self.__on_unhandled_exception_3)
        horilayout.add(button, margin_left=10)

        button = Button(self, label="GC")
        button.activated.connect(self.__on_garbage_collector)
        horilayout.add(button, margin_left=10)
Exemplo n.º 18
0
class StatusBar(Panel):

    def __init__(self, parent):
        Panel.__init__(self, parent, paintable=True)
        self.set_min_height(29)
        # self.set_background_color(Color(0xd8, 0xd8, 0xd8))
        self.layout = VerticalLayout()
        self.hori_layout = HorizontalLayout()
        if Skin.fws():
            self.top_border_size = 2
        else:
            self.top_border_size = 1
        self.layout.add(self.hori_layout, fill=True, expand=True,
                        margin_top=self.top_border_size)

        element = ProtectionElement(self)
        self.hori_layout.add(element, fill=True)

        element = WarningsElement(self)
        self.hori_layout.add(element, fill=True, expand=True)
        self.hori_layout.add_spacer(16)

        for language, icon_name in reversed([
            ("en", "flag-gb"),
            ("de", "flag-de"),
            ("fr", "flag-fr"),
            ("es", "flag-es"),
            ("it", "flag-it"),
            ("ja", "flag-jp"),
            # ("", "flag-unknown"),
        ]):
            icon = Image("workspace:res/16/" + icon_name + ".png")
            element = LanguageElement(self, language, icon)
            self.hori_layout.add(element, fill=True)
        self.hori_layout.add_spacer(16)

        element = PlayersElement(self)
        self.hori_layout.add(element, fill=True)

        # for config_key, icon_name in [
        #     ("database_url", "database_url_16"),
        #     ("hol_url", "hol_url_16"),
        #     ("lemonamiga_url", "lemon_url_16"),
        #     ("mobygames_url", "mobygames_url_16"),
        #     ("wikipedia_url", "wikipedia_url_16"),
        # ]:
        #     icon = Image("launcher:res/" + icon_name + ".png")
        #     element = LinkButtonElement(self, config_key, icon)
        #     self.hori_layout.add(element)

        element = WebLinkElement(self)
        self.hori_layout.add(element, fill=True)

        # this listener is added after all status bar children have
        # added their listeners, this is important for re-layout...
        LauncherConfig.add_listener(self)

    def on_destroy(self):
        LauncherConfig.remove_listener(self)

    def on_config(self, key, value):
        unused(value)
        layout = False
        if key in ["languages", "protection"]:
            layout = True
        if layout:
            self.layout.update()

    def on_paint(self):
        dc = self.create_dc()
        size = self.size()
        if Skin.fws():
            dc.draw_rectangle(
                0, 0, size[0], 2, Color(0xe5, 0xe5, 0xe5, 0xff))
            return
        color_1 = Skin.get_background_color()
        if color_1 is not None:
            color_1 = color_1.copy().darken(0.12)
        else:
            color_1 = Color(0x00, 0x00, 0x00, 0x30)
        dc.draw_line(0, 0, size[0], 0, color_1)
        self.draw_background(self, dc, offset=1, height=size[1] - 1)

    @classmethod
    def draw_element_background(cls, widget, dc):
        cls.draw_background(widget, dc)

    @classmethod
    def draw_background(cls, widget, dc, offset=None, height=None):
        size = widget.size()
        if Skin.fws():
            return
        x = 0
        y = 0
        w = size[0]
        h = size[1]
        if offset is not None:
            y += offset
        if height is not None:
            h = height

        color_1 = Skin.get_background_color()
        color_2 = color_1
        # if fsui.System.macosx:
        #     color_1 = Color(0xa7, 0xa7, 0xa7)
        #     color_2 = Color(0xc0, 0xc0, 0xc0)
        if color_1 is not None:
            color_1 = color_1.copy().darken(0.08)
        else:
            color_1 = Color(0x00, 0x00, 0x00, 0x20)
            color_2 = Color(0x00, 0x00, 0x00, 0x00)
        dc.draw_vertical_gradient(x, y, w, h, color_1, color_2)
Exemplo n.º 19
0
class StatusBar(Panel):
    def __init__(self, parent):
        Panel.__init__(self, parent, paintable=True)
        self.set_min_height(29)
        # self.set_background_color(Color(0xd8, 0xd8, 0xd8))
        self.layout = VerticalLayout()
        self.hori_layout = HorizontalLayout()
        if Skin.fws():
            self.top_border_size = 2
        else:
            self.top_border_size = 1
        self.layout.add(self.hori_layout,
                        fill=True,
                        expand=True,
                        margin_top=self.top_border_size)

        element = ProtectionElement(self)
        self.hori_layout.add(element, fill=True)

        element = WarningsElement(self)
        self.hori_layout.add(element, fill=True, expand=True)
        self.hori_layout.add_spacer(16)

        for language, icon_name in reversed([
            ("en", "flag-gb"),
            ("de", "flag-de"),
            ("fr", "flag-fr"),
            ("es", "flag-es"),
            ("it", "flag-it"),
            ("ja", "flag-jp"),
                # ("", "flag-unknown"),
        ]):
            icon = Image("workspace:res/16/" + icon_name + ".png")
            element = LanguageElement(self, language, icon)
            self.hori_layout.add(element, fill=True)
        self.hori_layout.add_spacer(16)

        element = PlayersElement(self)
        self.hori_layout.add(element, fill=True)

        # for config_key, icon_name in [
        #     ("database_url", "database_url_16"),
        #     ("hol_url", "hol_url_16"),
        #     ("lemonamiga_url", "lemon_url_16"),
        #     ("mobygames_url", "mobygames_url_16"),
        #     ("wikipedia_url", "wikipedia_url_16"),
        # ]:
        #     icon = Image("launcher:res/" + icon_name + ".png")
        #     element = LinkButtonElement(self, config_key, icon)
        #     self.hori_layout.add(element)

        element = WebLinkElement(self)
        self.hori_layout.add(element, fill=True)

        # this listener is added after all status bar children have
        # added their listeners, this is important for re-layout...
        LauncherConfig.add_listener(self)

    def on_destroy(self):
        LauncherConfig.remove_listener(self)

    def on_config(self, key, value):
        unused(value)
        layout = False
        if key in ["languages", "protection"]:
            layout = True
        if layout:
            self.layout.update()

    def on_paint(self):
        dc = self.create_dc()
        size = self.size()
        if Skin.fws():
            dc.draw_rectangle(0, 0, size[0], 2, Color(0xe5, 0xe5, 0xe5, 0xff))
            return
        color_1 = Skin.get_background_color()
        if color_1 is not None:
            color_1 = color_1.copy().darken(0.12)
        else:
            color_1 = Color(0x00, 0x00, 0x00, 0x30)
        dc.draw_line(0, 0, size[0], 0, color_1)
        self.draw_background(self, dc, offset=1, height=size[1] - 1)

    @classmethod
    def draw_element_background(cls, widget, dc):
        cls.draw_background(widget, dc)

    @classmethod
    def draw_background(cls, widget, dc, offset=None, height=None):
        size = widget.size()
        if Skin.fws():
            return
        x = 0
        y = 0
        w = size[0]
        h = size[1]
        if offset is not None:
            y += offset
        if height is not None:
            h = height

        color_1 = Skin.get_background_color()
        color_2 = color_1
        # if fsui.System.macosx:
        #     color_1 = Color(0xa7, 0xa7, 0xa7)
        #     color_2 = Color(0xc0, 0xc0, 0xc0)
        if color_1 is not None:
            color_1 = color_1.copy().darken(0.08)
        else:
            color_1 = Color(0x00, 0x00, 0x00, 0x20)
            color_2 = Color(0x00, 0x00, 0x00, 0x00)
        dc.draw_vertical_gradient(x, y, w, h, color_1, color_2)
class WorkspaceTitleBar(Panel):
    def __init__(self, parent):
        super().__init__(parent)
        self.layout = HorizontalLayout()

        self.title = get_workspace_window_title()
        self.dragging = False
        self.dragging_mouse_origin = (0, 0)
        self.dragging_window_origin = (0, 0)
        self.buttons = []

        theme = get_theme(self)
        self.height = theme.titlebar_height()
        self.set_min_height(self.height)

        button_size = (self.height, self.height)
        # fgcolor = theme.titlebar_fgcolor()
        # fgcolor_inactive = theme.titlebar_fgcolor_inactive()
        fgcolor = Color(0x000000)
        fgcolor_inactive = Color(0x000000)

        self.set_background_color(Color(0xFFFFFF))

        menu = True
        if menu:
            self.menubutton = TitleBarButton(
                self,
                icon_name="TitleBarMenu",
                size=button_size,
                fgcolor=fgcolor,
                fgcolor_inactive=fgcolor_inactive,
            )
            self.menubutton.activated.connect(self.__on_menu_activated)
            self.layout.add(self.menubutton)
            self.buttons.append(self.menubutton)
        else:
            self.menubutton = None

        self.layout.add_spacer(0, expand=True)

        self.volumebutton = VolumeButton(self)
        self.layout.add(self.volumebutton)
        self.monitorbutton = MonitorButton(self)
        self.layout.add(self.monitorbutton)
        self.fullscreenbutton = FullscreenToggleButton(self)
        self.layout.add(self.fullscreenbutton)

        self._window_active = True

        # parent.activated.connect(self.__on_window_activated)
        # parent.deactivated.connect(self.__on_window_deactivated)

        # FIXME: Would be better to do this via theme instead and get a theme
        # updated notification. Works well enough for now.

        for option in [
            "launcher_titlebar_font",
            "launcher_titlebar_height",
            "launcher_titlebar_uppercase",
        ]:
            self.on_setting(
                option,
                get_settings(self).get(option),
            )
        get_settings(self).add_listener(self)

    def on_destroy(self):
        get_settings(self).remove_listener(self)
        super().on_destroy()

    @exceptionhandler
    def on_setting(self, option, _):
        if option == "launcher_titlebar_font":
            self.refresh()
        elif option == "launcher_titlebar_uppercase":
            self.refresh()
        elif option == "launcher_titlebar_height":
            new_height = get_theme(self).titlebar_height()
            self.update_height(new_height)

    def update_height(self, new_height):
        if self.height == new_height:
            return
        self.height = new_height
        self.set_min_height(new_height)
        for button in self.buttons:
            button.set_size((new_height, new_height))
        get_window(self).layout.update()

    @exceptionhandler
    def on_paint(self):
        theme = get_theme(self)
        text = self.title
        if theme.titlebar_uppercase():
            text = text.upper()
        _, wh = self.size()
        dc = self.create_dc()
        dc.set_font(theme.titlebar_font())
        color = Color(0, 0, 0)
        dc.set_text_color(color)
        _, th = dc.measure_text(text)
        if self.menubutton:
            # Adding width of button (same as height). Also, adding 6 gives
            # 20 pixels between edge of burger icon and start of text.
            x = self.height + 6
        else:
            x = 20
        y = (wh - th) // 2 + 1
        dc.draw_text(text, x, y)

    @exceptionhandler
    def __on_menu_activated(self):
        try:
            on_menu = self.window.on_menu
        except AttributeError:
            print(
                f"WARNING: Window {self.window} has menu enabled, but missing "
                "on_menu method"
            )
            return
        menu = on_menu()
        if menu is None:
            return
        print("FIXME: Open menu")
        # menu.open()
        self.popup_menu(menu, (0, self.height))
    def __init__(self, parent):
        super().__init__(parent)
        self.layout = HorizontalLayout()

        self.title = get_workspace_window_title()
        self.dragging = False
        self.dragging_mouse_origin = (0, 0)
        self.dragging_window_origin = (0, 0)
        self.buttons = []

        theme = get_theme(self)
        self.height = theme.titlebar_height()
        self.set_min_height(self.height)

        button_size = (self.height, self.height)
        # fgcolor = theme.titlebar_fgcolor()
        # fgcolor_inactive = theme.titlebar_fgcolor_inactive()
        fgcolor = Color(0x000000)
        fgcolor_inactive = Color(0x000000)

        self.set_background_color(Color(0xFFFFFF))

        menu = True
        if menu:
            self.menubutton = TitleBarButton(
                self,
                icon_name="TitleBarMenu",
                size=button_size,
                fgcolor=fgcolor,
                fgcolor_inactive=fgcolor_inactive,
            )
            self.menubutton.activated.connect(self.__on_menu_activated)
            self.layout.add(self.menubutton)
            self.buttons.append(self.menubutton)
        else:
            self.menubutton = None

        self.layout.add_spacer(0, expand=True)

        self.volumebutton = VolumeButton(self)
        self.layout.add(self.volumebutton)
        self.monitorbutton = MonitorButton(self)
        self.layout.add(self.monitorbutton)
        self.fullscreenbutton = FullscreenToggleButton(self)
        self.layout.add(self.fullscreenbutton)

        self._window_active = True

        # parent.activated.connect(self.__on_window_activated)
        # parent.deactivated.connect(self.__on_window_deactivated)

        # FIXME: Would be better to do this via theme instead and get a theme
        # updated notification. Works well enough for now.

        for option in [
            "launcher_titlebar_font",
            "launcher_titlebar_height",
            "launcher_titlebar_uppercase",
        ]:
            self.on_setting(
                option,
                get_settings(self).get(option),
            )
        get_settings(self).add_listener(self)
Exemplo n.º 22
0
class TitleBar(Panel):
    def __init__(self, parent):
        super().__init__(parent, paintable=True)
        self.set_min_height(40)
        self.set_background_color(Color(0xFF, 0xFF, 0xFF))

        self.menu_button = Button(self, "=")
        self.minimize_button = Button(self, "_")
        self.minimize_button.activated.connect(self.on_minimize_button)
        self.maximize_button = Button(self, "^")
        self.maximize_button.activated.connect(self.on_maximize_button)
        self.close_button = Button(self, "X")
        self.close_button.activated.connect(self.on_close_button)

        self.layout = HorizontalLayout()
        self.layout.add(self.menu_button, fill=True)
        self.layout.add_spacer(0, expand=True)
        self.layout.add(self.minimize_button, fill=True)
        self.layout.add(self.maximize_button, fill=True)
        self.layout.add(self.close_button, fill=True)

        self.window_pos = (-1, -1)
        self.mouse_pos = (-1, -1)

    def on_menu_button(self):
        pass

    def on_minimize_button(self):
        self.parent().minimize()

    def on_maximize_button(self):
        self.parent().maximize(not self.parent().is_maximized())

    def on_close_button(self):
        self.parent().close()

    def on_left_dclick(self):
        self.on_maximize_button()

    def on_left_down(self):
        self.window_pos = self.parent().get_position()
        self.mouse_pos = get_mouse_position()

    def on_mouse_motion(self):
        mouse_pos = get_mouse_position()
        window_pos = (
            self.window_pos[0] + mouse_pos[0] - self.mouse_pos[0],
            self.window_pos[1] + mouse_pos[1] - self.mouse_pos[1],
        )
        self.parent().set_position(window_pos)

    # def on_left_up(self):
    #     pass

    def on_paint(self):
        dc = self.create_dc()
        if self.close_button is not None:
            x_offset = self.close_button.width() + 20
        else:
            x_offset = 20
        # print(self.parent())
        # text = self.parent().title()
        text = "FIXME"
        _, th = dc.measure_text(text)
        dc.draw_text(text, x_offset, (self.height() - th) // 2)
Exemplo n.º 23
0
class OpenRetroPrefsPanel(BasePrefsPanel):
    def __init__(self, parent):
        super().__init__(parent)
        # FIXME
        self.set_min_size((540, 100))
        self.layout.set_padding(20, 20, 20, 20)
        # self.layout.set_padding(10, 10, 10, 10)
        import fsui

        # self.layout.add(fsui.Button(self, "hei"))

        with AsParent(self):
            LoginPanel()

        self.add_section("Platforms")

        self.add_option(Option.PLATFORMS_FEATURE)

        self.hori_layout = None
        self.hori_counter = 0

        # if openretro or settings.get(Option.PLATFORMS_FEATURE) == "1":
        #     # self.add_section(gettext("Game Databases"))

        label = MultiLineLabel(
            self,
            gettext(
                "Note: This is an experimental feature. "
                "Additional plugins are needed."
            ),
            640,
        )
        self.layout.add(label, margin_top=20, margin_bottom=20)

        self.add_database_option(
            Platform.CPC, Option.CPC_DATABASE, "Amstrad CPC"
        )
        self.add_database_option(
            Platform.ARCADE, Option.ARCADE_DATABASE, "Arcade"
        )
        self.add_database_option(
            Platform.A7800, Option.A7800_DATABASE, "Atari 7800"
        )
        self.add_database_option(
            Platform.C64, Option.C64_DATABASE, "Commodore 64"
        )
        self.add_database_option(Platform.DOS, Option.DOS_DATABASE, "DOS")
        self.add_database_option(Platform.GB, Option.GB_DATABASE, "Game Boy")
        self.add_database_option(
            Platform.GBA, Option.GBA_DATABASE, "Game Boy Advance"
        )
        self.add_database_option(
            Platform.GBC, Option.GBC_DATABASE, "Game Boy Color"
        )
        self.add_database_option(
            Platform.SMS, Option.SMS_DATABASE, "Master System"
        )
        self.add_database_option(
            Platform.SMD, Option.SMD_DATABASE, "Mega Drive"
        )
        self.add_database_option(
            Platform.NEOGEO, Option.NEOGEO_DATABASE, "Neo-Geo"
        )
        self.add_database_option(Platform.NES, Option.NES_DATABASE, "Nintendo")
        self.add_database_option(
            Platform.PSX, Option.PSX_DATABASE, "PlayStation"
        )
        self.add_database_option(
            Platform.SNES, Option.SNES_DATABASE, "Super Nintendo"
        )
        self.add_database_option(Platform.ST, Option.ST_DATABASE, "Atari ST")
        self.add_database_option(
            Platform.TG16, Option.TG16_DATABASE, "TurboGrafx-16"
        )
        self.add_database_option(
            Platform.TGCD, Option.TGCD_DATABASE, "TurboGrafx-CD"
        )
        self.add_database_option(
            Platform.ZXS, Option.ZXS_DATABASE, "ZX Spectrum"
        )

        # label = fsui.MultiLineLabel(
        #     self, gettext(
        #         "Note: Support for additional game databases is an "
        #         "experimental feature and does not provide the "
        #         "same level of maturity as Amiga/CDTV/CD32. "
        #         "Also, additional plugins are needed to play the "
        #         "games."), 640)
        # self.layout.add(label, margin_top=20)

    def add_database_option(self, platform, name, description=""):
        # self.options_on_page.add(name)
        group = OptionUI.create_group(
            self, name, description=description, help_button=False
        )

        if self.hori_counter % 2 == 0:
            self.hori_layout = HorizontalLayout()
            self.layout.add(
                self.hori_layout,
                fill=True,
                margin_top=10,
                margin_bottom=10,
                margin_left=-10,
                margin_right=-10,
            )

        self.hori_layout.add(
            group,
            fill=True,
            expand=-1,
            margin=10,
            margin_top=0,
            margin_bottom=0,
        )
        self.hori_layout.add(
            PlatformSettingsButton(self, platform), margin_right=10
        )

        if self.hori_counter % 2 == 0:
            self.hori_layout.add_spacer(0)
        self.hori_counter += 1
Exemplo n.º 24
0
    def __init__(self, parent):
        super().__init__(parent, title="Calculator", maximizable=False)

        self.text_field = CalculatorTextField(self)
        self.layout.add(self.text_field, fill=True, margin=20)

        hori_layout = HorizontalLayout()
        self.layout.add(
            hori_layout,
            fill=True,
            margin_top=0,
            margin_right=20,
            margin_left=10,
            margin_bottom=10,
        )
        button = CalculatorButton(self, "7")
        hori_layout.add(button, margin_left=10)
        button = CalculatorButton(self, "8")
        hori_layout.add(button, margin_left=10)
        button = CalculatorButton(self, "7")
        hori_layout.add(button, margin_left=10)
        # CA and CE buttons use a smaller font on purpose, to make them look
        # more like symbols.
        button = CalculatorButton(self, "CA", letters=True)
        hori_layout.add(button, margin_left=10)
        button = CalculatorButton(self, "CE", letters=True)
        hori_layout.add(button, margin_left=10)

        hori_layout = HorizontalLayout()
        self.layout.add(
            hori_layout,
            fill=True,
            margin_top=0,
            margin_right=20,
            margin_left=10,
            margin_bottom=10,
        )
        button = CalculatorButton(self, "4")
        hori_layout.add(button, margin_left=10)
        button = CalculatorButton(self, "5")
        hori_layout.add(button, margin_left=10)
        button = CalculatorButton(self, "6")
        hori_layout.add(button, margin_left=10)
        button = CalculatorButton(self, "×", symbol=True)
        hori_layout.add(button, margin_left=10)
        button = CalculatorButton(self, "÷", symbol=True)
        hori_layout.add(button, margin_left=10)

        hori_layout = HorizontalLayout()
        self.layout.add(
            hori_layout,
            fill=True,
            margin_top=0,
            margin_right=20,
            margin_left=10,
            margin_bottom=10,
        )
        button = CalculatorButton(self, "1")
        hori_layout.add(button, margin_left=10)
        button = CalculatorButton(self, "2")
        hori_layout.add(button, margin_left=10)
        button = CalculatorButton(self, "3")
        hori_layout.add(button, margin_left=10)
        button = CalculatorButton(self, "+", symbol=True)
        hori_layout.add(button, margin_left=10)
        button = CalculatorButton(self, "\u2212", symbol=True)  # Minus sign
        hori_layout.add(button, margin_left=10)

        hori_layout = HorizontalLayout()
        self.layout.add(
            hori_layout,
            fill=True,
            margin_top=0,
            margin_right=20,
            margin_left=10,
            margin_bottom=10,
        )
        button = CalculatorButton(self, "0")
        hori_layout.add(button, margin_left=10)
        button = CalculatorButton(self, ".")
        hori_layout.add(button, margin_left=10)
        button = CalculatorButton(self, "«", symbol=True)
        hori_layout.add(button, margin_left=10)
        button = CalculatorButton(self, "±", symbol=True)
        hori_layout.add(button, margin_left=10)
        button = CalculatorButton(self, "=", symbol=True)
        hori_layout.add(button, margin_left=10)

        self.layout.add_spacer(10)
Exemplo n.º 25
0
    def __init__(self, parent):
        super().__init__(
            parent,
            title=gettext("Execute a file"),
            maximizable=False,
            minimizable=False,
            escape=True,
        )
        vertlayout = VerticalLayout(20)
        self.layout.add(vertlayout, fill=True, expand=True)
        vertlayout.add(Label(self,
                             gettext("Enter command and its arguments:")))

        horilayout = HorizontalLayout()
        vertlayout.add(horilayout, fill=True, margin_top=10)
        horilayout.add(Label(self, gettext("Command:")), fill=True)
        self.textfield = TextField(self)
        self.textfield.set_min_width(300)
        self.textfield.activated.connect(self.__on_execute)
        horilayout.add(self.textfield, expand=True, fill=True, margin_left=10)

        # Creating execute button first, so it will become default for when
        # the user presses return in the text field. This only applies when
        # this dialog is implemented as an actual Dialog though.
        self.executebutton = Button(self, gettext("Execute"))
        self.executebutton.activated.connect(self.__on_execute)
        self.cancelbutton = Button(self, gettext("Cancel"))
        self.cancelbutton.activated.connect(self.__on_cancel)

        horilayout = HorizontalLayout()
        vertlayout.add(horilayout, fill=True, margin_top=20)
        horilayout.add_spacer(0, expand=True)
        horilayout.add(self.cancelbutton, margin_left=10)
        horilayout.add(self.executebutton, margin_left=10)
        self._command = ""