summaryrefslogtreecommitdiff
path: root/fluid/documentation/src/page_mergeback.dox
blob: 7b3bc1a2246bc4ab8d44ec478baeb75ec09413dc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/**

 \page page_mergeback Fluid Mergeback

 \tableofcontents

 # Introduction to Mergeback #

 Fluid has introduced an experimental feature called **MergeBack** in version 1.5.
 This feature allows developers to edit the C++ source files generated by Fluid and
 then merge those changes back into the corresponding Fluid project file (.fl). This
 can streamline the development process by reducing the need to switch between Fluid
 and your code editor for minor adjustments.

 \note MergeBack is currently experimental and may not handle all
 scenarios perfectly. It's advisable to back up your project files before using this
 feature to prevent potential data loss.

 <H2>Enabling MergeBack</H2>

 1. **Open Your Project in Fluid:**
   - Launch Fluid and load your existing `.fl` project file.

 2. **Enable MergeBack:**
   - Navigate to the **Settings Panel**.
   - In the **Project Settings**, locate and enable the **MergeBack** option.

 Once enabled, Fluid assigns a unique ID to each node in your project.
 Additionally, user-editable code sections in the generated source files will
 be marked with special divider lines, indicating areas that can be edited
 and later merged back.

 <H2>Understanding the Code Markers:</H2>

 In the generated `.cxx` files, editable sections are demarcated as follows:

 ```cpp
 static void cb_script_panel(Fl_Double_Window*, void*) {
    //fl ▼ ---------------------- callback ~~----~~~~=-=~~~~=-~~~ ▼ fl//
    if (Fl::event() == FL_SHORTCUT && Fl::event_key() == FL_Escape) return;
    script_panel->hide();
    //fl ▲ ----------=~-~~=-=--=~-----------~-==--~=~-~~--~=-~=~- ▲ fl//
 }
 ```

 The lines beginning with `//fl ▼` and `//fl ▲` are markers that Fluid
 uses to identify editable sections. These markers contain encoded information
 about the code block, including a CRC32 checksum and a unique node ID. Fluid
 uses this information during the merge process to detect changes and associate
 them with the correct nodes in your project.

 <H2>Editing and Merging Back</H2>

 1. **Edit the Source Code:**
   - Open the generated `.cxx` file in your preferred code editor.
   - Make your desired changes within the marked sections.

 2. **Merge Changes Back into Fluid:**
   - After saving your edits, return to Fluid.
   - Select **File > MergeBack** from the main menu or press `Ctrl+Shift+M`.
   - Fluid will analyze the `.cxx` file, detect changes within the marked
     sections, and offer to merge them back into the `.fl` project file.

 <H2>Things to Keep in Mind</H2>

 - **Scope of MergeBack:** Currently, MergeBack supports merging changes
   made to code blocks and widget callbacks. Other modifications might
   not be recognized or merged correctly.
 - **Conflict Detection:** Fluid calculates checksums (CRC32) for the
  code blocks to detect changes. If discrepancies are found, Fluid
  will prompt you with options to merge or cancel the changes.
 - **Undo Functionality:** In case of unintended merges, Fluid provides
  an undo feature to revert the project to its previous state.

 <H2>Caution</H2>

 Given the experimental nature of MergeBack, unexpected
 behaviors may occur. Always ensure you have backups of your project
 files before using this feature.
*/