1e41f4b71Sopenharmony_ci# Window Title Bar Customization Development (C++)
2e41f4b71Sopenharmony_ci## Overview
3e41f4b71Sopenharmony_ci### Introduction
4e41f4b71Sopenharmony_ciOpenHarmony has a default UX style for window titles. It also allows you to customize the window titles in your own style to accommodate diverse needs.
5e41f4b71Sopenharmony_ci### Constraints
6e41f4b71Sopenharmony_ciA folder for storing the custom title bar code must be placed in **foundation/arkui/ace_engine/frameworks/core/components_ng/pattern/container_modal**. The build configuration must be specified in **foundation/arkui/ace_engine/frameworks/core/components_ng/pattern/BUILD.gn**.
7e41f4b71Sopenharmony_ci## How to Develop
8e41f4b71Sopenharmony_ci
9e41f4b71Sopenharmony_ci### Development
10e41f4b71Sopenharmony_ciTo customize the title bar:
11e41f4b71Sopenharmony_ci1. In the **frameworks/core/components/common/layout/constants.h** file, define the values for **MaximizeMode** – a parameter that specifies the mode for maximizing or minimizing the window. In the following example, **MODE_AVOID_SYSTEM_BAR** and **MODE_FULL_FILL** are the values defined by vendor enhance.
12e41f4b71Sopenharmony_ci    ```cpp
13e41f4b71Sopenharmony_ci    enum class MaximizeMode : uint32_t {
14e41f4b71Sopenharmony_ci        MODE_AVOID_SYSTEM_BAR,
15e41f4b71Sopenharmony_ci        MODE_FULL_FILL,
16e41f4b71Sopenharmony_ci        MODE_RECOVER,
17e41f4b71Sopenharmony_ci    };
18e41f4b71Sopenharmony_ci    ```
19e41f4b71Sopenharmony_ci2. In the **foundation/arkui/ace_engine/frameworks/core/components_ng/pattern/container_modal/container_modal_view_factory.h** file, add code to **ContainerModalViewFactory::GetView** for creating a custom window title bar based on the **MaximizeMode** settings.
20e41f4b71Sopenharmony_ci    > **NOTE**
21e41f4b71Sopenharmony_ci    >
22e41f4b71Sopenharmony_ci> **ContainerModalViewFactory::GetView** is a factory method that creates a window title bar based on the **MaximizeMode** settings. It is expanded as follows:
23e41f4b71Sopenharmony_ci    
24e41f4b71Sopenharmony_ci    ```cpp
25e41f4b71Sopenharmony_ci        class ACE_EXPORT ContainerModalViewFactory {
26e41f4b71Sopenharmony_ci        public:
27e41f4b71Sopenharmony_ci            static RefPtr<FrameNode> GetView(RefPtr<FrameNode>& content, MaximizeMode mode) {
28e41f4b71Sopenharmony_ci                if (mode == MaximizeMode::MODE_AVOID_SYSTEM_BAR ||
29e41f4b71Sopenharmony_ci                    mode == MaximizeMode::MODE_FULL_FILL) {
30e41f4b71Sopenharmony_ci                    return ContainerModalViewEnhance::Create(content);
31e41f4b71Sopenharmony_ci                } else {
32e41f4b71Sopenharmony_ci                    return ContainerModalView::Create(content);
33e41f4b71Sopenharmony_ci                }
34e41f4b71Sopenharmony_ci             }
35e41f4b71Sopenharmony_ci        };
36e41f4b71Sopenharmony_ci    ```
37e41f4b71Sopenharmony_ciIn the preceding example from vendor enhance, a custom window title bar is created depending on the value of **MaximizeMode** (**MaximizeMode::MODE_AVOID_SYSTEM_BAR** or **MaximizeMode::MODE_FULL_FILL**).
38e41f4b71Sopenharmony_ci    
39e41f4b71Sopenharmony_ci3. Create a folder in the **foundation/arkui/ace_engine/frameworks/core/components_ng/pattern/container_modal** directory to store the custom title bar code.
40e41f4b71Sopenharmony_ci    > **NOTE**
41e41f4b71Sopenharmony_ci    >
42e41f4b71Sopenharmony_ci> The entry to a custom title bar has been completed in steps 1 and 2. This step is to write the specific implementation code.
43e41f4b71Sopenharmony_ci    >
44e41f4b71Sopenharmony_ci    > The structure of the **container_modal** folder is as follows:
45e41f4b71Sopenharmony_ci    ```shell
46e41f4b71Sopenharmony_ci    ├── container_modal_accessibility_property.cpp
47e41f4b71Sopenharmony_ci    ├── container_modal_accessibility_property.h
48e41f4b71Sopenharmony_ci    ├── container_modal_pattern.cpp
49e41f4b71Sopenharmony_ci    ├── container_modal_pattern.h
50e41f4b71Sopenharmony_ci    ├── container_modal_view.cpp
51e41f4b71Sopenharmony_ci    ├── container_modal_view_factory.h
52e41f4b71Sopenharmony_ci    ├── container_modal_view.h
53e41f4b71Sopenharmony_ci    └── enhance
54e41f4b71Sopenharmony_ci        ├── container_modal_pattern_enhance.cpp
55e41f4b71Sopenharmony_ci        ├── container_modal_pattern_enhance.h
56e41f4b71Sopenharmony_ci        ├── container_modal_view_enhance.cpp
57e41f4b71Sopenharmony_ci        └── container_modal_view_enhance.h
58e41f4b71Sopenharmony_ci```
59e41f4b71Sopenharmony_ci    The **container_modal_*** file under **container_modal** contains the code related to the default title bar view. You can add your code file in the created folder for the custom title bar. In the preceding example, the **container_modal_*** file under **enhance** is the code file by vendor enhance.
60e41f4b71Sopenharmony_ci    
61e41f4b71Sopenharmony_ci4. Complete the build configuration for .cpp files in **foundation/arkui/ace_engine/frameworks/core/components_ng/pattern/BUILD.gn**.
62e41f4b71Sopenharmony_ci
63e41f4b71Sopenharmony_ciWhen the development is complete, you can debug and verify the custom title bar.
64e41f4b71Sopenharmony_ci### Debugging and Verification
65e41f4b71Sopenharmony_ciBefore getting started, prepare the following files in the same directory:
66e41f4b71Sopenharmony_ci- **open_maximize.bat**, the content of which is as follows:
67e41f4b71Sopenharmony_ci    ```shell
68e41f4b71Sopenharmony_ci    hdc shell mount -o rw,remount /sys_prod
69e41f4b71Sopenharmony_ci    hdc file send window_manager_config_open.xml sys_prod/etc/window/resources/window_manager_config.xml
70e41f4b71Sopenharmony_ci    hdc shell reboot
71e41f4b71Sopenharmony_ci    ```
72e41f4b71Sopenharmony_ci- **window_manager_config_open.xml**, the content of which is as follows:
73e41f4b71Sopenharmony_ci    ```html
74e41f4b71Sopenharmony_ci    <?xml version="1.0" encoding="utf-8"?>
75e41f4b71Sopenharmony_ci        <Configs>
76e41f4b71Sopenharmony_ci          <decor enable="true"/>
77e41f4b71Sopenharmony_ci          <modeChangeHotZones>50 50 50</modeChangeHotZones>
78e41f4b71Sopenharmony_ci          <maxFloatingWidth>1706</maxFloatingWidth>
79e41f4b71Sopenharmony_ci          <maxFloatingHeight>1000</maxFloatingHeight>
80e41f4b71Sopenharmony_ci          <minFloatingWidth>398</minFloatingWidth>
81e41f4b71Sopenharmony_ci          <minFloatingHeight>528</minFloatingHeight>
82e41f4b71Sopenharmony_ci          <floatingBottomPosY>0</floatingBottomPosY>
83e41f4b71Sopenharmony_ci          <defaultFloatingWindow>82 121 1068 706</defaultFloatingWindow>
84e41f4b71Sopenharmony_ci          <defaultWindowMode>102</defaultWindowMode>
85e41f4b71Sopenharmony_ci          <defaultMaximizeMode>0</defaultMaximizeMode>
86e41f4b71Sopenharmony_ci          <dragFrameGravity>5</dragFrameGravity>
87e41f4b71Sopenharmony_ci          <maxUniRenderAppWindowNumber>10</maxUniRenderAppWindowNumber>
88e41f4b71Sopenharmony_ci          <maxFloatingWindowSize>2880</maxFloatingWindowSize>
89e41f4b71Sopenharmony_ci          <splitRatios>0.5 0.33 0.67</splitRatios>
90e41f4b71Sopenharmony_ci          <keyboardAnimation>
91e41f4b71Sopenharmony_ci            <timing>
92e41f4b71Sopenharmony_ci              <durationIn>500</durationIn>
93e41f4b71Sopenharmony_ci              <durationOut>150</durationOut>
94e41f4b71Sopenharmony_ci              <curve name="cubic">0.2 0.0 0.2 1.0</curve>
95e41f4b71Sopenharmony_ci            </timing>
96e41f4b71Sopenharmony_ci          </keyboardAnimation>
97e41f4b71Sopenharmony_ci          <windowAnimation>
98e41f4b71Sopenharmony_ci            <timing>
99e41f4b71Sopenharmony_ci              <duration>200</duration>
100e41f4b71Sopenharmony_ci              <curve name="cubic">0.0 0.0 0.2 1.0</curve>
101e41f4b71Sopenharmony_ci            </timing>
102e41f4b71Sopenharmony_ci            <scale>0.9 0.9</scale>
103e41f4b71Sopenharmony_ci            <rotation>0 0 1 0</rotation>
104e41f4b71Sopenharmony_ci            <translate>0 0</translate>
105e41f4b71Sopenharmony_ci            <opacity>0</opacity>
106e41f4b71Sopenharmony_ci          </windowAnimation>
107e41f4b71Sopenharmony_ci          <windowEffect>
108e41f4b71Sopenharmony_ci            <appWindows>
109e41f4b71Sopenharmony_ci              <cornerRadius>
110e41f4b71Sopenharmony_ci                <fullScreen>off</fullScreen>
111e41f4b71Sopenharmony_ci                <split>off</split>
112e41f4b71Sopenharmony_ci                <float>defaultCornerRadiusL</float>
113e41f4b71Sopenharmony_ci              </cornerRadius>
114e41f4b71Sopenharmony_ci              <shadow>
115e41f4b71Sopenharmony_ci                <focused>
116e41f4b71Sopenharmony_ci                  <elevation>0</elevation>
117e41f4b71Sopenharmony_ci                  <color>#000000</color>
118e41f4b71Sopenharmony_ci                  <offsetX>0</offsetX>
119e41f4b71Sopenharmony_ci                  <offsetY>15</offsetY>
120e41f4b71Sopenharmony_ci                  <alpha>0.4</alpha>
121e41f4b71Sopenharmony_ci                  <radius>34</radius>
122e41f4b71Sopenharmony_ci                </focused>
123e41f4b71Sopenharmony_ci                <unfocused>
124e41f4b71Sopenharmony_ci                  <elevation>0</elevation>
125e41f4b71Sopenharmony_ci                  <color>#000000</color>
126e41f4b71Sopenharmony_ci                  <offsetX>0</offsetX>
127e41f4b71Sopenharmony_ci                  <offsetY>15</offsetY>
128e41f4b71Sopenharmony_ci                  <alpha>0.2</alpha>
129e41f4b71Sopenharmony_ci                  <radius>17</radius>
130e41f4b71Sopenharmony_ci                </unfocused>
131e41f4b71Sopenharmony_ci              </shadow>
132e41f4b71Sopenharmony_ci            </appWindows>
133e41f4b71Sopenharmony_ci          </windowEffect>
134e41f4b71Sopenharmony_ci        </Configs>
135e41f4b71Sopenharmony_ci    ```
136e41f4b71Sopenharmony_ci    > **NOTE**
137e41f4b71Sopenharmony_ci    >
138e41f4b71Sopenharmony_ci    > **window_manager_config_open.xml** contains configuration items. Among them, change the value of **defaultMaximizeMode** to one of the values you define for **MaximizeMode**. The value is the one obtained by **MaximizeMode maximizeMode = GetWindowManager()->GetWindowMaximizeMode()**. The system loads the title bar according to this value.
139e41f4b71Sopenharmony_ci
140e41f4b71Sopenharmony_ciNow with the prepared files, debug and verify your title bar as follows:
141e41f4b71Sopenharmony_ci1. Burn the image that contains the title bar code to the target device.
142e41f4b71Sopenharmony_ci2. Run the **open_maximize.bat** script.
143e41f4b71Sopenharmony_ci3. Run the demo to examine the effect.
144