Пример #1
0
    def process_mid_row_code(self, mid_row_code: SccMidRowCode,
                             time_code: SmpteTimeCode):
        """Processes SCC Mid-Row Code to map it to the model"""

        # If the Paint-On or Roll-Up style is activated, write directly on active caption
        processed_caption = self.buffered_caption
        if self.current_style in (SccCaptionStyle.PaintOn,
                                  SccCaptionStyle.RollUp):
            processed_caption = self.active_caption

        if processed_caption is None:
            raise ValueError("No current SCC caption initialized")

        if processed_caption.get_current_text() is not None \
            and processed_caption.get_current_text().get_text() \
            and not processed_caption.get_current_text().get_text().isspace():
            processed_caption.new_caption_text()

        processed_caption.get_current_text().add_style_property(
            StyleProperties.Color, mid_row_code.get_color())
        processed_caption.get_current_text().add_style_property(
            StyleProperties.FontStyle, mid_row_code.get_font_style())
        processed_caption.get_current_text().add_style_property(
            StyleProperties.TextDecoration, mid_row_code.get_text_decoration())

        # The cursor moves one column to the right after each Mid-Row Code
        processed_caption.append_text(" ")

        if processed_caption.get_caption_style() is SccCaptionStyle.PaintOn:
            processed_caption.get_current_text().set_begin(time_code)
Пример #2
0
    def process_mid_row_code(self, mid_row_code: SccMidRowCode,
                             time_code: SmpteTimeCode):
        """Processes SCC Mid-Row Code to map it to the model"""

        # If the Paint-On or Roll-Up style is activated, write directly on active caption
        processed_caption = self.buffered_caption
        if self.current_style in (SccCaptionStyle.PaintOn,
                                  SccCaptionStyle.RollUp):
            processed_caption = self.active_caption

        if processed_caption is None:
            raise ValueError("No current SCC caption initialized")

        color = mid_row_code.get_color()
        font_style = mid_row_code.get_font_style()
        text_decoration = mid_row_code.get_text_decoration()

        if self.previous_code_type is not SccMidRowCode:
            # In case of multiple mid-row codes, move right only after the first code

            # If there is already text on the current line
            if processed_caption.get_current_text() is not None \
                and processed_caption.get_current_text().get_text() != "":

                # In case of paint-on replacing text
                if self.current_style is SccCaptionStyle.PaintOn \
                    and processed_caption.get_current_line().get_cursor() < processed_caption.get_current_line().get_length():
                    processed_caption.append_text(" ")

                else:
                    if text_decoration is None:
                        processed_caption.new_caption_text()
                        processed_caption.append_text(" ")
                    else:
                        processed_caption.append_text(" ")
                        processed_caption.new_caption_text()

            else:
                processed_caption.append_text(" ")

            self.current_color = color
            self.current_font_style = font_style
            self.current_text_decoration = text_decoration

        else:
            if color is not None:
                self.current_color = color
            if font_style is not None:
                self.current_font_style = font_style
            if text_decoration is not None:
                self.current_text_decoration = text_decoration

            processed_caption.append_text(" ")
            processed_caption.new_caption_text()

        if processed_caption.get_caption_style() is SccCaptionStyle.PaintOn:
            processed_caption.get_current_text().set_begin(time_code)
Пример #3
0
  def process_mid_row_code(self, mid_row_code: SccMidRowCode):
    """Processes SCC Mid-Row Code to map it to the model"""
    if self.current_caption is None:
      raise ValueError("No current SCC caption initialized")

    if self.current_caption.get_current_text() is not None and self.current_caption.get_current_text().get_text():
      self.current_caption.new_caption_text()
      self.current_caption.apply_current_text_offsets()

    self.current_caption.get_current_text().add_style_property(StyleProperties.Color, mid_row_code.get_color())
    self.current_caption.get_current_text().add_style_property(StyleProperties.FontStyle, mid_row_code.get_font_style())
    self.current_caption.get_current_text().add_style_property(StyleProperties.TextDecoration, mid_row_code.get_text_decoration())