Theming - RubbaBoy/EmojIDE GitHub Wiki
Teming is an important task within the IDE, as it allows for a customized UI without overriding anything else, as it is vastly expandable. Theming allows for the rendering of a Frame to be separated into another object, with all other logic being delegated to the primary Frame. An example of this is in the TabbedFrame frame. It is in its own package, com.uddernetworks.emojide.gui.tabbed, and its file structure is the following:
.tabbed
├TabbedFrame
├TabbedFrameTheme
├DefaultTabbedFrame
├IntelliJTabbedFrame
└TabbedFrameConstants
Here is what the above classes do:
This is the primary Frame of the component. This hosts all the logic of it, and this is what you initialize as a normal Frame and use for children, displaying, whatever. When it wants to render anything, it invoked an instance of the TabbedFrameTheme (shown below) where the instance is retrieved by the following line of code:
TabbedFrameTheme theme = ThemeDependantRendering.getImplementation(this);This is an interface containing all the methods that get the rendered emoji data from each of the themes. This includes setting offsets, rendering headers, etc. There are two implementations of this, for the Default and IntelliJ themes.
This is an instance of TabbedFrameTheme that renders everything for the default theme.
This must be registered after the reation of a ThemeDependantRendering object in the main class, with the following code
ThemeDependantRendering.registerImplementation(TabbedFrame.class, Theme.DEFAULT, DefaultTabbedFrame::new);This is an instance of TabbedFrameTheme that renders everything for the IntelliJ theme. See the code block above on registering, it's pretty much the same.
The constants are simply constant variables that change based on the currently selected theme. These can be things like offsets in which to add children to, or anything else. This is just an enum containing the constants that themed frames' implementations must register with the following code:
static {
ThemeDependantRendering.setThemeConstant(TabbedFrame.class, Theme.INTELLIJ, AVAILABLE_TEXT_HEIGHT, 11);
}These constants can be fetched via something like
int textHeight = ThemeDependantRendering.getThemeConstant(TabbedFrame.class, AVAILABLE_TEXT_HEIGHT);