@@ -33,6 +33,7 @@ static const char *mousemodes[] = {
33
33
#define SMALLNODE_MIN_WIDTH 8
34
34
#define SMALLNODE_TITLE_LEN 4
35
35
#define SMALLNODE_CENTER_X 3
36
+ #define MININODE_MIN_WIDTH 16
36
37
37
38
#define ZOOM_STEP 10
38
39
#define ZOOM_DEFAULT 100
@@ -163,6 +164,9 @@ static void update_node_dimension(const RGraph *g, int is_small, int zoom) {
163
164
if (is_small ) {
164
165
n -> h = 1 ;
165
166
n -> w = SMALLNODE_MIN_WIDTH ;
167
+ } else if (n -> is_mini ) {
168
+ n -> h = 1 ;
169
+ n -> w = MININODE_MIN_WIDTH ;
166
170
} else {
167
171
unsigned int len ;
168
172
n -> w = r_str_bounds (n -> body , (int * ) & n -> h );
@@ -183,46 +187,8 @@ static void update_node_dimension(const RGraph *g, int is_small, int zoom) {
183
187
}
184
188
}
185
189
186
- static void small_RANode_print (const RAGraph * g , const RANode * n , int cur ) {
187
- char title [TITLE_LEN ];
188
- int x , delta_x = 0 ;
189
-
190
- if (!G (n -> x + SMALLNODE_CENTER_X , n -> y ) &&
191
- !G (n -> x + SMALLNODE_CENTER_X + n -> w , n -> y )) {
192
- return ;
193
- }
194
-
195
- x = n -> x + SMALLNODE_CENTER_X + g -> can -> sx ;
196
- if (x < 0 ) {
197
- delta_x = - x ;
198
- }
199
- G (n -> x + SMALLNODE_CENTER_X + delta_x , n -> y );
200
-
201
- if (cur ) {
202
- W (& SMALLNODE_TEXT_CUR [delta_x ]);
203
- (void ) G (- g -> can -> sx , - g -> can -> sy + 2 );
204
- snprintf (title , sizeof (title ) - 1 ,
205
- "%s:" , n -> title );
206
- W (title );
207
- (void ) G (- g -> can -> sx , - g -> can -> sy + 3 );
208
- W (n -> body );
209
- } else {
210
- char * str = "____" ;
211
- if (n -> title ) {
212
- int l = strlen (n -> title );
213
-
214
- str = n -> title ;
215
- if (l > SMALLNODE_TITLE_LEN ) {
216
- str += l - SMALLNODE_TITLE_LEN ;
217
- }
218
- }
219
- snprintf (title , sizeof (title ) - 1 , "[_%s_]" , str );
220
- W (title + delta_x );
221
- }
222
- return ;
223
- }
224
-
225
- static void mini_RANode_print (const RAGraph * g , const RANode * n , int cur ) {
190
+ static void small_RANode_print (const RAGraph * g , const RANode * n ,
191
+ int cur , bool print_details ) {
226
192
char title [TITLE_LEN ];
227
193
int x , delta_x = 0 ;
228
194
@@ -239,15 +205,31 @@ static void mini_RANode_print(const RAGraph *g, const RANode *n, int cur) {
239
205
return ;
240
206
}
241
207
242
- if (cur ) {
243
- W (& SMALLNODE_TEXT_CUR [delta_x ]);
244
- snprintf (title , sizeof (title ) - 1 ,
245
- "[ %s ]" , n -> title );
246
- W (title );
208
+ if (print_details ) {
209
+ if (cur ) {
210
+ W (& SMALLNODE_TEXT_CUR [delta_x ]);
211
+ (void ) G (- g -> can -> sx , - g -> can -> sy + 2 );
212
+ snprintf (title , sizeof (title ) - 1 ,
213
+ "[ %s ]" , n -> title );
214
+ W (title );
215
+ (void ) G (- g -> can -> sx , - g -> can -> sy + 3 );
216
+ W (n -> body );
217
+ } else {
218
+ char * str = "____" ;
219
+ if (n -> title ) {
220
+ int l = strlen (n -> title );
221
+
222
+ str = n -> title ;
223
+ if (l > SMALLNODE_TITLE_LEN ) {
224
+ str += l - SMALLNODE_TITLE_LEN ;
225
+ }
226
+ }
227
+ snprintf (title , sizeof (title ) - 1 , "__%s__" , str );
228
+ W (title + delta_x );
229
+ }
247
230
} else {
248
- W (& SMALLNODE_TEXT_CUR [delta_x ]);
249
231
snprintf (title , sizeof (title ) - 1 ,
250
- " %s " , n -> title );
232
+ cur ? "[ %s ]" : " %s " , n -> title );
251
233
W (title );
252
234
}
253
235
return ;
@@ -2275,30 +2257,10 @@ static void agraph_update_seek(RAGraph *g, RANode *n, int force) {
2275
2257
2276
2258
static void agraph_print_node (const RAGraph * g , RANode * n ) {
2277
2259
const int cur = g -> curnode && get_anode (g -> curnode ) == n ;
2278
- if (is_mini (g )) {
2279
- small_RANode_print (g , n , cur );
2260
+ if (is_mini (g ) || n -> is_mini ) {
2261
+ small_RANode_print (g , n , cur , is_mini ( g ) );
2280
2262
} else {
2281
- if (n -> mini ) {
2282
- n -> w = strlen (n -> title ) + 4 ;
2283
- n -> h = 1 ;
2284
- #if 1
2285
- mini_RANode_print (g , n , cur );
2286
- #else
2287
- small_RANode_print (g , n , cur );
2288
- #endif
2289
- } else {
2290
- if (n -> h < 4 ) {
2291
- int titlen = strlen (n -> title );
2292
- n -> w = r_str_bounds (n -> body , (int * ) & n -> h );
2293
- if (titlen > n -> w ) {
2294
- n -> w = titlen + 6 ;
2295
- } else {
2296
- n -> w += 4 ;
2297
- }
2298
- n -> h += 3 ;
2299
- }
2300
- normal_RANode_print (g , n , cur );
2301
- }
2263
+ normal_RANode_print (g , n , cur );
2302
2264
}
2303
2265
}
2304
2266
@@ -2500,7 +2462,8 @@ static void agraph_merge_child(RAGraph *g, int idx) {
2500
2462
2501
2463
static void agraph_toggle_mini (RAGraph * g ) {
2502
2464
RANode * n = get_anode (g -> curnode );
2503
- n -> mini = !n -> mini ;
2465
+ n -> is_mini = !n -> is_mini ;
2466
+ g -> need_update_dim = 1 ;
2504
2467
agraph_refresh (r_cons_singleton ()-> event_data );
2505
2468
agraph_set_layout ((RAGraph * ) g , r_cons_singleton ()-> is_interactive );
2506
2469
}
0 commit comments