Exemple #1
0
 def add_entry(self, frame, hsizer, text, value, value_range, width):
     vsizer = Sizer("vertical")
     label = self.create_label(frame, text)
     vsizer.add(SizerWidget(label),
                borders=self.borders,
                alignments=("min", "center"))
     entry = self.create_spin_entry(frame, value, value_range, width)
     vsizer.add(SizerWidget(entry),
                alignments=("min", "expand"),
                borders=self.borders)
     hsizer.add(vsizer, alignments=("min", "center"), borders=self.borders)
     return entry
Exemple #2
0
 def create_spin_entry(self, frame, param, slider=None, component=None):
     scale3 = LVector3(self.text_scale[0], 1.0, self.text_scale[1])
     value_range = param.get_range()
     value_type = param.get_type()
     if value_range is None:
         value_range = (value_type(float("-inf")), value_type(float("inf")))
     step_size = param.get_step()
     if step_size is None:
         step_size = 1
     if component is not None:
         value = param.get_param_component(component)
     else:
         value = param.get_param()
     entry = DirectSpinBox(parent=frame,
                           value=value,
                           valueType=value_type,
                           textFormat='{}',
                           minValue=value_range[0],
                           maxValue=value_range[1],
                           stepSize=step_size,
                           suppressKeys=1,
                           command=self.do_update,
                           extraArgs=[slider, param, component],
                           valueEntry_width=10,
                           valueEntry_text_align=TextNode.A_left,
                           valueEntry_frameColor=settings.entry_background,
                           scale=scale3)
     widget = SizerWidget(entry)
     return widget
Exemple #3
0
 def create_text_entry(self, frame, param):
     entry = DirectEntry(parent=frame,
                         initialText=str(param.get_param()),
                         numLines=1,
                         width=10,
                         command=self.do_update,
                         extraArgs=[None, param],
                         text_scale=self.font_size,
                         text_align=TextNode.A_left,
                         suppressKeys=1)
     widget = SizerWidget(entry)
     return widget
Exemple #4
0
 def create_layout(self):
     frame = DirectFrame(state=DGG.NORMAL,
                         frameColor=settings.panel_background)
     self.layout = DirectWidgetContainer(frame)
     self.layout.frame.setPos(0, 0, 0)
     sizer = Sizer("vertical")
     self.add_time(frame, sizer)
     self.add_date(frame, sizer)
     self.set_current_time()
     hsizer = Sizer("horizontal")
     ok = DirectButton(parent=frame,
                       text=_("OK"),
                       text_scale=self.text_scale,
                       command=self.ok)
     hsizer.add(SizerWidget(ok),
                alignments=("min", "center"),
                borders=self.borders)
     current = DirectButton(parent=frame,
                            text=_("Set current time"),
                            text_scale=self.text_scale,
                            command=self.set_current_time)
     hsizer.add(SizerWidget(current),
                alignments=("min", "center"),
                borders=self.borders)
     cancel = DirectButton(parent=frame,
                           text=_("Cancel"),
                           text_scale=self.text_scale,
                           command=self.cancel)
     hsizer.add(SizerWidget(cancel),
                alignments=("min", "center"),
                borders=self.borders)
     sizer.add(hsizer, borders=self.borders)
     sizer.update((self.width, self.height))
     size = sizer.min_size
     frame['frameSize'] = (0, size[0], -size[1], 0)
     self.window = Window(_("Set time"),
                          parent=pixel2d,
                          scale=self.scale,
                          child=self.layout,
                          owner=self)
Exemple #5
0
 def add_parameter(self, frame, sizer, param):
     hsizer = Sizer("horizontal")
     label = DirectLabel(parent=frame,
                         text=param.name,
                         textMayChange=True,
                         text_scale=self.text_scale,
                         text_align=TextNode.A_left)
     widget = SizerWidget(label)
     hsizer.add(widget, borders=self.borders, alignments=("min", "center"))
     if param.param_type == UserParameter.TYPE_BOOL:
         widget = self.create_bool_entry(frame, param)
         hsizer.add(widget,
                    alignments=("min", "center"),
                    borders=self.borders)
     elif param.param_type == UserParameter.TYPE_STRING:
         widget = self.create_text_entry(frame, param)
         hsizer.add(widget,
                    alignments=("min", "center"),
                    borders=self.borders)
     elif param.param_type == UserParameter.TYPE_INT:
         if param.value_range is not None:
             widget = self.create_slider_entry(frame, param)
         else:
             widget = self.create_spin_entry(frame, param)
         hsizer.add(widget,
                    alignments=("min", "center"),
                    borders=self.borders)
     elif param.param_type == UserParameter.TYPE_FLOAT:
         if param.value_range is not None:
             widget = self.create_slider_entry(frame, param)
         else:
             widget = self.create_spin_entry(frame, param)
         hsizer.add(widget,
                    alignments=("min", "center"),
                    borders=self.borders)
     elif param.param_type == UserParameter.TYPE_VEC:
         vsizer = Sizer("vertical")
         for component in range(param.nb_components):
             widget = self.create_slider_entry(frame, param, component)
             vsizer.add(widget, borders=self.borders)
         hsizer.add(vsizer,
                    borders=self.borders,
                    alignments=("min", "center"))
     else:
         print("Unknown entry type", param.param_type)
     sizer.add(hsizer, alignments=("min", "expand"), borders=self.borders)
Exemple #6
0
 def add_parameters(self, frame, sizer, parameters):
     for param in parameters:
         if param is None: continue
         if param.is_group():
             if param.is_empty(): continue
             borders = (self.font_size / 2, 0, self.font_size / 4.0,
                        self.font_size / 4.0)
             if param.name is not None:
                 label = DirectLabel(parent=frame,
                                     text=param.name,
                                     textMayChange=True,
                                     text_scale=self.text_scale,
                                     text_align=TextNode.A_left)
                 widget = SizerWidget(label)
                 sizer.add(widget, borders=borders)
             self.add_parameters(frame, sizer, param.parameters)
         else:
             self.add_parameter(frame, sizer, param)
Exemple #7
0
 def create_slider_entry(self, frame, param, component=None):
     if component is not None:
         scaled_value = param.get_param_component(component, scale=True)
     else:
         scaled_value = param.get_param(scale=True)
     hsizer = Sizer("horizontal")
     slider = DirectSlider(parent=frame,
                           scale=(self.font_size * 16, 1,
                                  self.font_size * 6),
                           value=scaled_value,
                           range=param.get_range(scale=True),
                           suppressKeys=1,
                           command=self.do_update_slider)
     widget = SizerWidget(slider)
     hsizer.add(widget,
                alignments=("expand", "center"),
                borders=self.borders)
     widget = self.create_spin_entry(frame, param, slider, component)
     hsizer.add(widget, alignments=("min", "center"), borders=self.borders)
     slider['extraArgs'] = [slider, widget.dgui_obj, param, component]
     return hsizer
Exemple #8
0
 def create_bool_entry(self, frame, param):
     btn = DirectCheckButton(
         parent=frame,
         text="",
         text_scale=self.text_scale,
         text_align=TextNode.A_left,
         boxPlacement="left",
         #borderWidth=(2, 2),
         indicator_text_scale=self.text_scale,
         indicator_text='A',
         indicator_text_pos=(0, 4),
         indicator_borderWidth=(2, 2),
         #boxBorder=1
         pressEffect=False,
         suppressKeys=1,
         command=self.do_update,
         extraArgs=[None, param],
     )
     btn['indicatorValue'] = param.get_param()
     widget = SizerWidget(btn)
     return widget