FXML <opaqueInsets> 标签
FXML <opaqueInsets> tag
我正在试验 FXML 布局,以了解如何使用边距、边框和填充来布局节点。我使用 SceneBuilder 创建了一个虚拟 FXML 布局:
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.HBox?>
<HBox maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8.0.111" xmlns:fx="http://javafx.com/fxml/1">
<children>
<AnchorPane prefWidth="180.0" style="-fx-border-width: 5; -fx-border-color: blue;">
<HBox.margin>
<Insets bottom="2.0" left="2.0" right="2.0" top="2.0" />
</HBox.margin>
<children>
<AnchorPane layoutY="8.0" style="-fx-background-color: orange;" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" />
</children>
<padding>
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
</padding>
<opaqueInsets>
<Insets bottom="20.0" left="20.0" right="20.0" top="20.0" />
</opaqueInsets>
</AnchorPane>
<AnchorPane prefHeight="200.0" prefWidth="200.0" style="-fx-border-color: red; -fx-border-width: 10;" />
<AnchorPane prefHeight="200.0" prefWidth="200.0" style="-fx-border-color: gold; -fx-border-width: 15;">
<children>
<AnchorPane layoutX="-14.0" layoutY="100.0" />
</children>
</AnchorPane>
</children>
</HBox>
但是在 SceneBuilder 中有 'Opaque Insets' 个值框:
并且我已经在上面的 FXML 中添加了它们。
但是它们有什么用呢?它们似乎对布局的视觉外观没有影响,我在 Introduction to FXML 中没有找到对它们的任何引用。它们可能是来自 FXML 1.0 的 'left-over' 吗?
opaqueInsets
属性定义在Region
。直接引用 documentation:
Defines the area of the region within which completely opaque pixels are drawn. This is used for various performance optimizations. The pixels within this area MUST BE fully opaque, or rendering artifacts will result. It is the responsibility of the application, either via code or via CSS, to ensure that the opaqueInsets is correct for a Region based on the backgrounds and borders of that region. The values for each of the insets must be real numbers, not NaN or Infinity. If no known insets exist, then the opaqueInsets should be set to null.
我读这篇文章的方式是,您可以在 Region
上定义 opaqueInsets
,以提供渲染提示,即这些插图内的区域完全不透明。这是作为性能提示提供的 - 大概的想法是渲染器可以忽略该区域内具有较低 z-order 的任何节点。
我正在试验 FXML 布局,以了解如何使用边距、边框和填充来布局节点。我使用 SceneBuilder 创建了一个虚拟 FXML 布局:
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.HBox?>
<HBox maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8.0.111" xmlns:fx="http://javafx.com/fxml/1">
<children>
<AnchorPane prefWidth="180.0" style="-fx-border-width: 5; -fx-border-color: blue;">
<HBox.margin>
<Insets bottom="2.0" left="2.0" right="2.0" top="2.0" />
</HBox.margin>
<children>
<AnchorPane layoutY="8.0" style="-fx-background-color: orange;" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" />
</children>
<padding>
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
</padding>
<opaqueInsets>
<Insets bottom="20.0" left="20.0" right="20.0" top="20.0" />
</opaqueInsets>
</AnchorPane>
<AnchorPane prefHeight="200.0" prefWidth="200.0" style="-fx-border-color: red; -fx-border-width: 10;" />
<AnchorPane prefHeight="200.0" prefWidth="200.0" style="-fx-border-color: gold; -fx-border-width: 15;">
<children>
<AnchorPane layoutX="-14.0" layoutY="100.0" />
</children>
</AnchorPane>
</children>
</HBox>
但是在 SceneBuilder 中有 'Opaque Insets' 个值框:
并且我已经在上面的 FXML 中添加了它们。
但是它们有什么用呢?它们似乎对布局的视觉外观没有影响,我在 Introduction to FXML 中没有找到对它们的任何引用。它们可能是来自 FXML 1.0 的 'left-over' 吗?
opaqueInsets
属性定义在Region
。直接引用 documentation:
Defines the area of the region within which completely opaque pixels are drawn. This is used for various performance optimizations. The pixels within this area MUST BE fully opaque, or rendering artifacts will result. It is the responsibility of the application, either via code or via CSS, to ensure that the opaqueInsets is correct for a Region based on the backgrounds and borders of that region. The values for each of the insets must be real numbers, not NaN or Infinity. If no known insets exist, then the opaqueInsets should be set to null.
我读这篇文章的方式是,您可以在 Region
上定义 opaqueInsets
,以提供渲染提示,即这些插图内的区域完全不透明。这是作为性能提示提供的 - 大概的想法是渲染器可以忽略该区域内具有较低 z-order 的任何节点。