const char* PropertyWindow::name() const { const vector<I64> nodes = selections(); if (nodes.empty()) { return DockedWindow::name(); } if (nodes.size() == 1) { return node(nodes.front())->name().c_str(); } return Util::StringFormat("%s, %s, ...", node(nodes[0])->name().c_str(), node(nodes[1])->name().c_str()).c_str(); }
void QTextParagraph::setSelection( int id, int start, int end ) { QMap<int, QTextParagraphSelection>::ConstIterator it = selections().find( id ); if ( it != mSelections->end() ) { if ( start == ( *it ).start && end == ( *it ).end ) return; } QTextParagraphSelection sel; sel.start = start; sel.end = end; (*mSelections)[ id ] = sel; setChanged( TRUE, TRUE ); }
void Q3TextParagraph::setSelection(int id, int start, int end) { QMap<int, Q3TextParagraphSelection>::ConstIterator it = selections().constFind(id); if (it != mSelections->constEnd()) { if (start == (*it).start && end == (*it).end) return; } Q3TextParagraphSelection sel; sel.start = start; sel.end = end; (*mSelections)[id] = sel; setChanged(true, true); }
Foam::wordHashSet Foam::vtkPV3Foam::getSelected ( vtkDataArraySelection* select ) { int nElem = select->GetNumberOfArrays(); wordHashSet selections(2*nElem); for (int elemI=0; elemI < nElem; ++elemI) { if (select->GetArraySetting(elemI)) { selections.insert(getFirstWord(select->GetArrayName(elemI))); } } return selections; }
Foam::wordHashSet Foam::vtkPV3Foam::getSelected ( vtkDataArraySelection* select, const partInfo& selector ) { int nElem = select->GetNumberOfArrays(); wordHashSet selections(2*nElem); for (int elemI = selector.start(); elemI < selector.end(); ++elemI) { if (select->GetArraySetting(elemI)) { selections.insert(getFirstWord(select->GetArrayName(elemI))); } } return selections; }
Foam::wordHashSet Foam::vtkPVblockMesh::getSelected ( vtkDataArraySelection* select, const arrayRange& range ) { int nElem = select->GetNumberOfArrays(); wordHashSet selections(2*nElem); for (int elemI = range.start(); elemI < range.end(); ++elemI) { if (select->GetArraySetting(elemI)) { selections.insert(getFirstWord(select->GetArrayName(elemI))); } } return selections; }
Foam::stringList Foam::vtkPV3Foam::getSelectedArrayEntries ( vtkDataArraySelection* select, const partInfo& selector ) { stringList selections(selector.size()); label nElem = 0; for (int elemI = selector.start(); elemI < selector.end(); ++elemI) { if (select->GetArraySetting(elemI)) { selections[nElem++] = select->GetArrayName(elemI); } } selections.setSize(nElem); if (debug) { Info<< "available("; for (int elemI = selector.start(); elemI < selector.end(); ++elemI) { Info<< " \"" << select->GetArrayName(elemI) << "\""; } Info<< " )\nselected("; forAll(selections, elemI) { Info<< " " << selections[elemI]; } Info<< " )\n"; } return selections; }
Foam::stringList Foam::vtkPV3Foam::getSelectedArrayEntries ( vtkDataArraySelection* select ) { stringList selections(select->GetNumberOfArrays()); label nElem = 0; forAll(selections, elemI) { if (select->GetArraySetting(elemI)) { selections[nElem++] = select->GetArrayName(elemI); } } selections.setSize(nElem); if (debug) { label nElem = select->GetNumberOfArrays(); Info<< "available("; for (int elemI = 0; elemI < nElem; ++elemI) { Info<< " \"" << select->GetArrayName(elemI) << "\""; } Info<< " )\nselected("; forAll(selections, elemI) { Info<< " " << selections[elemI]; } Info<< " )\n"; } return selections; }
//----------------------------------------------------------------------------- uint TCheckList::Transfer(void* buffer, TTransferDirection direction) { long style = GetStyle(); TCheckListData* checkListData = (TCheckListData*)buffer; if (direction == tdGetData){ // First, clear out Strings array and fill with contents of list box // checkListData->Clear(false); int count = GetCount(); for(int i =0; i < count; i++) checkListData->AddItem(GetItem(i)); // Update transfer data with new selected item(s) // checkListData->ResetSelections(); if (!(style & MULTIPLESEL)) { // Single selection // checkListData->Select(GetSelIndex()); } else { // Multiple selection // int selCount = GetSelCount(); if (selCount > 0) { TAPointer<int> selections(new int[selCount]); GetSelIndexes(selections, selCount); // Select each item by index // for (int selIndex = 0; selIndex < selCount; selIndex++) checkListData->Select(selections[selIndex]); } } } else if (direction == tdSetData){ ClearList(); // Add each string, item data and selections in listBoxData to list box // const int noSelection = -1; uint selCount = checkListData->GetSelCount(); // for multi selection int selIndex = noSelection; // for single selection for (uint i = 0; i < checkListData->ItemCount(); i++){ // Index may be different from i when the listbox is sorted. // int index = AddString((LPCTSTR)checkListData->GetItem(i)); if (style & MULTIPLESEL) { for (uint j = 0; j < selCount; j++) if (checkListData->GetSelIndices()[j] == (int)i) { SetSel(index, true); break; } } else { if (selCount && (uint)checkListData->GetSelIndices()[0] == i) selIndex = index; else // Inserted something before item and the item to select has been // pushed further down in the list. // if (selIndex != noSelection && index <= selIndex) selIndex++; } } if (selIndex != noSelection && !(style & MULTIPLESEL)) SetSelIndex(selIndex); } return sizeof(TCheckListData); }
void PropertyWindow::drawInternal() { bool hasSelections = !selections().empty(); Camera* selectedCamera = Attorney::EditorPropertyWindow::getSelectedCamera(_parent); if (selectedCamera != nullptr) { if (ImGui::CollapsingHeader(selectedCamera->resourceName().c_str())) { vec3<F32> eye = selectedCamera->getEye(); if (ImGui::InputFloat3("Eye", eye._v)) { selectedCamera->setEye(eye); } vec3<F32> euler = selectedCamera->getEuler(); if (ImGui::InputFloat3("Euler", euler._v)) { selectedCamera->setEuler(euler); } F32 aspect = selectedCamera->getAspectRatio(); if (ImGui::InputFloat("Aspect", &aspect)) { selectedCamera->setAspectRatio(aspect); } F32 horizontalFoV = selectedCamera->getHorizontalFoV(); if (ImGui::InputFloat("FoV (horizontal)", &horizontalFoV)) { selectedCamera->setHorizontalFoV(horizontalFoV); } vec2<F32> zPlanes = selectedCamera->getZPlanes(); if (ImGui::InputFloat2("zPlanes", zPlanes._v)) { if (selectedCamera->isOrthoProjected()) { selectedCamera->setProjection(selectedCamera->orthoRect(), zPlanes); } else { selectedCamera->setProjection(selectedCamera->getAspectRatio(), selectedCamera->getVerticalFoV(), zPlanes); } } if (selectedCamera->isOrthoProjected()) { vec4<F32> orthoRect = selectedCamera->orthoRect(); if (ImGui::InputFloat4("Ortho", orthoRect._v)) { selectedCamera->setProjection(orthoRect, selectedCamera->getZPlanes()); } } ImGui::Text("View Matrix"); ImGui::Spacing(); mat4<F32> viewMatrix = selectedCamera->getViewMatrix(); EditorComponentField worldMatrixField = { GFX::PushConstantType::MAT4, EditorComponentFieldType::PUSH_TYPE, true, "View Matrix", &viewMatrix }; processBasicField(worldMatrixField); ImGui::Text("Projection Matrix"); ImGui::Spacing(); mat4<F32> projMatrix = selectedCamera->getProjectionMatrix(); EditorComponentField projMatrixField = { GFX::PushConstantType::MAT4, EditorComponentFieldType::PUSH_TYPE, true, "Projection Matrix", &projMatrix }; processBasicField(projMatrixField); } } else if (hasSelections) { const F32 smallButtonWidth = 60.0f; F32 xOffset = ImGui::GetWindowSize().x * 0.5f - smallButtonWidth; const vector<I64>& crtSelections = selections(); static bool closed = false; for (I64 nodeGUID : crtSelections) { SceneGraphNode* sgnNode = node(nodeGUID); if (sgnNode != nullptr) { bool enabled = sgnNode->isActive(); if (ImGui::Checkbox(sgnNode->name().c_str(), &enabled)) { sgnNode->setActive(enabled); } ImGui::Separator(); vectorFast<EditorComponent*>& editorComp = Attorney::SceneGraphNodeEditor::editorComponents(*sgnNode); for (EditorComponent* comp : editorComp) { if (ImGui::CollapsingHeader(comp->name().c_str(), ImGuiTreeNodeFlags_OpenOnArrow)) { //const I32 RV = ImGui::AppendTreeNodeHeaderButtons(comp->name().c_str(), ImGui::GetCursorPosX(), 1, &closed, "Remove", NULL, 0); ImGui::NewLine(); ImGui::SameLine(xOffset); if (ImGui::Button("INSPECT", ImVec2(smallButtonWidth, 20))) { Attorney::EditorGeneralWidget::inspectMemory(_context.editor(), std::make_pair(comp, sizeof(EditorComponent))); } ImGui::SameLine(); if (ImGui::Button("REMOVE", ImVec2(smallButtonWidth, 20))) { Attorney::EditorGeneralWidget::inspectMemory(_context.editor(), std::make_pair(nullptr, 0)); } ImGui::Separator(); vector<EditorComponentField>& fields = Attorney::EditorComponentEditor::fields(*comp); for (EditorComponentField& field : fields) { ImGui::Text(field._name.c_str()); ImGui::Spacing(); if (processField(field) && !field._readOnly) { Attorney::EditorComponentEditor::onChanged(*comp, field); } } } } } } } if (hasSelections) { const F32 buttonWidth = 80.0f; F32 xOffset = ImGui::GetWindowSize().x - buttonWidth - 20.0f; ImGui::NewLine(); ImGui::Separator(); ImGui::NewLine(); ImGui::SameLine(xOffset); if (ImGui::Button("ADD NEW", ImVec2(buttonWidth, 15))) { ImGui::OpenPopup("COMP_SELECTION_GROUP"); } static ComponentType selectedType = ComponentType::COUNT; if (ImGui::BeginPopup("COMP_SELECTION_GROUP")) { for (ComponentType type : ComponentType::_values()) { if (type._to_integral() == ComponentType::COUNT) { continue; } if (ImGui::Selectable(type._to_string())) { selectedType = type; } } ImGui::EndPopup(); } if (selectedType._to_integral() != ComponentType::COUNT) { ImGui::OpenPopup("Add new component"); } if (ImGui::BeginPopupModal("Add new component", NULL, ImGuiWindowFlags_AlwaysAutoResize)) { ImGui::Text("Add new %s component?", selectedType._to_string()); ImGui::Separator(); if (ImGui::Button("OK", ImVec2(120, 0))) { selectedType = ComponentType::COUNT; ImGui::CloseCurrentPopup(); } ImGui::SetItemDefaultFocus(); ImGui::SameLine(); if (ImGui::Button("Cancel", ImVec2(120, 0))) { selectedType = ComponentType::COUNT; ImGui::CloseCurrentPopup(); } ImGui::EndPopup(); } } }
void create_widget(const dictionary_t& parameters, size_enum_t, listbox_t*& listbox) { std::string name; std::string alt_text; long characters(25); long rows(0); bool sort(false); name_t sort_order("ascending"); name_t selections("single"); bool user_delete(false); bool browse_updates(false); array_t items; listbox_t::item_set_t item_set; GG::Clr color(GG::CLR_GRAY); GG::Clr interior_color(GG::CLR_ZERO); GG::Clr hilite_color(GG::CLR_SHADOW); GG::Clr label_color(GG::CLR_BLACK); GG::Clr item_text_color(GG::CLR_BLACK); name_t signal_id; array_t allowed_drop_types; implementation::get_localized_string(parameters, key_name, name); implementation::get_localized_string(parameters, key_alt_text, alt_text); get_value(parameters, key_characters, characters); get_value(parameters, static_name_t("rows"), rows); get_value(parameters, static_name_t("sort"), sort); get_value(parameters, static_name_t("sort_order"), sort_order); get_value(parameters, static_name_t("selections"), selections); get_value(parameters, static_name_t("user_delete"), user_delete); get_value(parameters, static_name_t("browse_updates"), browse_updates); get_value(parameters, key_items, items); implementation::get_color(parameters, static_name_t("color"), color); implementation::get_color(parameters, static_name_t("interior_color"), interior_color); implementation::get_color(parameters, static_name_t("hilite_color"), hilite_color); implementation::get_color(parameters, static_name_t("label_color"), label_color); implementation::get_color(parameters, static_name_t("item_text_color"), item_text_color); get_value(parameters, static_name_t("signal_id"), signal_id); get_value(parameters, static_name_t("allowed_drop_types"), allowed_drop_types); GG::Flags<GG::ListBoxStyle> style; if (!sort) style |= GG::LIST_NOSORT; get_sort_order_style(sort_order, style); get_selection_style(selections, style); if (user_delete) style |= GG::LIST_USERDELETE; if (browse_updates) style |= GG::LIST_BROWSEUPDATES; for (array_t::iterator first(items.begin()), last(items.end()); first != last; ++first) { item_set.push_back(any_regular_t(first->cast<dictionary_t>())); dictionary_t& back = item_set.back().cast<dictionary_t>(); get_value(back, key_value); dictionary_t::iterator it = back.find(key_name); if (it != back.end() && it->second.type_info() == type_info<adobe::string_t>()) { it->second.assign(localization_invoke(it->second.cast<std::string>())); } } if (!rows && items.empty()) rows = 8; std::vector<std::string> drop_types; for (array_t::iterator first(allowed_drop_types.begin()), last(allowed_drop_types.end()); first != last; ++first) { drop_types.push_back(first->cast<std::string>()); } listbox = new listbox_t(name, alt_text, characters, rows, style, item_set, color, interior_color, hilite_color, label_color, item_text_color, drop_types, signal_id); }