Changeset 08fcaf2 in mainline
- Timestamp:
- 2026-02-19T20:27:38Z (23 hours ago)
- Branches:
- master
- Parents:
- b769ca0
- File:
-
- 1 edited
-
uspace/lib/ui/src/wdecor.c (modified) (15 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/ui/src/wdecor.c
rb769ca0 r08fcaf2 45 45 #include <ui/paint.h> 46 46 #include <ui/pbutton.h> 47 #include <ui/resource.h> 47 48 #include <ui/ui.h> 48 49 #include <ui/wdecor.h> 50 #include "../private/pbutton.h" 49 51 #include "../private/resource.h" 50 52 #include "../private/wdecor.h" 51 53 52 54 static void ui_wdecor_btn_min_clicked(ui_pbutton_t *, void *); 53 static errno_t ui_wdecor_btn_min_ paint(ui_pbutton_t *, void *,55 static errno_t ui_wdecor_btn_min_decor_paint(ui_pbutton_t *, void *, 54 56 gfx_coord2_t *); 57 static errno_t ui_wdecor_btn_min_paint_text(ui_pbutton_t *, void *); 55 58 56 59 static void ui_wdecor_btn_max_clicked(ui_pbutton_t *, void *); 57 static errno_t ui_wdecor_btn_max_ paint(ui_pbutton_t *, void *,60 static errno_t ui_wdecor_btn_max_decor_paint(ui_pbutton_t *, void *, 58 61 gfx_coord2_t *); 62 static errno_t ui_wdecor_btn_max_paint_text(ui_pbutton_t *, void *); 59 63 60 64 static void ui_wdecor_btn_close_clicked(ui_pbutton_t *, void *); 61 static errno_t ui_wdecor_btn_close_ paint(ui_pbutton_t *, void *,65 static errno_t ui_wdecor_btn_close_decor_paint(ui_pbutton_t *, void *, 62 66 gfx_coord2_t *); 67 static errno_t ui_wdecor_btn_close_paint_text(ui_pbutton_t *, void *); 63 68 64 69 static ui_pbutton_cb_t ui_wdecor_btn_min_cb = { … … 67 72 68 73 static ui_pbutton_ops_t ui_wdecor_btn_min_ops = { 69 .decor_paint = ui_wdecor_btn_min_paint 74 .decor_paint = ui_wdecor_btn_min_decor_paint 75 }; 76 77 static ui_pbutton_ops_t ui_wdecor_btn_min_ops_text = { 78 .paint = ui_wdecor_btn_min_paint_text 70 79 }; 71 80 … … 75 84 76 85 static ui_pbutton_ops_t ui_wdecor_btn_max_ops = { 77 .decor_paint = ui_wdecor_btn_max_paint 86 .decor_paint = ui_wdecor_btn_max_decor_paint 87 }; 88 89 static ui_pbutton_ops_t ui_wdecor_btn_max_ops_text = { 90 .paint = ui_wdecor_btn_max_paint_text 78 91 }; 79 92 … … 83 96 84 97 static ui_pbutton_ops_t ui_wdecor_btn_close_ops = { 85 .decor_paint = ui_wdecor_btn_close_paint 98 .decor_paint = ui_wdecor_btn_close_decor_paint 99 }; 100 101 static ui_pbutton_ops_t ui_wdecor_btn_close_ops_text = { 102 .paint = ui_wdecor_btn_close_paint_text 86 103 }; 87 104 … … 153 170 { 154 171 ui_wdecor_t *wdecor; 172 bool textmode; 155 173 errno_t rc; 174 175 textmode = ui_resource_is_textmode(resource); 156 176 157 177 wdecor = calloc(1, sizeof(ui_wdecor_t)); … … 175 195 (void *)wdecor); 176 196 177 ui_pbutton_set_ops(wdecor->btn_min, &ui_wdecor_btn_min_ops, 178 (void *)wdecor); 197 ui_pbutton_set_ops(wdecor->btn_min, textmode ? 198 &ui_wdecor_btn_min_ops_text : 199 &ui_wdecor_btn_min_ops, (void *)wdecor); 179 200 } 180 201 … … 189 210 (void *)wdecor); 190 211 191 ui_pbutton_set_ops(wdecor->btn_max, &ui_wdecor_btn_max_ops, 192 (void *)wdecor); 212 ui_pbutton_set_ops(wdecor->btn_max, textmode ? 213 &ui_wdecor_btn_max_ops_text : 214 &ui_wdecor_btn_max_ops, (void *)wdecor); 193 215 } 194 216 … … 203 225 (void *)wdecor); 204 226 205 ui_pbutton_set_ops(wdecor->btn_close, &ui_wdecor_btn_close_ops, 206 (void *)wdecor); 227 ui_pbutton_set_ops(wdecor->btn_close, textmode ? 228 &ui_wdecor_btn_close_ops_text : 229 &ui_wdecor_btn_close_ops, (void *)wdecor); 207 230 } 208 231 … … 369 392 rc = gfx_set_color(wdecor->res->gc, wdecor->sysmenu_hdl_active ? 370 393 wdecor->res->btn_shadow_color : wdecor->res->btn_face_color); 394 if (rc != EOK) 395 return rc; 371 396 372 397 gfx_text_fmt_init(&fmt); … … 1207 1232 * @param pos Center position 1208 1233 */ 1209 static errno_t ui_wdecor_btn_min_ paint(ui_pbutton_t *pbutton,1234 static errno_t ui_wdecor_btn_min_decor_paint(ui_pbutton_t *pbutton, 1210 1235 void *arg, gfx_coord2_t *pos) 1211 1236 { … … 1217 1242 1218 1243 return rc; 1244 } 1245 1246 /** Paint minimize button in text mode. 1247 * 1248 * @param pbutton Push button 1249 * @param arg Argument (ui_wdecor_t *) 1250 */ 1251 static errno_t ui_wdecor_btn_min_paint_text(ui_pbutton_t *pbutton, void *arg) 1252 { 1253 ui_wdecor_t *wdecor = (ui_wdecor_t *)arg; 1254 errno_t rc; 1255 gfx_text_fmt_t fmt; 1256 1257 gfx_text_fmt_init(&fmt); 1258 fmt.font = wdecor->res->font; 1259 fmt.color = (pbutton->held && pbutton->inside) ? 1260 wdecor->res->wnd_sel_text_color : 1261 wdecor->res->tbar_act_text_color; 1262 fmt.halign = gfx_halign_left; 1263 fmt.valign = gfx_valign_top; 1264 1265 rc = gfx_puttext(&pbutton->rect.p0, &fmt, "[\u2193]"); 1266 if (rc != EOK) 1267 return rc; 1268 1269 return gfx_update(wdecor->res->gc); 1219 1270 } 1220 1271 … … 1225 1276 * @param pos Center position 1226 1277 */ 1227 static errno_t ui_wdecor_btn_max_ paint(ui_pbutton_t *pbutton,1278 static errno_t ui_wdecor_btn_max_decor_paint(ui_pbutton_t *pbutton, 1228 1279 void *arg, gfx_coord2_t *pos) 1229 1280 { … … 1231 1282 errno_t rc; 1232 1283 1233 if (wdecor->maximized) { 1234 rc = ui_paint_unmaxicon(wdecor->res, pos, wdecor_unmax_w, 1235 wdecor_unmax_h, wdecor_unmax_dw, wdecor_unmax_dh); 1236 } else { 1237 rc = ui_paint_maxicon(wdecor->res, pos, wdecor_max_w, 1238 wdecor_max_h); 1239 } 1284 rc = ui_paint_maxicon(wdecor->res, pos, wdecor_min_w, 1285 wdecor_min_h); 1240 1286 1241 1287 return rc; 1288 } 1289 1290 /** Paint maximize button in text mode. 1291 * 1292 * @param pbutton Push button 1293 * @param arg Argument (ui_wdecor_t *) 1294 */ 1295 static errno_t ui_wdecor_btn_max_paint_text(ui_pbutton_t *pbutton, void *arg) 1296 { 1297 ui_wdecor_t *wdecor = (ui_wdecor_t *)arg; 1298 errno_t rc; 1299 gfx_text_fmt_t fmt; 1300 1301 gfx_text_fmt_init(&fmt); 1302 fmt.font = wdecor->res->font; 1303 fmt.color = (pbutton->held && pbutton->inside) ? 1304 wdecor->res->wnd_sel_text_color : 1305 wdecor->res->tbar_act_text_color; 1306 fmt.halign = gfx_halign_left; 1307 fmt.valign = gfx_valign_top; 1308 1309 rc = gfx_puttext(&pbutton->rect.p0, &fmt, "[\u2191]"); 1310 if (rc != EOK) 1311 return rc; 1312 1313 return gfx_update(wdecor->res->gc); 1242 1314 } 1243 1315 … … 1261 1333 * @param pos Center position 1262 1334 */ 1263 static errno_t ui_wdecor_btn_close_ paint(ui_pbutton_t *pbutton,1335 static errno_t ui_wdecor_btn_close_decor_paint(ui_pbutton_t *pbutton, 1264 1336 void *arg, gfx_coord2_t *pos) 1265 1337 { … … 1278 1350 } 1279 1351 1352 /** Paint close button in text mode. 1353 * 1354 * @param pbutton Push button 1355 * @param arg Argument (ui_wdecor_t *) 1356 */ 1357 static errno_t ui_wdecor_btn_close_paint_text(ui_pbutton_t *pbutton, void *arg) 1358 { 1359 ui_wdecor_t *wdecor = (ui_wdecor_t *)arg; 1360 errno_t rc; 1361 gfx_text_fmt_t fmt; 1362 1363 gfx_text_fmt_init(&fmt); 1364 fmt.font = wdecor->res->font; 1365 fmt.color = (pbutton->held && pbutton->inside) ? 1366 wdecor->res->wnd_sel_text_color : 1367 wdecor->res->tbar_act_text_color; 1368 fmt.halign = gfx_halign_left; 1369 fmt.valign = gfx_valign_top; 1370 1371 rc = gfx_puttext(&pbutton->rect.p0, &fmt, "[\u25a0]"); 1372 if (rc != EOK) 1373 return rc; 1374 1375 return gfx_update(wdecor->res->gc); 1376 } 1377 1280 1378 /** @} 1281 1379 */
Note:
See TracChangeset
for help on using the changeset viewer.
