int RUCE_Roto_GetEntry(RUCE_Roto* This, RUCE_Roto_Entry* Dest, String* Name) { cJSON* Entries = cJSON_GetObjectItem(This -> Ptr, "Entries"); if(! Entries) return 0; cJSON* Entry = cJSON_GetObjectItem(Entries, String_GetChars(Name)); if(! Entry) return -1; _GetEntry(); return 1; }
int RUCE_Roto_GetEntryByIndex(RUCE_Roto* This, RUCE_Roto_Entry* Dest, int Index) { cJSON* Entries = cJSON_GetObjectItem(This -> Ptr, "Entries"); if(! Entries) return 0; cJSON* Entry = cJSON_GetArrayItem(Entries, Index); if(! Entry) return -1; _GetEntry(); return 1; }
static gboolean dsource_Measure(t_HDataSource h, t_GuiViewType viewtype, int index, int *width, int *height) { t_DSAppStore* pme = (t_DSAppStore *)h; t_AppStoreDir *entry = pme->entry; t_AppStoreEntry* child; t_AppStoreDir *dir; t_AppStoreApp *app; BrdHandle brd; char title[GUID_NAME_MAX+1]; t_HImage image = NULL; int iw, ih, tw, th; child = _GetEntry(entry, index); if(!child) return FALSE; strcpy(title, "<N/A>"); if(child->type == APPSTORE_ENTRY_APP){ app = (t_AppStoreApp *)child; image = pack_GetIcon(app->guid); pack_GetModuleTitle(app->guid, app->module, title, sizeof(title)); }else{ dir = (t_AppStoreDir *)child; brd = brd_get("sys"); image = brd_get_image(brd, dir->icon); brd_get_string2(brd, dir->text, title, sizeof(title)); } iw = ih = tw = th = 0; font_measure_string(title, -1, CHARSET_UNDEF, -1, &tw, &th, NULL); if(g_object_valid(image)){ iw = image_get_width(image); ih = image_get_height(image); } if(viewtype == GUI_VIEWTYPE_NORMAL){ if(width)*width = tw+iw+ICON_TEXT_SPLIT; if(height)*height = MAX(th, ih); }else if(viewtype == GUI_VIEWTYPE_ICON_ONLY || viewtype == GUI_VIEWTYPE_ICON_TEXT_TITLE){ if(width)*width = iw; if(height)*height = ih; }else if(viewtype == GUI_VIEWTYPE_ICON_TEXT_TOP || viewtype == GUI_VIEWTYPE_ICON_TEXT_BOTTOM){ if(width){*width = MAX(tw, iw); if(*width > 80)*width = 80; } if(height){*height = th+ih+ICON_TEXT_SPLIT; if(*height > 80)*height = 80; } }else{ if(width)*width = 0; if(height)*height = 0; } g_object_unref(image); return TRUE; }
bool VirtualDirectoryPoseView::_EntryRemoved(const BMessage* message) { NotOwningEntryRef entryRef; node_ref nodeRef; if (message->FindInt32("device", &nodeRef.device) != B_OK || message->FindInt64("node", &nodeRef.node) != B_OK || message->FindInt64("directory", &entryRef.directory) != B_OK || message->FindString("name", (const char**)&entryRef.name) != B_OK) { return true; } entryRef.device = nodeRef.device; // It might be our definition file. if (nodeRef == *TargetModel()->NodeRef()) return _inherited::FSNotification(message); // It might be one of our directories. BString path; if (message->FindString("path", &path) == B_OK && fDirectoryPaths.HasString(path)) { // Find all poses that stem from that directory and generate an // entry-removed message for each. PoseList poses; for (int32 i = 0; BPose* pose = fPoseList->ItemAt(i); i++) { NotOwningEntryRef poseEntryRef = *pose->TargetModel()->EntryRef(); if (poseEntryRef.DirectoryNodeRef() == nodeRef) poses.AddItem(pose); } for (int32 i = 0; BPose* pose = poses.ItemAt(i); i++) { _DispatchEntryCreatedOrRemovedMessage(B_ENTRY_REMOVED, *pose->TargetModel()->NodeRef(), *pose->TargetModel()->EntryRef(), NULL, false); } return true; } // If it is a directory, translate it. entry_ref* actualEntryRef = &entryRef; node_ref* actualNodeRef = &nodeRef; entry_ref definitionEntryRef; node_ref definitionNodeRef; VirtualDirectoryManager* manager = VirtualDirectoryManager::Instance(); AutoLocker<VirtualDirectoryManager> managerLocker(manager); if (manager != NULL && manager->GetSubDirectoryDefinitionFile(*TargetModel()->NodeRef(), entryRef.name, definitionEntryRef, definitionNodeRef)) { actualEntryRef = &definitionEntryRef; actualNodeRef = &definitionNodeRef; } // Check the pose. It might have been an entry that wasn't visible anyway. // In that case we can just ignore the notification. BPose* pose = fPoseList->FindPoseByFileName(actualEntryRef->name); if (pose == NULL || *actualNodeRef != *pose->TargetModel()->NodeRef()) return true; // See, if another entry becomes visible, now. struct stat st; entry_ref visibleEntryRef; node_ref visibleNodeRef; if (_GetEntry(actualEntryRef->name, visibleEntryRef, &st)) { // If the new entry is a directory, translate it. visibleNodeRef = node_ref(st.st_dev, st.st_ino); if (S_ISDIR(st.st_mode)) { if (manager == NULL || manager->TranslateDirectoryEntry( *TargetModel()->NodeRef(), visibleEntryRef, visibleNodeRef) != B_OK) { return true; } // Effectively nothing changes, when the removed entry was a // directory as well. if (visibleNodeRef == *actualNodeRef) return true; } } if (actualEntryRef == &entryRef) { managerLocker.Unlock(); if (_inherited::FSNotification(message)) pendingNodeMonitorCache.Add(message); } else { // tell the manager that the directory has been removed manager->DirectoryRemoved(*actualNodeRef); managerLocker.Unlock(); _DispatchEntryCreatedOrRemovedMessage(B_ENTRY_REMOVED, *actualNodeRef, *actualEntryRef); } _DispatchEntryCreatedOrRemovedMessage(B_ENTRY_CREATED, visibleNodeRef, visibleEntryRef); return true; }
bool VirtualDirectoryPoseView::_EntryCreated(const BMessage* message) { NotOwningEntryRef entryRef; node_ref nodeRef; if (message->FindInt32("device", &nodeRef.device) != B_OK || message->FindInt64("node", &nodeRef.node) != B_OK || message->FindInt64("directory", &entryRef.directory) != B_OK || message->FindString("name", (const char**)&entryRef.name) != B_OK) { return true; } entryRef.device = nodeRef.device; // It might be one of our directories. BString path; if (message->FindString("path", &path) == B_OK && fDirectoryPaths.HasString(path)) { // Iterate through the directory and generate an entry-created message // for each entry. BDirectory directory; if (directory.SetTo(&nodeRef) != B_OK) return true; BPrivate::Storage::LongDirEntry entry; while (directory.GetNextDirents(&entry, sizeof(entry), 1) == 1) { if (strcmp(entry.d_name, ".") != 0 && strcmp(entry.d_name, "..") != 0) { _DispatchEntryCreatedOrRemovedMessage(B_ENTRY_CREATED, node_ref(entry.d_dev, entry.d_ino), NotOwningEntryRef(entry.d_pdev, entry.d_pino, entry.d_name), NULL, false); } } return true; } // See, if this entry actually becomes visible. If not, we can simply ignore // it. struct stat st; entry_ref visibleEntryRef; if (!_GetEntry(entryRef.name, visibleEntryRef, &st) || visibleEntryRef != entryRef) { return true; } // If it is a directory, translate it. VirtualDirectoryManager* manager = VirtualDirectoryManager::Instance(); AutoLocker<VirtualDirectoryManager> managerLocker(manager); bool entryTranslated = S_ISDIR(st.st_mode); if (entryTranslated) { if (manager == NULL) return true; if (manager->TranslateDirectoryEntry(*TargetModel()->NodeRef(), entryRef, nodeRef) != B_OK) { return true; } } // The entry might replace another entry. If it does, we'll fake a removed // message for the old one first. BPose* pose = fPoseList->FindPoseByFileName(entryRef.name); if (pose != NULL) { if (nodeRef == *pose->TargetModel()->NodeRef()) { // apparently not really a new entry -- can happen for // subdirectories return true; } // It may be a directory, so tell the manager. if (manager != NULL) manager->DirectoryRemoved(*pose->TargetModel()->NodeRef()); managerLocker.Unlock(); BMessage removedMessage(B_NODE_MONITOR); _DispatchEntryCreatedOrRemovedMessage(B_ENTRY_REMOVED, *pose->TargetModel()->NodeRef(), *pose->TargetModel()->EntryRef()); } else managerLocker.Unlock(); return entryTranslated ? (_DispatchEntryCreatedOrRemovedMessage(B_ENTRY_CREATED, nodeRef, entryRef), true) : _inherited::FSNotification(message); }
static void dsource_Redraw(t_HDataSource h, t_HGDI gdi, t_GuiViewType viewtype, int index, int width, int height, gboolean hilight) { t_DSAppStore* pme = (t_DSAppStore *)h; t_AppStoreEntry* child; BrdHandle brd; resid_t resid; t_HImage image = NULL; char title[GUID_NAME_MAX+1]; gu32 old; child = _GetEntry(pme->entry, index); if(!child) return; if(pme->icon_w >= width || pme->icon_h >= height){ pme->icon_w = 0; pme->icon_h = 0; } old = gdi_set_color(gdi, RGB_WHITE); strcpy(title, "<N/A>"); if(child->type == APPSTORE_ENTRY_APP){ t_AppStoreApp *app = (t_AppStoreApp *)child; brd = brd_get(app->guid); resid = RESID_APP_ICON; if(brd == BRD_HANDLE_ERROR) //2 资源获取失败则表示动态加载应用 image = pack_GetIcon(app->guid); pack_GetModuleTitle(app->guid, app->module, title, sizeof(title)); }else{ t_AppStoreDir *dir = (t_AppStoreDir *)child; brd = brd_get("sys"); resid = dir->icon; //image = brd_get_image0(brd, dir->icon); brd_get_string2(brd, dir->text, title, sizeof(title)); } if(VIEWTYPE_IS_NORMAL(viewtype)){ if(image == NULL) image = brd_get_image(brd, resid); gdi_draw_icon_text(gdi, image, title, width, height, guiRight, IDF_HALIGN_LEFT|IDF_VALIGN_MIDDLE); }else if(VIEWTYPE_IS_ICON(viewtype)){ int text_height = font_get(lang_get_current())->height; int icon_height = height; if(viewtype == GUI_VIEWTYPE_ICON_TEXT_BOTTOM || viewtype == GUI_VIEWTYPE_ICON_TEXT_TOP) icon_height -= text_height+ICON_TEXT_SPLIT; { gui_rect_t tmp; if(pme->icon_w && pme->icon_h){ tmp.x = (width-pme->icon_w)>>1; tmp.y = (icon_height-pme->icon_h)>>1; tmp.dx = pme->icon_w; tmp.dy = pme->icon_h; }else{ tmp.x = 0; tmp.y = 0; tmp.dx = width; tmp.dy = icon_height; } if(g_object_valid(image)){ //2 动态加载的应用的图标,直接显示 gdi_draw_image_in(gdi, tmp.x, tmp.y, tmp.dx, tmp.dy, image, IDF_HALIGN_BESTFIT | IDF_VALIGN_BESTFIT); }else if(!hilight){ //2 非焦点项,也直接显示 gdi_draw_image_in_by_resid(gdi, tmp.x, tmp.y, tmp.dx, tmp.dy, brd, resid, IDF_HALIGN_BESTFIT | IDF_VALIGN_BESTFIT); }else{ //2 焦点项,如果是多帧gif,则播放动画 mmc_stop(pme->mmc_anim); mmc_set_image_output(pme->mmc_anim, gdi, &tmp); mmc_play_resid(pme->mmc_anim, -1, brd, resid); } }