diff --git a/Ghidra/Debug/Framework-Debugging/src/main/java/ghidra/dbg/agent/AgentWindow.java b/Ghidra/Debug/Framework-Debugging/src/main/java/ghidra/dbg/agent/AgentWindow.java index 3198ac29c1..5e1c7a995a 100644 --- a/Ghidra/Debug/Framework-Debugging/src/main/java/ghidra/dbg/agent/AgentWindow.java +++ b/Ghidra/Debug/Framework-Debugging/src/main/java/ghidra/dbg/agent/AgentWindow.java @@ -28,7 +28,6 @@ import org.apache.logging.log4j.core.Appender; import org.apache.logging.log4j.core.LoggerContext; import org.apache.logging.log4j.core.config.Configuration; -import generic.theme.GThemeDefaults.Colors.Messages; import ghidra.framework.LoggingInitialization; import ghidra.util.Msg; import ghidra.util.Swing; @@ -74,11 +73,7 @@ public class AgentWindow extends JFrame implements WindowListener, LogListener { @Override public void messageLogged(String message, boolean isError) { -<<<<<<< Upstream, based on origin/master -======= - String fMessage = - isError ? "" + message + "" : message; ->>>>>>> 1e5309a GP-1981 - Theming - Color conversion for Debugger modules + Swing.runIfSwingOrRunLater(() -> { MutableAttributeSet attributes = new SimpleAttributeSet(); if (isError) { diff --git a/Ghidra/Features/Base/src/main/help/help/topics/AutoAnalysisPlugin/AutoAnalysis.htm b/Ghidra/Features/Base/src/main/help/help/topics/AutoAnalysisPlugin/AutoAnalysis.htm index 75d88be43f..fda1271536 100644 --- a/Ghidra/Features/Base/src/main/help/help/topics/AutoAnalysisPlugin/AutoAnalysis.htm +++ b/Ghidra/Features/Base/src/main/help/help/topics/AutoAnalysisPlugin/AutoAnalysis.htm @@ -165,7 +165,7 @@ with the analyzer.

-

+

Note that multi-user merge does not currently support merging of Program Options (including Analysis Options). Options stored in shared Program database following a conflicting checkin may not reflect option settings specified prior to checkin. @@ -182,9 +182,9 @@ the current program. -

+

Access to stored configurations is not currently - aupported across different versions of Ghidra. + supported across different versions of Ghidra.

@@ -452,7 +452,7 @@

-

+

When using an external GNU demangler, please understand the risks associated with using that version of the software. The demangler_gnu_v2_24 version of the diff --git a/Ghidra/Features/Base/src/main/help/help/topics/FrontEndPlugin/Ghidra_Front_end.htm b/Ghidra/Features/Base/src/main/help/help/topics/FrontEndPlugin/Ghidra_Front_end.htm index 6c8abbef53..db73da2d09 100644 --- a/Ghidra/Features/Base/src/main/help/help/topics/FrontEndPlugin/Ghidra_Front_end.htm +++ b/Ghidra/Features/Base/src/main/help/help/topics/FrontEndPlugin/Ghidra_Front_end.htm @@ -448,12 +448,11 @@ - + - + - + diff --git a/Ghidra/Features/Base/src/main/help/help/topics/Glossary/glossary.htm b/Ghidra/Features/Base/src/main/help/help/topics/Glossary/glossary.htm index 93025be9bf..0e488d20e4 100644 --- a/Ghidra/Features/Base/src/main/help/help/topics/Glossary/glossary.htm +++ b/Ghidra/Features/Base/src/main/help/help/topics/Glossary/glossary.htm @@ -25,7 +25,7 @@ xmlns:w="urn:schemas-microsoft-com:office:word" xmlns="http://www.w3.org/TR/REC-

 

-

A

+

A

Action

@@ -97,7 +97,7 @@ xmlns:w="urn:schemas-microsoft-com:office:word" xmlns="http://www.w3.org/TR/REC-
-

B

+

B

Back Reference

@@ -197,7 +197,7 @@ xmlns:w="urn:schemas-microsoft-com:office:word" xmlns="http://www.w3.org/TR/REC-
-

C

+

C

Call Block Model

@@ -319,7 +319,7 @@ xmlns:w="urn:schemas-microsoft-com:office:word" xmlns="http://www.w3.org/TR/REC-
-

D

+

D

Data (item)

@@ -436,7 +436,7 @@ xmlns:w="urn:schemas-microsoft-com:office:word" xmlns="http://www.w3.org/TR/REC-
-

E

+

E

ELF

@@ -491,7 +491,7 @@ xmlns:w="urn:schemas-microsoft-com:office:word" xmlns="http://www.w3.org/TR/REC-
-

F

+

F

Fall Through Address

@@ -555,7 +555,7 @@ xmlns:w="urn:schemas-microsoft-com:office:word" xmlns="http://www.w3.org/TR/REC-
-

G

+

G

Ghidra

@@ -606,7 +606,7 @@ xmlns:w="urn:schemas-microsoft-com:office:word" xmlns="http://www.w3.org/TR/REC-
-

H

+

H

Hex Integer

@@ -636,7 +636,7 @@ xmlns:w="urn:schemas-microsoft-com:office:word" xmlns="http://www.w3.org/TR/REC-
-

I

+

I

IDA Pro

@@ -688,7 +688,7 @@ xmlns:w="urn:schemas-microsoft-com:office:word" xmlns="http://www.w3.org/TR/REC-
-

K

+

K

Key Binding

@@ -698,7 +698,7 @@ xmlns:w="urn:schemas-microsoft-com:office:word" xmlns="http://www.w3.org/TR/REC-
-

L

+

L

Label 

@@ -756,7 +756,7 @@ xmlns:w="urn:schemas-microsoft-com:office:word" xmlns="http://www.w3.org/TR/REC-
-

M

+

M

@@ -848,7 +848,7 @@ xmlns:w="urn:schemas-microsoft-com:office:word" xmlns="http://www.w3.org/TR/REC-
-

N

+

N

Name Space

@@ -865,7 +865,7 @@ xmlns:w="urn:schemas-microsoft-com:office:word" xmlns="http://www.w3.org/TR/REC-
-

O

+

O

Offcut

@@ -906,7 +906,7 @@ xmlns:w="urn:schemas-microsoft-com:office:word" xmlns="http://www.w3.org/TR/REC-
-

P

+

P

Partitioned Code Model

@@ -1058,7 +1058,7 @@ xmlns:w="urn:schemas-microsoft-com:office:word" xmlns="http://www.w3.org/TR/REC-
-

R

+

R

Read-Only Project

@@ -1108,7 +1108,7 @@ xmlns:w="urn:schemas-microsoft-com:office:word" xmlns="http://www.w3.org/TR/REC-
-

S

+

S

Scalar

@@ -1239,7 +1239,7 @@ xmlns:w="urn:schemas-microsoft-com:office:word" xmlns="http://www.w3.org/TR/REC-
-

T

+

T

Tabbed Window

@@ -1297,7 +1297,7 @@ xmlns:w="urn:schemas-microsoft-com:office:word" xmlns="http://www.w3.org/TR/REC-
-

U

+

U

Unconditional Call

@@ -1352,7 +1352,7 @@ xmlns:w="urn:schemas-microsoft-com:office:word" xmlns="http://www.w3.org/TR/REC-
-

V

+

V

Version Control

@@ -1383,7 +1383,7 @@ xmlns:w="urn:schemas-microsoft-com:office:word" xmlns="http://www.w3.org/TR/REC-
-

W

+

W

Workspace

@@ -1394,7 +1394,7 @@ xmlns:w="urn:schemas-microsoft-com:office:word" xmlns="http://www.w3.org/TR/REC-
-

X

+

X

XREF

diff --git a/Ghidra/Features/Base/src/main/help/help/topics/Tool/ToolOptions_Dialog.htm b/Ghidra/Features/Base/src/main/help/help/topics/Tool/ToolOptions_Dialog.htm index 1b28628dec..4719feaa67 100644 --- a/Ghidra/Features/Base/src/main/help/help/topics/Tool/ToolOptions_Dialog.htm +++ b/Ghidra/Features/Base/src/main/help/help/topics/Tool/ToolOptions_Dialog.htm @@ -294,16 +294,11 @@
File StatusFile StatusSample Icon in Project Data - TreeSample IconDescriptionDescription
- - - - + - + @@ -398,15 +393,11 @@
-

Tool Options

-
OptionOptionDescriptionDescription
- - - - + - + @@ -445,7 +436,7 @@ of the UI. Doing this effectively creates a Dark Theme, which some users find less visually straining.

-
+

As a prototype feature, this feature has many known issues, including:

diff --git a/Ghidra/Features/FunctionGraph/certification.manifest b/Ghidra/Features/FunctionGraph/certification.manifest index b2032df49a..05bca5ea1c 100644 --- a/Ghidra/Features/FunctionGraph/certification.manifest +++ b/Ghidra/Features/FunctionGraph/certification.manifest @@ -66,8 +66,6 @@ src/main/resources/images/fgpaths.png||GHIDRA||reviewed||END| src/main/resources/images/fgrevblock.png||GHIDRA||reviewed||END| src/main/resources/images/field.header.png||GHIDRA||reviewed|Custom icon|END| src/main/resources/images/fullscreen_view.png||FAMFAMFAM Icons - CC 2.5||||END| -src/main/resources/images/function_graph.png||FAMFAMFAM Icons - CC 2.5||||END| -src/main/resources/images/function_graph_curvey.png||GHIDRA||reviewed|author eric|END| src/main/resources/images/graph_view.png||FAMFAMFAM Icons - CC 2.5||||END| src/main/resources/images/house.png||FAMFAMFAM Icons - CC 2.5||||END| src/main/resources/images/id.png||FAMFAMFAM Icons - CC 2.5||||END| diff --git a/Ghidra/Features/FunctionGraph/src/main/help/help/topics/FunctionGraphPlugin/Function_Graph.html b/Ghidra/Features/FunctionGraph/src/main/help/help/topics/FunctionGraphPlugin/Function_Graph.html index b66dce8c8f..97a6c2207a 100644 --- a/Ghidra/Features/FunctionGraph/src/main/help/help/topics/FunctionGraphPlugin/Function_Graph.html +++ b/Ghidra/Features/FunctionGraph/src/main/help/help/topics/FunctionGraphPlugin/Function_Graph.html @@ -33,51 +33,6 @@ "#Function_Graph_Actions">actions that apply to the entire graph.

-

NoteWhat's New

- -
-
-

Primary View

diff --git a/Ghidra/Framework/Docking/src/main/help/help/TOC_Source.xml b/Ghidra/Framework/Docking/src/main/help/help/TOC_Source.xml index 584eba039b..233752f8a2 100644 --- a/Ghidra/Framework/Docking/src/main/help/help/TOC_Source.xml +++ b/Ghidra/Framework/Docking/src/main/help/help/TOC_Source.xml @@ -60,8 +60,8 @@ - - + + diff --git a/Ghidra/Framework/Docking/src/main/help/help/shared/DarkStyle.css b/Ghidra/Framework/Docking/src/main/help/help/shared/DarkStyle.css new file mode 100644 index 0000000000..6ff0fe6fb8 --- /dev/null +++ b/Ghidra/Framework/Docking/src/main/help/help/shared/DarkStyle.css @@ -0,0 +1,58 @@ +/* ### + * IP: GHIDRA + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/* + Java Help Note: JavaHelp does not accept sizes (like in 'margin-top') in anything but + px (pixel) or with no type marking. +*/ + +body { margin-bottom: 50px; margin-left: 10px; margin-right: 10px; margin-top: 10px; } /* some padding to improve readability */ +li { font-family:times new roman; font-size:14pt; } +h1 { color:#80a0c0; font-family:times new roman; font-size:36pt; font-style:italic; font-weight:bold; text-align:center; } +h2 { margin: 10px; margin-top: 20px; color:#DDA0DD; font-family:times new roman; font-size:18pt; font-weight:bold; } +h3 { margin-left: 10px; margin-top: 20px; color:#6495ED; font-family:times new roman; font-size:14pt; font-weight:bold; } +h4 { margin-left: 10px; margin-top: 20px; font-family:times new roman; font-size:14pt; font-style:italic; } + +/* + P tag code. Most of the help files nest P tags inside of blockquote tags (the was the + way it had been done in the beginning). The net effect is that the text is indented. In + modern HTML we would use CSS to do this. We need to support the Ghidra P tags, nested in + blockquote tags, as well as naked P tags. The following two lines accomplish this. Note + that the 'blockquote p' definition will inherit from the first 'p' definition. +*/ +p { margin-left: 40px; font-family:times new roman; font-size:14pt; } +blockquote p { margin-left: 10px; } + +p.providedbyplugin { color:#7f7f7f; margin-left: 10px; font-size:14pt; margin-top:100px } +p.ProvidedByPlugin { color:#7f7f7f; margin-left: 10px; font-size:14pt; margin-top:100px } +p.relatedtopic { color:#9370DB; margin-left: 10px; font-size:14pt; } +p.RelatedTopic { color:#9370DB; margin-left: 10px; font-size:14pt; } + +/* + We wish for a tables to have space between it and the preceding element, so that text + is not too close to the top of the table. Also, nest the table a bit so that it is clear + the table relates to the preceding text. +*/ +table { margin-left: 20px; margin-top: 10px; width: 80%;} +td { font-family:times new roman; font-size:14pt; vertical-align: top; } +th { font-family:times new roman; font-size:14pt; font-weight:bold; background-color: #EDF3FE; color: gray;} + +/* + Code-like formatting for things such as file system paths and proper names of classes, + methods, etc. To apply this to a file path, use this syntax: + ... +*/ +code { color: #F5F5F5; font-weight: bold; font-family: courier new, monospace; font-size: 14pt; white-space: nowrap; } +code.path { color: #4682B4; font-weight: bold; font-family: courier new, monospace; font-size: 14pt; white-space: nowrap; } diff --git a/Ghidra/Framework/Docking/src/main/help/help/topics/Theming/ThemingDeveloperDocs.html b/Ghidra/Framework/Docking/src/main/help/help/topics/Theming/ThemingDeveloperDocs.html index 4be4a61936..086394618e 100644 --- a/Ghidra/Framework/Docking/src/main/help/help/topics/Theming/ThemingDeveloperDocs.html +++ b/Ghidra/Framework/Docking/src/main/help/help/topics/Theming/ThemingDeveloperDocs.html @@ -5,129 +5,139 @@ - Theming Developer Documentation - - + Developer's Guide -

Ghidra Theming Developer Documentation

+

Developer's Guide to Theming

-

This document provides everything an application developer should know when developing - plugins, scripts, etc., that use colors, fonts, or icons. By following these guidelines, +

This document provides information an application developer should know when developing + plugins, actions, scripts, etc., that use colors, fonts, or icons. By following these guidelines, developers can easily make use of Ghidra's theming capabilities.

Theme Resource Types

When developing application code for Ghidra such as plugins, actions, etc., developers often - want to use a color, font, or icon. The key idea to support theming is to never directly - reference these resources. Instead, the developer should "create" an id string for the resource - and then in a .theme.properties file provide a default value for that id (and if appropriate, - also define an alternate default value if the theme is a "dark" theme).  The way you - define and use these ids is a bit different depending on whether the resource is a color, font, - or icon. Colors and Icons are similar in that references are done using either GColor or GIcon, - Unfortunately, because of the way Fonts are implemented, there is no GFont, so using fonts is a - bit more involved.

+ want to use colors, fonts, and icons. The key idea to support theming is to never + directly + reference those resources. Instead, the developer should create an ID string for the resource + and then in a module.theme.properties file, provide a default value for that ID. + (Also, you may define an alternate "dark" default value that will be used if the + current theme is considered a dark theme). The way you + define and use these IDs is a bit different depending on whether the resource is a color, font, + or icon. Colors and icons are similar in that developers use these types by creating either + GColor or GIcon. + Unfortunately, because of the way fonts are implemented, there is no equivalent + GFont, so using fonts is a bit more involved.

Colors

-

For colors, developers should use the GColor class. Simply construct a new GColor object - passing in the color resource id as the argument. GColor is a subclass of Color, so it can be - used anywhere a Color would be used. The developer then needs to provide a default value for - that id in the module's theme.properties file. So, for example:

+

For colors, developers should use the GColor class. Simply construct a new + GColor object passing in the color resource ID as the argument. + GColor is a subclass of Color, so it can be + used anywhere a Color would be used. The developer then needs to provide a + default value for that ID in the module's module.theme.properties file. + So, for example:

- panel.setBackground(Color.Red); + panel.setBackground(Color.Red);

becomes

- panel.setBackground(new GColor("color.bg.abc")); + panel.setBackground(new GColor("color.bg.abc"));

and

- public static final Color MY_COLOR = Color.BLUE; + public static final Color MY_COLOR = Color.BLUE;

becomes

- public static final Color MY_COLOR = new + public static final Color MY_COLOR = new GColor("color.fg.xzy");
-

The GColor class uses a delegation model where all method calls to GColor get mapped to - its delegate. If ever the color associated with a GColor's resource id changes, the GColor is - refreshed by calling the refresh() method. This is done automatically whenever the - Gui.setColor(id) is called or a new theme is loaded.

+

The GColor class uses a delegation model where all method calls to + GColor get mapped to + its delegate color. If ever the color associated with a GColor's resource ID + changes, the GColor is automatically updated by calling the + refresh() method. This is done whenever the + Gui.setColor(id) is called or a new theme is loaded.

+ +

Icons

+ +

Icons work just like colors, so you can just create a GIcon(String id). + So, for example,

+ +
+
+ public static final Icon MY_ICON = + ResourceManager("images/balloon.png"); +
+ +

becomes

+ +
+ public static final Icon MY_ICON = new + GIcon("icon.text.bubble"); +
+

Fonts

-

Unfortunately, fonts able to use the delegation trick that was used for colors. Therefore, - there is no GFont class. Programming fonts requires a bit more work. If the use of a font is - in a renderer or in a paint method, imply get the font each time from the Gui class (Font - font = Gui.getFont(String id)). To set a font on a component, use the "registerFont" method - on the Gui class. Once the component is registered, the application will automatically update - the component's font if the font associated with that id changes. So, for example:

+

Unfortunately, fonts are unable to use the delegation model used for colors and icons. + Therefore, there is no GFont class. Programming fonts requires a bit more work. + If a font used directly, such as in renderer or in a paint method, simply get the + font each time + from the Gui class, as shown below. To set a font on a component, use + Gui.registerFont(Component, String). Once the component is registered, the + application will + automatically update the component if the font associated with that ID changes. So, for + example:

- Font font = new Font("Monospaced", Font.BOLD, 12); + Font font = new Font("Monospaced", Font.BOLD, 12);

becomes

- Font font = Gui.getFont("font.xyz"); + Font font = Gui.getFont("font.xyz");

or

- myLabel.setFont(new Font("Dialog", Font.PLAIN, 14) + myLabel.setFont(new Font("Dialog", Font.PLAIN, 14)

becomes

- Gui.registerFont(myLabel, "font.xyz"); + Gui.registerFont(myLabel, "font.xyz");
-

Icons

+
-

Icons work just like colors, so you can just create a GIcon(String id). So, for - example, 

-
-
- public static final Icon MY_ICON = - ResourceManager("images/balloon.png"); -
- -

becomes

- -
- public static final Icon MY_ICON = new - GIcon("icon.text.bubble"); -
-
-
- -

Resource Id Strings

+

Resource ID Strings

-

Resource Ids are strings used to identify the color, font, or icon. These strings are - "made up" by the developer and should be chosen in a way that it is as self describing as +

Resource IDs are strings used to identify a color, font, or icon. These strings are + created by the developer and should be chosen in a way that it is as self-describing as possible. So, for example, if you wanted the text color in some error message in some widget - "abc", you might create the color id "color.fg.abc.error". To make resource ids as consistent - as possible, we created a convention for ids as follows: 

+ "abc", you might create the color ID "color.fg.abc.error". To help keep resource IDs + consistent, we created a convention for IDs as follows:

@@ -145,11 +155,10 @@
  • category: any value, examples include 'bg'(background), 'fg'(foreground), 'cursor'. There may be multiple dot-separated values.
  • -
  • client: the plugin name or feature name; any value usd to represent a more - specialized use.
  • +
  • client: the plugin name or feature name.
  • specialized uses: any key value here that applies to the client, such as - "vertex' for a graph client.
  • + 'vertex' for a graph client.
    @@ -160,6 +169,8 @@
  • color.bg.listing
  • +
  • color.bg.functiongraph.vertex.group
  • +
  • font.listing
  • font.listing.header
  • @@ -176,11 +187,16 @@

    Theme Property Files

    -

    The default values for resource ids are defined in "theme property" files that created in - each module's data directory. For small modules there can be just one theme properties, but - larger modules should probably use multiple files; one for each sub-feature. The application - will find all theme property files as long as they exist in a module's data directory and end - with '.theme.properties'.

    +

    The default values for resource IDs are defined in files that reside + a module's data directory (not all modules define this file). These files all + are named to end in theme.properties and begin with the module's name. Some + modules make use of multiple files in order to better manage the volume of IDs. In this + case, the name of each properties file offers a clue as to its contents. Thus, for small + modules, those without many resource IDs in use, one theme properties file is sufficient to + easily define and manage all required IDs. But, we recommend larger modules use multiple + files, one for each sub-feature. The application will find all theme property files as long as + they exist in a module's data directory and are named with the + .theme.properties suffix.

    Theme Properties File Naming Convention

    @@ -191,7 +207,7 @@
     
    -      [module name][.additional name]].theme.properties
    +      module name[.additional name]].theme.properties
     
     
    @@ -201,17 +217,17 @@
    • base.theme.properties
    • -
    • base.funtiongraph.theme.properties
    • +
    • base.listing.theme.properties

    Theme Properties File Format

    Theme files uses a very simple format for specifying theme property values. Each line - specifies a property id (sometimes referfed to as key) and a value, separated by an "=". A - theme properties file consists of two sections: the standard defaults section and a section - for specifying defaults for "dark" themes. So a file theme file uses the following - format:

    + specifies a property ID (sometimes referred to as the key) and a value, separated by an + "=". A theme properties file consists of two sections: the standard defaults section and a + section for specifying defaults for "dark" themes. +

    @@ -259,13 +275,15 @@ color.fg.listing.bytes = orange
    -

    NOTE: The [Dark Defaults] section is for overriding values defined in the standard - [Defaults] section. If a property id is not given a value in the defaults section, it is an - error. If a value is not defined in the [Dark Defaults] section, then the value defined in - the [Defaults] section will be used in a dark theme.

    + +

    NOTE: The [Dark Defaults] section is for optionally overriding values + defined in the standard [Defaults] section. If a property ID is not given a value + in the defaults section, it is an error. If a value is not defined in the + [Dark Defaults] section, then the value defined in the [Defaults] + section will be used in a dark theme.

    -

    Theme Property Values

    +

    Theme Property Values

    The values specified in the theme properties files can be specified in a variety of ways, @@ -273,15 +291,15 @@ color.fg.listing.bytes = orange directly in the theme properties file. A font value can specified as a reference to another defined font, but with a different size or style.

    -

    Also, any value can also be a reference to some other id of the same type. So, for +

    Also, any value can also be a reference to some other ID of the same type. So, for example, a reference color entry might be something like "color.bg.listing = color.bg". This says that the listing's background color should be whatever "color.bg" is defined to be. Note that all of the application's defined properties start with either "color.", "font.", or - "icon.". Properties defined by a Java LookAndFeel don't follow this pattern. To reference a - property that does not have a standard prefix, an id can be prefixed with "[color]", + "icon.". Properties defined by a Java Look and Feel don't follow this pattern. To reference a + property that does not have a standard prefix, an ID can be prefixed with "[color]", "[font]", or "[icon] as appropriate to allow the theme property parser to recognize the - values as ids to other properties. So to refer to a property named "table.background, it - would be "color.bg.table = [color]table.background".

    + values as IDs to other properties. So to refer to a Java property named "table.background", + you would use the following definition: "color.bg.table = [color]table.background".

    Color Values

    @@ -301,7 +319,8 @@ color.fg.listing.bytes = orange
  • rgba(red, green, blue, alpha)
  • -
  • [web color name] the name of a web color such as red, olive, or purple
  • +
  • web color name // the case-insensitive name of a web color such as red, olive, or + purple
  • @@ -324,14 +343,16 @@ color.fg.listing.bytes = orange
     
    -      [family name]-[style]-[size]
    +      family name-style-size
     
     
      -
    • family name: the font name such as monospaced, dialog, courier.
    • +
    • family name: the font name such as monospaced, dialog, + courier.
    • -
    • style: One of PLAIN, BOLD, ITALIC, or BOLDITALIC.
    • +
    • style: One of PLAIN, BOLD, ITALIC, or + BOLDITALIC.
    • size: the font point size. 12 is very common.
    @@ -341,7 +362,7 @@ color.fg.listing.bytes = orange
             font.foo = monospaced-PLAIN-12
             font.foo = courier-BOLD-14
    -        font.foo = SansSerif-ITALIC=10
    +        font.foo = SansSerif-ITALIC-10
     

    Font Modifiers

    @@ -352,18 +373,19 @@ color.fg.listing.bytes = orange
     
    -      font.ref[family name][style][size]
    +      font.ref[family name][style][size]
     
     
      -
    • font.ref - the theme property id of some other font
    • +
    • font.ref: the theme property ID of some other font
    • family name: use the size and style of the reference font, but use this font - family
    • + family. -
    • style: use the same font as the reference font, but with this style. One of PLAIN, - BOLD, ITALIC, or BOLDITALIC
    • +
    • style: use the same font as the reference font, but with this style. One of + PLAIN, BOLD, ITALIC, or + BOLDITALIC.
    • size: use the same font as the reference font, but with this size.
    @@ -387,22 +409,22 @@ color.fg.listing.bytes = orange
     
    -      iconName[size(width,height)][disabled]{iconOverlayName[size(width,geight)[disabled][move(x,y)]}{...}
    +      iconName[size(width,height)][disabled]{iconOverlayName[size(width,height)[disabled][move(x,y)]}{...}
     
     
     
      -
    • iconName - the name the base icon
    • +
    • iconName: the name the base icon
    • -
    • size(width,height) - optional modifier to scale the image to the given size.
    • +
    • size(width,height): optional modifier to scale the image to the given size.
    • -
    • disabled - optional modifier to create a disabled version of the icon.
    • +
    • disabled: optional modifier to create a disabled version of the icon.
    • -
    • {...} - optional modifier to overlay an icon on the base icon. It is recursively - defined using the same format.
    • +
    • {...}: optional modifier to overlay an icon on the base icon. It is recursively + defined using the standard icon format.
    • -
    • move(x,y) - optional modifier on overlays to position them relative to the base +
    • move(x,y): optional modifier on overlays to position them relative to the base icon.
    @@ -417,22 +439,26 @@ color.fg.listing.bytes = orange // hammer.icon overlayed in its lower right corner -

    To create an icon suitable for dynamically overlaying other icons, there is special syntax - for specifying an empty base icon, then overlay another icon in some specific area of the - empty icon. This icon can then be used to overlay dynamically in the code. For example, to - create an overlay icon that would add a flag to the bottom, right corner any other iconw:

    +

    To create stand-alone icon suitable for dynamically overlaying other icons, there is + special syntax for specifying an empty base icon. Use the empty icon along with another + overlay icon in some specific area of the empty icon to create a final icon that can be used + as an overlay for other icons. For example, to + create an overlay icon that would add a flag to the bottom-right corner of any other icon:

    -        icon.foo = EMPTY_ICON[size(16,16)]{flag.png[size(6,6)][move(10,10)]}
    +        icon.overlay.flag = EMPTY_ICON[size(16,16)]{flag.png[size(6,6)][move(10,10)]}
     
    + +

    Provided by: Theme Manager

    +

    Related Topics


    diff --git a/Ghidra/Framework/Docking/src/main/help/help/topics/Theming/ThemingInternals.html b/Ghidra/Framework/Docking/src/main/help/help/topics/Theming/ThemingInternals.html index eaa3667ba8..6a72228954 100644 --- a/Ghidra/Framework/Docking/src/main/help/help/topics/Theming/ThemingInternals.html +++ b/Ghidra/Framework/Docking/src/main/help/help/topics/Theming/ThemingInternals.html @@ -5,90 +5,106 @@ - Theming Internals Documentation + Theming Architecture -

    Ghidra Theming Internals Documentation

    +

    Theming Architecture

    -

    This document describes the api for initializing and managing themes. A theme (the GTheme - class) in Ghidra represents a specific LookAndFeel as well the set of values for the color, - font, and icon resource ids used in the application.  The Gui class provides a set of +

    This document describes the API for initializing and managing themes. A theme (the + GTheme + class) in Ghidra represents a specific Look and Feel as well the set of values for the color, + font, and icon resource IDs used in the application. Resource IDs are defined in theme properties + files. Application writers refer to these IDs when using colors, fonts and icons. + The Gui class provides a set of static methods that serves as the primary interface for managing all aspects of theming.

    -

    GTheme class

    +

    GTheme Class

    -

    The GTheme class is the implementation of the theme concept. At any giving time, the - application is using resource values as specified by an  active theme. The theme specifies - the LookAndFeel, whether or not the overall theme is "dark" (which determines which default +

    The GTheme class is the implementation of the theme concept. At any given time, + the application is using resource values as specified by the active theme. The theme specifies + the Java Look and Feel, whether or not the overall theme is "dark" (which determines which default values to use) and any resource values which have been overridden specifically by that theme. - There are two types of of themes; "built-in"  themes and file based themes. "Built-in" - themes are implemented directly as sub-classes of GTheme and simply specify a Java LookAndFeel + There are two types of of themes; built-in themes and file-based themes. Built-in + themes are implemented directly as sub-classes of GTheme and simply specify a + Java Look and Feel and whether or not the theme is "dark". There is one "built-in" theme for each supported - LookAndFeel. File based themes read their values from a theme file. Theme files are created by + Look and Feel. File-based themes read their values from a theme file. Theme files are created by editing and saving existing themes.

    -

    GThemeValueMap / ThemeValue class

    +

    GThemeValueMap / ThemeValue Classes

    -

    These are the base classes for storing values for resource ids.  A GThemeValueMap - consists of three hashmaps; one each for colors, fonts, and icons. Each hashmap maps an id to a - appropriate subclass of ThemeValue, which is the base class for ColorValue, FontValue, and - IconValue. Resource values are stored in these ThemeValue sub-classes because the value can be +

    These are the base classes for storing values for resource IDs. A GThemeValueMap + consists of three maps, one each for colors, fonts, and icons. Each map binds an ID to a + appropriate subclass of ThemeValue, which is the base class for + ColorValue, FontValue, and + IconValue. Resource values are stored in these ThemeValue sub-classes + because the value can be either a concrete value or be a reference to some other resource of the same type. So, for example, "color.bg.foo" could map directly to an actual color or its value could be reference - to some other indirect color like "color.bg.bar". In any ThemeValue object, either the - referenceId or the direct value must be null.  To get the ultimate concrete value, there - is a convenience method called "get" on ThemeValues that takes a GThemeValueMap as an argument. - This method will recursively resolve referenceIds which is why it needs a value map as an + to some other indirect color like "color.bg.bar". In any ThemeValue object, either + the referenced ID or the direct value must be null. To get the ultimate concrete value, there + is a convenience method called get() on ThemeValues that takes a + GThemeValueMap as an argument. + This method will recursively resolve reference IDs, which is why it needs a value map as an argument.

    -

    GThemeValueMaps have some convenience methods for doing set operations.  You can load - values from other GThemeValueMaps into this map, which adds to the current map, replacing - values with the same id with values from the other map. Also, there is a method for getting the - differences from one GThemeValueMap to another. 

    +

    GThemeValueMaps have some convenience methods for performing set operations. + You can load + values from other GThemeValueMaps into this map, which adds to the current map, + replacing values with the same ID with values from the other map. Also, there is a method for + getting the differences from one GThemeValueMap to another.

    -

    Gui class

    +

    Gui Class

    -

    The Gui class is a set of static methods that provides the primary API for managing themes. +

    The Gui class is a set of static methods that provides the primary API for + managing themes. It has methods for switching themes, adding themes, deleting themes, saving themes, restoring - themes, getting/setting values for resource ids, adding theme listeners, and others.

    + themes, getting/setting values for resource IDs, adding theme listeners, and others. This + class is meant to be used by application developers, along with GColor for colors + and GIcon for icons. Fonts are handled slightly differently by making calls to + Gui.registerFont(Component, Id) +

    Application Initialization

    -

    Applications need to call Gui.initialize() before any uses of color, fonts, or icons occur. - This will load all resource defaults from the theme.properties files, read the last used theme - from preferences, and load that theme which includes setting the LookAndFeel.

    +

    Applications need to call Gui.initialize() before any uses of color, fonts, or + icons occur. + This will load all resource defaults from all *.theme.properties files, read the + last used theme from preferences, and load that theme which includes setting the Look and Feel. +

    Loading a Theme

    -

    Loading a theme consists of two main operations. Loading the LookAndFeel and building the - set of values for the resource ids.

    +

    Loading a theme consists of two main operations: loading the Look and Feel and building the + set of values for all defined resource IDs.

    -

    Loading the LookAndFeel

    +

    Loading the Look and Feel

    -

    Because each LookAndFeel present different challenges to the theming feature, there is a - LookAndFeelManager for each LookAndFeel. The LookAndFeelManager is responsible for installing - the lookAndFeel (in the case of Nimbus, we had to install a special subclass of the - NimbusLookAndFeel),  extracting the Java resources mappings(Java LookAndFeel objects also - use a resource id concept), group the java resources into common groups,  possibly fix up - some issues specific to that LookAndFeel, possibly install global properties, and have specific - update (kicking) techniques to get that LookAndFeel to update its componentUIs when values - change.

    +

    Because each Look and Feel presents different challenges to the theming feature, there is a + LookandFeelManager for each Look and Feel. The LookandFeelManager is + responsible for installing + the Look and Feel (in the case of Nimbus, we had to install a special subclass of the + NimbusLookandFeel), extracting the Java resources mappings (Java Look and Feel + objects also use a resource ID concept), group the Java resources into common groups, possibly + fix up some issues specific to that Look and Feel, possibly install global properties, and have + specific update techniques to get that Look and Feel to update its component UIs when + values change.

    Creating the Active Theme Values

    -

    After the LookAndFeel is loaded and the java values extracted, the final resource mapping is - created. This is done by loading various resource values sets(each stored in a GThemeValueMap) - in the correct order into a new GThemeValueMap in GUI called "currentValues" .  When - values are loaded into a GThemeValueMap, they will replace any existing values with the same - id.  The values are loaded in the following order:

    +

    After the Look and Feel is loaded and the Java values extracted, the final resource mapping is + created. This is done by loading various resource values sets (each stored in a GThemeValueMap) + in the correct order into a new GThemeValueMap in ThemeManager called + "currentValues" . When values are loaded into a GThemeValueMap, they will replace + any existing values with the same ID. The values are loaded in the following order:

      -
    • java defaults (values from LookAndFeel)
    • +
    • Java defaults (values from Look and Feel)
    • -
    • application defaults (from theme.properties files)
    • +
    • application defaults (from *.theme.properties files)
    • applications dark defaults (if theme is dark)
    • @@ -98,89 +114,114 @@

      Changing Values Associated With Resource Ids

      -

      Whenever the value associated with a resource id changes, the application gets "kicked" in - various ways to update the display with the new value. The technique used to "kick" the - application differs depending on the resource type and the LookAndFeel (these differences are - captured in the LookAndFeelManager sub-classes for each LookAndFeel).  It can also vary - depending on whether the value is an application defined resource or a java defined +

      Whenever the value associated with a resource ID changes, the application gets notified in + various ways to update the display with the new value. The technique used to notify the + application differs depending on the resource type and the Look and Feel (these differences are + captured in the LookandFeelManager sub-classes for each Look and Feel). It can also + vary depending on whether the value is an application defined resource or a Java defined resource.

      Updating Colors

      -

      Updating Colors is the easiest of all the resource. First GColor.refreshAll() is called, - which causes every GColor to refresh its delegate. Next, repaint() is called on all the top - level java windows in the application. Also, since color values in the UIDefaults are actually +

      Updating Colors is the easiest of all the resource types. First + GColor.refreshAll() is called, + which causes every GColor to refresh its internal delegate Color. + This is the purpose of using the GColor class, to introduce a level of indirection + that allows us to change runtime behavior without having to recompile. + Next, repaint() is called on all the top-level Java windows in the application. + Also, since color values in the UIDefaults are actually replaced with GColor objects, this technique works for both application defined resources and - java defined resources.

      - -

      Updating Fonts

      - -

      Updating Fonts is a bit more involved. First, if the changed font is java defined, the - UIDefaults for that font Id (and any that derive from it) are updated. Next, all the components - that have a registeredFontId are updated, and finally the updateComponentTreeUI method is - called on all windows in the application.

      + Java defined resources.

      Updating Icons

      -

      Updating Icons is a mixed bag. If the Icon is application defined, GIcon.refreshAll() is - called which causes every GIcon to refresh its delegate and then call repaint on all the - windows. If the icon is java defined, then the UIDefaults has to be updated and the - updateComponentTreeUI method on all windows is called.

      +

      Updating icons is a mixed bag. If the icon is application defined, + GIcon.refreshAll() is + called which causes every GIcon to refresh its internal delegate icon and then + call repaint() on all the + windows. If the icon is Java defined, then the UIDefaults has to be updated and the + updateComponentTreeUI() method on all windows is called.

      + +

      Updating Fonts

      + +

      Updating Fonts is a bit more involved than updating colors and icons, due to the inability + to use the indirection model when working with fonts. First, if the changed font is Java + defined, the UIDefaults for that font ID (and any that derive from it) are updated. + Next, all the components that have called Gui.registeredFont() are updated. (The + registration system for fonts is what allows us to notify components of updates, since fonts + cannot use the indirection model.) + Finally, the updateComponentTreeUI() method is + called on all windows in the application.

      + +

      Creating/Editing/Saving Themes

      -

      New themes can be created and saved to files in the theme directory in the users ghidra - application directory. When the application is started, this directory is scanned and any - .theme files are loaded and available to be selected as the active theme. The Gui class has - methods for setting the value of a color, font, or icon for a given resource id. If any values +

      New themes can be created and saved to files in the theme directory in the user's + application directory (<home>/.ghidra/.ghidra-<version>/themes). + When the application is started, this directory is scanned and any + *.theme files are loaded and available to be selected as the active theme. + The Gui class has + methods for setting the value of a color, font, or icon for a given resource ID. If any values are currently different from the active theme, the theme can be saved. If the active theme is a - built-in theme, then the only choice is to save the theme with a new theme name. Saving the - theme will create a new xxx.theme file where xxx is the name of the theme. Otherwise, the + built-in theme, then the only choice is to save using a new theme name. Saving the + theme will create a new "xyz.theme" file where "xyz" is the name of the theme. Otherwise, the existing theme file can be overwritten or a new theme name can be supplied to save to a new file.

      External Icons

      -

      When settings icons for an icon resource id, the user has the option of using a icon that - exists on the application classpath or using any supported icon file (.png or .gif) If the user - chooses to use an icon file, then that icon will be copied into an images directory in their - application directory (.ghidra). These icons are considered external in that if the theme were - given to another user, you would also need to give them the icon files.

      +

      When setting icons for an icon resource ID, the user has the option of using an icon that + exists in the application (on the classpath) or using any supported icon file (.png or .gif) on + the filesystem. If the user + chooses to use a non-application icon file, then that icon will be copied into an images + directory in their application directory. These icons are considered external in that if the + theme were given to another user, you would also need to give them these icon files, as they + will not exist in other application installations.

      Importing/Exporting Themes

      Themes can be shared with other users by exporting and importing themes. When exporting a theme that doesn't use any external icons (icons not on the classpath), the theme can be - exported to a .theme file of the users choosing. If the theme does contain external icons, the - user has the option to save the theme as a .zip file which would contain both the .theme file + exported to a .theme file of the user's choosing. If the theme does contain + external icons, the + user has the option to save the theme as a .zip file, which would contain both the .theme file and all the external icon files.

      -

      LookAndFeel Notes

      +

      Look and Feel Notes

      -

      Getting the theming feature to work on all the various Java LookAndFeels is a - challenge.  Java created the concept of UiDefaults, which is a mapping of property names - to values. The implication is that users can change default values by setting values on the - UIDefaults. Unfortunately, not all LookAndFeels support this concept. Nimbus and GTK+, in - particular are problematic. Nimbus sort of honors values in UIDefaults, but only if they are - installed before Nimbus is loaded. So for out theming purposes, we had to extend the Nimbus - LookAndFeel in order to override the getDefaults() method (this is the method where - LookAndFeels populate the UiDefaults) so that we can install any overridden values from the - selected theme. Also, every time a Java defined property changes, we have to re-install the - Nimbus LookAndFeel because once it is installed, it no longer pays attention to changes to the - UIDefaults.  The GTK+ LookAndFeel is even more problematic. It gets many of its properties +

      Getting the theming feature to work on all the various Java Look and Feels is a + challenge. Java created the concept of UIDefaults, which is a mapping of property + names + to values. The implication is that users can change Look and Feel settings by changing values + in the UIDefaults. Unfortunately, not all Look and Feels support this concept. + Nimbus and GTK+, in particular are problematic. Nimbus somewhat honors values in + UIDefaults, but only if those values are + installed before Nimbus is loaded. So for our theming purposes, we had to extend the Nimbus + Look and Feel in order to override the getDefaults() method (this is the method + where Look and Feels populate the UIDefaults) so that we can install any overridden + values from the selected theme. Also, since Nimbus does not respect changes to these values after + they have been created, every time a Java defined property changes, we have to re-install the + Nimbus Look and Feel. The GTK+ Look and Feel is even more problematic. It gets many of its + properties from native libraries and there doesn't appear to be anyway of changing them. Therefore, themes - based on GTK+ doesn't allow for changing java defined values.  To compensate for the - differences among LookAndFeels, we created a LookAndFeelManager base class with sub-classes for - each LookAndFeel that addresses these differences.

      + based on GTK+ doesn't allow for changing Java defined values. To compensate for the + differences among Look and Feels, we created a LookandFeelManager base class with + sub-classes for each Look and Feel.

      + + + + +

      Provided by: Theme Manager

      Related Topics


      diff --git a/Ghidra/Framework/Docking/src/main/help/help/topics/Theming/ThemingOverview.html b/Ghidra/Framework/Docking/src/main/help/help/topics/Theming/ThemingOverview.html index d0b5b8e364..d446609d85 100644 --- a/Ghidra/Framework/Docking/src/main/help/help/topics/Theming/ThemingOverview.html +++ b/Ghidra/Framework/Docking/src/main/help/help/topics/Theming/ThemingOverview.html @@ -5,114 +5,133 @@ - Theming Overivew + General Overivew -

      Ghidra Theming Overview

      +

      Theming Overview

      + +

      This document describes Ghidra's support for using and managing UI themes. +

      Goal

      -

      The goal was to add a theming infrastructure/feature to Ghidra that would allow - users/developers to completely configure the colors, fonts, and icons used within Ghidra. There - are two main reasons for creating this feature. The first reason is to create the much - requested "Dark Theme". Many people find Ghidra's current color scheme to be hard on the eyes - and would greatly appreciate a color scheme that is not so bright.  The second reason is - for accessibility purposes. For example, the themeing feature would allow for the creating of a - high contrast color scheme, or a color scheme that helps mitigate color blindness or a theme - that uses larger fonts.

      -   +

      The primary goal of theming in Ghidra is to allow users to customize the appearance of the UI + and to share that customization with the community. We added infrastructure to Ghidra that + allows users/developers to completely configure the colors, fonts, and icons used within + the application. There are two main motivations for creating this feature. The first is to + provide the much requested "Dark Theme". Many users find Ghidra's current color scheme to be + hard on the eyes and have requested a dark color scheme. The + second motivation for creating this feature is for accessibility purposes. For example, the + theming feature allows the user to create a theme that uses high contrast colors and larger + fonts.

      +

      Background

      -

      Ghidra previously used hundreds of hard coded colors, fonts, and icons.  They are +

      Before theming, Ghidra used thousands of hard-coded colors, fonts, and icons. They were defined throughout the code in a somewhat haphazard fashion. Many features use colors to convey - similar concepts, but no effort was even made to use similar colors for those similar concepts. - Also, these colors were generally chosen to work with one of the common "light" java look and - feels. They often look terrible when used in conjunction with other LookAndFeels, especially - dark ones.

      + similar concepts, but no effort was made to use similar colors for similar concepts. + Further, these colors were generally chosen to work with one of the common default Java Look and + Feels. (A Java Look and Feel is a grouping of UI settings that define the appearance of the + application.) Those original colors often looked terrible when used in conjunction with other + Look and Feels, especially dark ones.

      -

      Ghidra does allow some customization of the current colors using "options", but this falls - short for several reasons. One problem is that not all colors or fonts are changeable via the - options. Another problem is that the options are tool based and you have to make the same - customization for each tool. A third problem is that options are unrelated to the LookAndFeel - option. In other words you can't have different option choices depending on the current - LookAndFeel.

      +

      Ghidra did allow some customization of the current colors using the Ghidra Options API, but + this was inadequate for several reasons. One issue with this approach is that not all colors and + fonts are changeable via the options. Another issue is that the options are tool-based and you + have to make the same customization for each tool. A third problem is that options are unrelated + to the Look and Feel; you couldn't have different option choices depending on the current Look + and Feel.

      -

      Also, all of Ghidra's icons are hard coded and many are not suitable to use in a dark theme. - Overall, the hard coding of colors, fonts, and icons and the limitation of options makes - creating a good dark theme virtually impossible. So to address these issues, a new theming +

      As mentioned, all of Ghidra's icons were hard-coded, with many not suitable for use in a dark + theme. Overall, the hard-coding of colors, fonts, and icons and the limitation of options made + creating a good dark theme virtually impossible. To address these issues, a new theming infrastructure was created.

      General Concepts and Approach

      -

      To achieve a theming capability in Ghidra, we had to implement the following concepts. - First, provide a level of indirection when using colors, fonts, or icons in code. Second, - introduce the concept of a theme which maps the indirect colors. font, and icons to actual - values in the context of a java LookAndFeel. Third, provide access to (and the ability to - change), the colors, fonts, and icons supplied by the Java LookAndFeel. And finally, provide - the GUIs needed to allow users to switch between, create, edit, save, import, and export - themes.

      - +

      To achieve a theming capability in Ghidra, we had to make the following changes:

      +
        +
      1. Replace hard-coded values with a level of indirection for colors, fonts, and icons + using property names/IDs +
      2. +
      3. Create the concept of a theme that allows for the the property values to change + as a group and along with the current Look and Feel in use +
      4. +
      5. Create an API that allows for the introduction of system-level properties that can + be mapped to specific Look and Feel values in order to create reusable groups of properties +
      6. +
      7. Provide methods for changing the property values, along with the ability to create, + edit, save, export and import themes +
      8. +
      + +

      Indirection

      -

      The basic idea for indirection is to never directly use a hard coded color, font, or icon - when developing a feature in the application. Instead, these properties will be indirectly +

      The goal of using indirection is to remove all uses of hard-coded colors, fonts, and icons + when developing a feature in the application. Instead, these objects will be indirectly referred to by an identifying string such as "color.bg.mywidget", where the string will follow a known convention that helps indicate its use. Default values for these identifying strings will be specified in data files that exist in the module where the code that defined - id is located. Also, the values associated with these ids can be either a concrete value such - as an actual color, font, or icon, or the value can be just an identifying string to - different property. This allows users to change individual values or entire groups of values - with one change.

      + the ID is located. The values associated with these IDs can be either a concrete value such + as an actual color, font, or icon, or the value can be defined using a different property name, + allowing for properties to be defined by other properties. This allows users to change + individual values or entire groups of values with one edit.

      Theme

      A theme is simply the object that specifies all the values for colors, fonts, and icons - used in the application as well as the LookAndFeel. The idea is that there will be a set of - themes to choose from and by simply switching the theme, the LookAndFeel and all the colors, - fonts, and icons can be switched out at one time. The set of themes to choose from are a mix - of built-in themes and saved custom themes. There is one built-in theme for each supported - LookAndFeel, which will use the values from the LookAndFeel as well as all the default values - for the defined property ids. Users will be able to create custom themes where they can - basically change any defined color, font, or icon, including those supplied by the associated - LookAndFeel for that theme.

      + used in the application, as well as the Look and Feel. This allows there to be a set of + themes to choose from and by simply switching the theme, the system will then update the Look + and Feel along with the colors, fonts, and icons, all with one action. The set of themes to + choose from is a mix of built-in themes and saved custom themes. There is one built-in theme + for each supported Look and Feel. The chosen theme will use the UI values defied by the Look + and Feel, as well as all the values for the defined property IDs. Users are able to + create custom themes to change any color, font, or icon defined by the application, along with + UI values supplied by the associated Look and Feel.

      Look and Feel Values

      -

      The Java LookAndFeel is specified by the active theme. The Java LookAndFeel objects also +

      The Java Look and Feel is specified by the active theme. These Look and Feel objects define colors, fonts, and icons indirectly using identifying strings such as "Button.font" - and "Menu.background". These values determine the default values used by all GUI elements - unless overridden by developers in code when they create the components. Uses have the - ability to change these values in the same way as values defined by Ghidra code. This will - allow users to generate themes that completely change the look of the GUI with out the - developers having to explicitly set a color, font and icon on every component as they get - created in code.  Another concept used by Java LookAndFeels is that many of the - individual components share the same colors and those shared colors are defined using a group - key such as "control", "text", or "menu". The idea is that by changing a group color, all - components that share that group color are changed together. Or an individual components - color can be changed by changing its specific key such as "Menu.background".

      + and "Menu.background". The Look and Feel mappings determine the default values used by all + GUI elements + unless overridden by developers when they create the components. With theming, users have the + ability to change these Java Look and Feel defined values in the same way as theme properties + defined created by application code. Another concept used by Java Look and Feels is that of + shared UI patterns. + Look and Feels typically share many of the same colors and those shared colors are defined + by the Look and Feel using a group name/key such as "control", "text", or "menu". This allows + for changes to be made at the group level or for the individual property. The theme + framework captures this Java grouping information when creating a theme that for a given + Look and Feel. +

      User Interaction

      Users will be able create, edit, delete, import, export, and of course switch the - application's active theme. The GUI theme editor allows users to do all of these actions. + application's active theme. The GUI theme editor allows users to perform all of these actions. Using the active theme as a starting point, users will be able to change any color, font, or - icon defined either by the LookAndFeel or the application. One or more of these changes can + icon defined either by the Look and Feel or the application. One or more of these changes can be saved as a new theme and stored in a file in their application directory. Themes can be - shared with other users by exporting and import themes.

      + shared with other users by exporting and importing themes.

      + +

      Provided by: Theme Manager

      +

      Related Topics


      diff --git a/Ghidra/Framework/Docking/src/main/help/help/topics/Theming/ThemingUserDocs.html b/Ghidra/Framework/Docking/src/main/help/help/topics/Theming/ThemingUserDocs.html index 3da437d6ae..eb9ff2d102 100644 --- a/Ghidra/Framework/Docking/src/main/help/help/topics/Theming/ThemingUserDocs.html +++ b/Ghidra/Framework/Docking/src/main/help/help/topics/Theming/ThemingUserDocs.html @@ -10,20 +10,21 @@ -

      Theming User Help

      +

      Editing Themes

      Description

      The Theming feature allows users to customize the colors, fonts, and icons used throughout - the application. The active theme determines the Java LookAndFeel, whether the theme should use + the application. The active theme determines the Java Look and Feel, whether the theme should use light or dark defaults, and any custom colors, fonts, and icons that override the default - values. Users can can easily switch between any of the built-in themes or any saved themes from - their home application directory

      + values. Users can can easily switch between any of the built-in themes or any saved themes found + in their home application directory

      Users can also edit and create their own themes using the Theme Editor. Custom themes are - stored in the users <application dir>/themes. These are simple text files that can + stored in the user's <home>/.ghidra/.ghidra-<version>/themes directory. + These theme files are simple text files that can easily be modified using any text editor. Also, users can share themes by exporting them to a - file that can be given to other users who can them import them into their own system.

      + file that can be given to other users who can them import them into their application.

      Theme Dialog

      @@ -32,26 +33,33 @@


       

      -

      The Theme Dialog consists of a theme comboBox and a tabbed set of tables that display the +

      The Theme Dialog consists of a theme drop-down and a tabbed set of tables that display the values for every color property, font property, and icon property defined by either the Java - LookAndFeel or the Ghidra application. All Ghidra defined properties start with "color.", - "font.", or "icon." depending on whether the the property is a color, font, or icon - respectively. All other properties are defined by the Java LookAndFeel.

      + Look and Feel or the application. All application defined properties start with "color.", + "font.", or "icon.", depending on whether the the property is a color, font, or icon + respectively. All other properties are defined by the Java Look and Feel. This naming + convention is not enforced, thus it is possible that 3rd-party Extensions may introduce + property names that do not match this description. See + the Developer Documentation for more details on the property ID + format and naming conventions. +

      -

      Each table entry shows the property id string and then the current value, the theme value, - and the default color. Most often, the three values are equal. If the theme value is different +

      Each table entry shows the property ID string, the current value, the theme value, + and the default value. Most often, the three values are equal. If the theme value is different from the default value, that means that the active theme has overridden the default value for that property. If the current value is different from the theme value, that means the user has changed that value, but not yet saved the changes back to the theme.

      -

      Individual values can be changed by double clicking the Id or Current Color column. This - will bring up an appropriate editor for changing the value. When editing a value, the change +

      Individual values can be changed by double-clicking the value in the ID or Current Value + column. This will bring up an appropriate editor for changing the value. When editing a value, + the change takes place immediately in the application so you can see the effect. When you leave the specific property editor, you have the choice of keeping the change or canceling and having it revert back to its previous value.

      -

      If any values have been changed, the "Save" button will become enabled, allowing you to save - any changes you have made. (Hitting "Dismiss" will also give the the option to save.) If the +

      If any values have been changed, the Save button will become enabled, allowing you to save + any changes you have made. (Pressing the Dismiss button will also give the the option to + save.) When saving, if the current theme is a built-in theme, you will first have to supply a new theme name. If the current theme is a not a built-in theme, you will have the option to overwrite the existing theme or supplying a new name to save it as a new theme.

      @@ -65,8 +73,8 @@  

      Any change you make in the editor is applied to the application immediately. If you press - the OK button, the change will stay. If you press the Cancel button, the color will revert - back to the original color.

      + the OK button, the change will stay. If you press the Cancel button, the color + will revert back to the original color.

      Font Editor

      @@ -76,8 +84,8 @@  

      Any change you make in the editor is applied to the application immediately. If you press - the OK button, the change will stay. If you press the Cancel button, the font will revert - back to the original font.

      + the OK button, the change will stay. If you press the Cancel button, the font + will revert back to the original font.

      Icon Editor

      @@ -86,12 +94,12 @@


       

      -

      The Edit Icon dialog has a drop down text field where you can find any existing icon on - the classpath. If you want to choose an Icon from the file system, press the "..." button and - a FileChooser will appear, allowing you to pick an icon file from anywhere in the filesystem. +

      The Edit Icon dialog has a drop-down text field where you can find any existing icon on + the classpath. If you want to choose an Icon from the file system, press the ... button + and a File Chooser will appear, allowing you to pick an icon file from anywhere on the filesystem. Any change you make in the editor is applied to the application immediately. If you press the - OK button, the change will stay. If you press the Cancel button, the icon will revert back to - the original icon.

      + OK button, the change will stay. If you press the Cancel button, the icon will + revert back to the original icon.

    Theme Actions

    @@ -100,30 +108,32 @@

    Switching Themes

    To change the current theme, first bring up the Theme Dialog. - The Theme Dialog can be invoked from the Ghidra Project Window menu using the - EditTheme menu. Then select - a theme from the combo box at the top of the Theme Editor dialog.

    + The Theme Dialog can be invoked from the main application menu using the + EditTheme menu. From the Theme + Dialog you can select a theme from the combo box at the top.

    Modifying Theme Values

    -

    All the colors, fonts, and icons that have been externalized can be modified using the Theme Dialog. The Theme Dialog can be invoked from the - Ghidra Project Window using the +

    All the colors, fonts, and icons that have been registered with the theme API can be + modified using the Theme Dialog. The Theme Dialog can be invoked + from the main application menu using the EditTheme menu. Choose the - tab for the appropriate type and double-click on the id column or current value column of the + tab for the appropriate type and double-click on the ID column or Current Value column of the item you want to change. An editor for that type will appear.

    Reseting Theme Values

    -

    To reset an individual value back to its original theme value, invoke the To reset an individual value back to its original theme value, from the + main application menu invoke the Theme Dialog using the Edit Theme menu. Switch to the appropriate tab for either colors, fonts, or - icons. Right-click on the row of the value you want to reset and choose the Restore - Value menu item.

    + border="0">Theme menu. Choose the + tab for the appropriate type and right-click on the row of the value you want to reset, then + choose the Restore Value menu item.

    Reseting All Theme Values

    -

    To reset all values back to the original values established by the current theme, invoked +

    To reset all values back to the original values established by the current theme, from the + main application menu invoke the EditTheme Actions Reset Theme Values menu.

    @@ -132,12 +142,13 @@

    After making changes to one or more theme values, the Theme Dialog's Save button will be enabled. Pressing the Save button will give the user the option of creating a new theme or overwriting the current them (if the current - theme is not a built-in theme). Also, users will have the options of saving a theme if they + theme is not a built-in theme). Also, users will have the option of saving a theme if they dismiss the Theme Dialog while there are changes to one or more theme values.

    Deleting Themes

    -

    To delete a custom saved theme, invoked the EditTo delete a custom saved theme, from the main application menu invoke the + EditTheme Actions Delete Theme... menu. This will bring up a dialog with a list of themes that can be deleted. Select the theme to delete and press the Ok @@ -145,16 +156,18 @@

    Exporting Themes>

    -

    To export a theme so that it can be shared with others, invoke the Edit To export a theme so that it can be shared with others, from the + main application menu invoke the Edit Theme Actions Export Theme... menu. You will first be asked if you want to export as a regular theme file or as a Zip file. The Zip file option is useful if - the current theme has icon values that are not included with standard Ghidra. In that case, - the Zip file will include those non standard icon files.

    + the current theme has icon values that are not included with standard application. In that case, + the Zip file will include those non-standard icon files.

    Importing Themes

    -

    To import a theme, invoke the Edit To import a theme, from the main application menu + invoke the Edit Theme Actions Import Theme... menu. A file chooser dialog will appear allowing the user to choose a theme file to import. The selected file can be either a standard theme file or a Zip file containing the @@ -162,7 +175,7 @@

    Reloading Default Values

    -

    XThis action causes Ghidra to reload all theme default values. It is really only useful +

    This action causes Ghidra to reload all theme default values. It is really only useful for developers who are actively making changes to theme.properties files. To activate this action, press the refresh button in the top right corner of the Theme Dialog.

    @@ -170,23 +183,24 @@

    Theme Property Names

    -

    Theme Property Names (also referred to as ids or keys) that are defined by Ghidra use a - common format to help make sorting and viewing properties more intuitive as to their use. See - the Developer Documentation for more details on the property id +

    Theme Property Names (also referred to as IDs or keys) that are defined by the application + use a common format to help make sorting and viewing properties more intuitive as to their use. See + the Developer Documentation for more details on the property ID format and naming conventions.

    Theme Files

    Theme Files are used to store saved custom themes. They are simple text files and are - stored in the user's home application directory. The first three properties are always the - theme name, the look and feel name, and whether the theme uses standard defaults or dark - defaults. Then there is just a list of overridden property "name = value" lines.So the format + stored in the user's home application directory under + <home>/.ghidra/.ghidra-<version>/themes. The first three properties are always the + theme name, the Look and Feel name, and whether the theme uses standard defaults or dark + defaults. Finally, there is a list of overridden property "name = value" lines. The format is:

             name = [theme name]
    -        lookAndFeel = [lookAndFeel name]
    +        Look and Feel = [Look and Feel name]
             useDarkDefaults = [true or false]
             
             [theme id 1]= [color, icon, or font value]
    @@ -201,7 +215,7 @@
             

    Example:

             name = BigFontTheme
    -        lookAndFeel = Nimbus
    +        Look and Feel = Nimbus
             useDarkDefaults = false
     		
             color.bg = Black
    @@ -216,8 +230,8 @@
     
           

    Each property line is expected to begin with either "color.", "font.", or "icon." Since java defined properties don't start with these prefixes, they will have "[color]", "[font]", - or "[icon]" prepended to their property name. These are just there for the purposes of - parsing this file. When the properties are used in Ghidra, those bracketed prefixes are + or "[icon]" prepended to their property name. These brackets are only used to aid in + parsing this file. When the properties are used in Ghidra, the bracketed prefixes are removed.

    Also, note that the values of these properties can reference other property names. If the @@ -225,16 +239,21 @@ bracketed prefix if the property name doesn't start with "color.", "font.", or "icon."

    Specifying Theme Property Values

    +

    Specifying property values varies depending on whether it is a color, font, or icon. Fonts and icons also support specifying modifiers. For a complete description of how to specify these values, see the Developer Documentation.

    + + +

    Provided by: Theme Manager

    +

    Related Topics


    diff --git a/Ghidra/Framework/Generic/src/main/java/resources/MultiIconBuilder.java b/Ghidra/Framework/Generic/src/main/java/resources/MultiIconBuilder.java index be6d0ff5e3..7ff95d565d 100644 --- a/Ghidra/Framework/Generic/src/main/java/resources/MultiIconBuilder.java +++ b/Ghidra/Framework/Generic/src/main/java/resources/MultiIconBuilder.java @@ -127,6 +127,16 @@ public class MultiIconBuilder { return addIcon(icon, w, h, QUADRANT.LL); } + // TODO + public MultiIconBuilder addCenteredIcon(Icon icon) { + int x = (multiIcon.getIconWidth() - icon.getIconWidth()) / 2; + int y = (multiIcon.getIconHeight() - icon.getIconHeight()) / 2; + + TranslateIcon txIcon = new TranslateIcon(icon, x, y); + multiIcon.addIcon(txIcon); + return this; + } + /** * Add text overlaid on the base icon, aligned to the specified quadrant. * diff --git a/Ghidra/Framework/Help/src/main/java/help/CustomFavoritesView.java b/Ghidra/Framework/Help/src/main/java/help/CustomFavoritesView.java index 29f2cb8cf6..6914f834ad 100644 --- a/Ghidra/Framework/Help/src/main/java/help/CustomFavoritesView.java +++ b/Ghidra/Framework/Help/src/main/java/help/CustomFavoritesView.java @@ -16,8 +16,7 @@ package help; import java.awt.Component; -import java.awt.event.KeyAdapter; -import java.awt.event.KeyEvent; +import java.awt.event.*; import java.beans.PropertyChangeListener; import java.net.MalformedURLException; import java.net.URL; @@ -30,8 +29,7 @@ import javax.help.event.HelpModelEvent; import javax.help.plaf.HelpNavigatorUI; import javax.help.plaf.basic.BasicFavoritesCellRenderer; import javax.help.plaf.basic.BasicFavoritesNavigatorUI; -import javax.swing.JComponent; -import javax.swing.JTree; +import javax.swing.*; import javax.swing.tree.DefaultMutableTreeNode; import ghidra.util.Msg; @@ -70,6 +68,28 @@ public class CustomFavoritesView extends FavoritesView { public void setUI(HelpNavigatorUI ui) { super.setUI(new CustomFavoritesNavigatorUI(this)); } + + private Action superGetAddAction() { + return super.getAddAction(); + } + + @Override + public Action getAddAction() { + + // + // Switching themes triggers a UI update. Internally, the Java Help API is not + // correctly updating listeners, which results in that API having a reference to an old + // UI. Using our own custom action to retrieve the currently active action prevents + // this issue, since we are always getting the active target for actionPerformed(). + // + return new AbstractAction() { + @Override + public void actionPerformed(ActionEvent e) { + Action currentAction = superGetAddAction(); + currentAction.actionPerformed(e); + } + }; + } } class CustomFavoritesNavigatorUI extends BasicFavoritesNavigatorUI { diff --git a/Ghidra/Framework/Help/src/main/java/help/GHelpBroker.java b/Ghidra/Framework/Help/src/main/java/help/GHelpBroker.java index 1923fa2d7d..29cafbbe0c 100644 --- a/Ghidra/Framework/Help/src/main/java/help/GHelpBroker.java +++ b/Ghidra/Framework/Help/src/main/java/help/GHelpBroker.java @@ -28,7 +28,8 @@ import generic.theme.GIcon; import ghidra.util.Msg; import ghidra.util.bean.GGlassPane; import resources.Icons; -import resources.ResourceManager; +import resources.MultiIconBuilder; +import resources.icons.EmptyIcon; // NOTE: for JH 2.0, this class has been rewritten to not // access the 'frame' and 'dialog' variable directly @@ -240,7 +241,11 @@ public class GHelpBroker extends DefaultHelpBroker { JToolBar toolbar = (JToolBar) component; toolbar.addSeparator(); - Icon zoomOutIcon = ResourceManager.getScaledIcon(ZOOM_OUT_ICON, 24, 24); + ImageIcon icon = new MultiIconBuilder(new EmptyIcon(24, 24)) + .addCenteredIcon(ZOOM_OUT_ICON) + .build(); + + Icon zoomOutIcon = icon; JButton zoomOutBtn = new JButton(zoomOutIcon); zoomOutBtn.setToolTipText("Zoom out"); zoomOutBtn.addActionListener(e -> { @@ -252,7 +257,10 @@ public class GHelpBroker extends DefaultHelpBroker { }); toolbar.add(zoomOutBtn); - Icon zoomInIcon = ResourceManager.getScaledIcon(ZOOM_IN_ICON, 24, 24); + icon = new MultiIconBuilder(new EmptyIcon(24, 24)) + .addCenteredIcon(ZOOM_IN_ICON) + .build(); + Icon zoomInIcon = icon; JButton zoomInBtn = new JButton(zoomInIcon); zoomInBtn.setToolTipText("Zoom in"); zoomInBtn.addActionListener(e -> { diff --git a/Ghidra/Framework/Help/src/main/java/help/GHelpHTMLEditorKit.java b/Ghidra/Framework/Help/src/main/java/help/GHelpHTMLEditorKit.java index 408489c265..937802cdf1 100644 --- a/Ghidra/Framework/Help/src/main/java/help/GHelpHTMLEditorKit.java +++ b/Ghidra/Framework/Help/src/main/java/help/GHelpHTMLEditorKit.java @@ -53,7 +53,8 @@ import utilities.util.FileUtilities; */ public class GHelpHTMLEditorKit extends HTMLEditorKit { - private static final String G_HELP_STYLE_SHEET = "help/shared/Frontpage.css"; + private static final String G_HELP_STYLE_SHEET = "Frontpage.css"; + private static final String DARK_G_HELP_STYLE_SHEET = "DarkStyle.css"; private static final Pattern EXTERNAL_URL_PATTERN = Pattern.compile("https?://.*"); @@ -320,12 +321,21 @@ public class GHelpHTMLEditorKit extends HTMLEditorKit { } private URL getGStyleSheetURL() { - URL GStyleSheetURL = ResourceManager.getResource(G_HELP_STYLE_SHEET); - if (GStyleSheetURL != null) { - return GStyleSheetURL; + + if (Gui.isDarkTheme()) { + return findStyleSheet(DARK_G_HELP_STYLE_SHEET); } - return findModuleFile("help/shared/FrontPage.css"); + return findStyleSheet(G_HELP_STYLE_SHEET); + } + + private URL findStyleSheet(String name) { + URL url = ResourceManager.getResource("help/shared/" + name); + if (url != null) { + return url; + } + + return findModuleFile("help/shared/" + name); } private URL findApplicationfile(String relativePath) { diff --git a/Ghidra/Framework/Project/src/main/java/ghidra/app/plugin/gui/ThemeManagerPlugin.java b/Ghidra/Framework/Project/src/main/java/ghidra/app/plugin/gui/ThemeManagerPlugin.java index 956d93c334..c3279f60cb 100644 --- a/Ghidra/Framework/Project/src/main/java/ghidra/app/plugin/gui/ThemeManagerPlugin.java +++ b/Ghidra/Framework/Project/src/main/java/ghidra/app/plugin/gui/ThemeManagerPlugin.java @@ -31,7 +31,7 @@ import ghidra.util.HelpLocation; status = PluginStatus.RELEASED, packageName = UtilityPluginPackage.NAME, category = PluginCategoryNames.SUPPORT, - shortDescription = "Manages themes for the Ghdira GUI", + shortDescription = "Manages themes for the Ghidra GUI", description = "Adds actions and options to manage Themes within Ghidra. " + "This plugin is available only in the Ghidra Project Window." )
    Tool - Options
    OptionOptionDescriptionDescription