Resources | developer.brewmp.com Resources | developer.brewmp.com

Developer

resources

Performance considerations

Initialization

If an application uses themes, theming should be enabled on applet initialization, so the widgets are drawn using theme values.

Runtime property referencing

When an application uses the nr:PropertyReference helper function to reference another property at runtime, applying a property means that the reference has to be resolved at runtime. If possible, use compile-time property referencing.

For example, in c_widgettheming_app, the naturetheme.car file uses runtime property referencing in the following way:

   AEECLSID_CButtonWidget = { --Applied by default to all button widgets
      properties = nr:Properties {
         {PROP_BGCOLOR, black},
         {PROP_BORDERCOLOR, yellow},
         {PROPEX_BORDERWIDTH, 10},
      },
   },
   AEECLSID_CStaticWidget = { --Applied by default to all static widgets
      properties = nr:Properties {
         {PROP_FGCOLOR, nr:PropertyReference("AEECLSID_CButtonWidget.properties",
          PROP_BORDERCOLOR) },
      },
   },

Note: This is a demonstration. The same effect can be achieved by defining a common variable that both properties reference, for example:

local bgcontrastcolor = yellow

Both properties can use the variable, as shown below:

   AEECLSID_CButtonWidget = { --Applied by default to all button widgets
      properties = nr:Properties {
         {PROP_BGCOLOR, black},
         {PROP_BORDERCOLOR, bgcontrastcolor},
         {PROPEX_BORDERWIDTH, 10},
      },
   },
   AEECLSID_CStaticWidget = { --Applied by default to all static widgets
      properties = nr:Properties {
         {PROP_FGCOLOR, bgcontrastcolor},
      },
   },

In many cases, applications can specify property values without using nr:PropertyReference. nr:PropertyReference is provided for the cases where the only way to achieve the desired result is to reference other properties at runtime.