Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

39
LINES

< > BotCompany Repo | #1021001 // dm_placeModuleUnderAIBar_v2

JavaX fragment (include)

static int dm_placeModuleUnderAIBar_expiry = 4000;

svoid dm_placeModuleUnderAIBar_v2(O moduleOrID, fS query) {
  fO module = dm_getModule(moduleOrID);
  fS moduleID = dm_moduleID(moduleOrID);
  dm_showModule_noFocus(module);
  swing {
    JTextComponent aiBar = cast getCreatorOpt('tfTopInput);
    Rect mr = dm_getBounds(module);
    if (aiBar == null || mr == null) ret;
    
    Rectangle r = getBounds(aiBar);
    
    QuickSearchPlacement p = optCastAndQuickImport(QuickSearchPlacement, dm_generalMap_get('modulesUnderAIBar));
    
    // new query?
    if (p != null && !eq(p.query, query)) p = null;
    
    // too old?
    if (p != null && elapsedMS(p.lastAdded) > dm_placeModuleUnderAIBar_expiry) p = null;
    
    // already contained? do nothing
    if (p != null && contains(p.modules, moduleID)) ret;
    
    if (p == null) p = new QuickSearchPlacement;
    p.query = query;
    
    // place below
    int y = p.height;
    p.height += mr.h;
    p.modules.add(moduleID);
    if (p.firstAdded == 0) p.firstAdded = now();
    p.lastAdded = now();

    //print("dm_place: " + p + " / " + y);
    dm_setBounds(module, r.x, y, r.width, mr.h);
    dm_generalMap_put('modulesUnderAIBar, p);
  }
}

Author comment

Began life as a copy of #1016704

download  show line numbers  debug dex  old transpilations   

Travelled to 7 computer(s): bhatertpkbcr, cfunsshuasjs, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1021001
Snippet name: dm_placeModuleUnderAIBar_v2
Eternal ID of this version: #1021001/5
Text MD5: 74ec4308930a88b974d739149a13ab6c
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-17 14:56:21
Source code size: 1245 bytes / 39 lines
Pitched / IR pitched: No / No
Views / Downloads: 228 / 284
Version history: 4 change(s)
Referenced in: [show references]