How to Create a new Theme

A Theme is a base class object that is created and customized as ThemeName. It is constructed during program initialization in a theme plugin PluginTClient, defined in plugins/theme_name source directory.

theme_name.C and theme_name.h are derived Theme class object constructors.

A Theme is constructed during initialization in init_theme (mwindow.C). The theme plugin is accessed using the name from preferences and then the theme plugin is loaded which contains the code to construct the theme. A Theme object has functions and data that CINELERRA-GG uses to do a variety of customizations, such as default_window_positions, and it can modify GUI defaults like
default_text_color when it is initialized.

The theme plugin contains a new_theme function that allocates and constructs a ThemeName object with base classes of BC_Theme (gui setup), Theme (CINELERRA-GG defaults), and ThemeName, with definitions and overrides that create the custom theme. To create a new theme, a new plugin is needed:

	#include "header files.h"
	PluginClient* new_plugin(PluginServer *server)
	{
		return new NameMain(server);
	}
	
	NameMain::NameMain(PluginServer *server)
	: PluginTClient(server)
	{
	}
	
	NameMain::~NameMain()
	{
	}
	const char* NameMain::plugin_title() { return N_("Name"); }
	
	Theme* NameMain::new_theme()
	{
		theme = new ThemeName;
		extern unsigned char _binary_theme_name_data_start[];
		theme->set_data(_binary_theme_name_data_start);
		return theme;
	}
	
	Name::Name()
	: Theme()
	{
	}
	
	Name::~Name()
	{
		delete stuff;
	}

When a theme is constructed by NameMain::new_theme(), it sets a pointer to a block of data created in the plugin build that contains all of the png data files in the plugins/theme_name/data directory. These images may define or override the appearance of gui images, such as ok.png (the ok button). There are usually a large number of images that need to be defined. The theme plugin adds them to the theme image data in the theme initialize() function. The best list of theme image setup is probably in SUV (plugins/theme_suv/suv).

The easy way to create a new theme is to copy an existing theme and change its name to ThemeName, change plugin_title() to the new name, and then tweak the definitions until you are happy with the results. The file names and Makefile also need to be updated to the new theme name. The source can by manually rebuilt by invoking make in the plugins/theme_name directory.

Once the new theme is built into the plugin library, it will automatically be discovered by the plugin probe and it will become an available theme in Preferences.

If you are ready to add it to the main build, then theme_name should be included in the DIRS targets of the plugins/Makefile, and plugin_defs needs theme_name in the themes list.

Themes usually require considerable time to create from scratch. For example, the SUV theme has over 800 lines in the initialize function, and has over 500 png images in the data directory. Most of these images and data values are required to be initialized by the custom theme constructor; very tedious and time consuming work. Creating a new theme is usually a lot of work.

The CINELERRA-GG Community, 2021
https://www.cinelerra-gg.org