Skip to content

Commit

Permalink
Verify version & arrange colors in configureFromXML
Browse files Browse the repository at this point in the history
  • Loading branch information
Mathis-Hu committed Aug 7, 2023
1 parent 886c8c0 commit d7ab370
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ public class GroupWidget extends MacroWidget
/** Group Widget version */
public static final Version GROUP_WIDGET_VERSION = new Version(3, 0, 0);

private boolean old_colors = false;

/** Widget descriptor */
public static final WidgetDescriptor WIDGET_DESCRIPTOR =
new WidgetDescriptor("group", WidgetCategory.STRUCTURE,
Expand Down Expand Up @@ -184,8 +182,14 @@ public boolean configureFromXML(final ModelReader model_reader, final Widget wid
group_widget.foreground.readFromXML(model_reader, text);
}

if (xml_version.getMajor() < 3)
group_widget.old_colors = true;
if (xml_version.getMajor() < 3) {
final Element text_foreground = XMLUtil.getChildElement(xml, "foreground_color");
if (text_foreground != null)
group_widget.line.readFromXML(model_reader, text_foreground);
final Element text_background = XMLUtil.getChildElement(xml, "background_color");
if (text_background != null && group_widget.style.getValue() == Style.TITLE)
group_widget.foreground.readFromXML(model_reader, text_background);
}

return true;
}
Expand Down Expand Up @@ -254,10 +258,6 @@ public Version getVersion()
return GROUP_WIDGET_VERSION;
}

public boolean isOld_colors() {
return old_colors;
}

/** @return Runtime 'children' property */
public ChildrenProperty runtimeChildren()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public class GroupRepresentation extends JFXBaseRepresentation<Pane, GroupWidget
/** Inner pane that holds child widgets */
private Pane inner;

private volatile boolean firstUpdate = true, changedOldColors = false;
private volatile boolean firstUpdate = true;
private volatile int inset = 10;
private volatile Color foreground_color, line_color, background_color;

Expand Down Expand Up @@ -121,15 +121,6 @@ private void borderChanged(final WidgetProperty<?> property, final Object old_va

private void computeColors()
{


if(model_widget.isOld_colors() && !changedOldColors) {
model_widget.propLineColor().setValue(model_widget.propForegroundColor().getValue());
if(model_widget.propStyle().getValue() == Style.TITLE){
model_widget.propForegroundColor().setValue(model_widget.propBackgroundColor().getValue());
}
changedOldColors = true;
}
line_color = JFXUtil.convert(model_widget.propLineColor().getValue());
foreground_color = JFXUtil.convert(model_widget.propForegroundColor().getValue());
background_color = JFXUtil.convert(model_widget.propBackgroundColor().getValue());
Expand Down

0 comments on commit d7ab370

Please sign in to comment.