1 | static int dm_placeModuleUnderAIBar_expiry = 4000; |
2 | |
3 | // return true if we are first |
4 | sbool dm_placeModuleUnderAIBar(O moduleOrID, fS query) { |
5 | fO module = dm_getModule(moduleOrID); |
6 | fS moduleID = dm_moduleID(moduleOrID); |
7 | dm_showModule_noFocus(module); |
8 | ret swing(func -> bool { |
9 | JTextComponent aiBar = cast getCreatorOpt('tfTopInput); |
10 | Rect mr = dm_getBounds(module); |
11 | if (aiBar == null || mr == null) false; |
12 | |
13 | Rectangle r = getBounds(aiBar); |
14 | |
15 | // height / query / timestamp |
16 | T3<Int, S, Long> p = optCast(T3, quickImport(dm_generalMap_get('modulesUnderAIBar_y))); |
17 | bool first = !(p != null && eq(p.b, query) |
18 | && sysNow() <= p.c+dm_placeModuleUnderAIBar_expiry |
19 | /*&& p.a != mr.y2()*/); |
20 | int y = first ? 0 : p.a; |
21 | |
22 | // place on top if there is space (doesn't work like this) |
23 | //if (y >= mr.h) y = 0; |
24 | |
25 | if (first) dm_generalMap_put('modulesUnderAIBar_firstModule, moduleID); |
26 | //print("dm_place: " + p + " / " + y); |
27 | dm_setBounds(module, r.x, y, r.width, mr.h); |
28 | int yOut = y+mr.h; |
29 | if (!first && p != null) yOut = max(yOut, p.a); |
30 | dm_generalMap_put('modulesUnderAIBar_y, t3(yOut, query, y == 0 ? sysNow() : p.c)); |
31 | if (first) |
32 | vmBus_send('placedModuleUnderAIBar, module); |
33 | ret first; |
34 | }); |
35 | } |
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1016704 |
Snippet name: | dm_placeModuleUnderAIBar (old, use v2 instead) |
Eternal ID of this version: | #1016704/31 |
Text MD5: | 8fc3591f876a3f5a77c597beca7c2669 |
Author: | stefan |
Category: | javax / stefan's os |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2019-01-18 00:41:58 |
Source code size: | 1311 bytes / 35 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 506 / 588 |
Version history: | 30 change(s) |
Referenced in: | [show references] |