Pencere Odaklanması: "Ek Ders Bağlantısı" penceresi, açıldığında diğer pencerelerin…
- User
Pencere Odaklanması: "Ek Ders Bağlantısı" penceresi, açıldığında diğer pencerelerin önüne geçmeli ve odaklanmalıdır. Ancak, mevcut çözümde, başka bir pencereden bir seçim yapıldığında, "Ek Ders Bağlantısı" penceresi arka plana düşüyor ve seçilen öğe kayboluyor. İstediğiniz, "Ek Ders Bağlantısı" penceresinin açık olduğu sürece odakta kalması ve diğer pencerelerin etkileşimini engellememesi.
Seçim Mantığı: Odaklanma sorununa ek olarak, uyguladığımız çözüm, ana penceredeki ("Window1Content") seçim mantığını da bozuyor. "Ek Ders Bağlantısı" penceresi açıkken, ana penceredeki tabloda seçim yapmak mümkün olmamalı.
modal kullanabilirz popup modal değil ama!!. Ayrıca focus window olayını denedim olmadı ayrıca iyice bozdu programı....
yani ben bu açtıüımız yeni pencerede herhangi bir yere tıklayınca seçili olan ders devre dışı kalıyor. AMA dikkatlice söylemek istiyorum , zaten böyle olması lazım ama sadece ana pencerede child pencerelerede bu özelliğin çalışmaması lazım
void DersDisiPenceresi(bool& open) { ImGuiWindowFlags window_flags = ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoDocking; if (open) { ImGui::Begin("Ders Dışı Bilgileri", &open, window_flags); ImGui::BeginChild("DersDisiChild", ImVec2(500, 350), true, ImGuiWindowFlags_HorizontalScrollbar | ImGuiWindowFlags_AlwaysVerticalScrollbar); static DersDisiBilgisi yeniDersDisi; static char adiInput[256] = ""; static char kisaAdiInput[256] = ""; ImGui::InputText("Adı", adiInput, IM_ARRAYSIZE(adiInput)); ImGui::InputText("Kısa Adı", kisaAdiInput, IM_ARRAYSIZE(kisaAdiInput)); if (ImGui::Button("Ekle")) { yeniDersDisi.no = dersDisiListesi.size() + 1; // Otomatik no ataması yeniDersDisi.dersDisiAdi = adiInput; yeniDersDisi.kisaAdi = kisaAdiInput; dersDisiListesi.push_back(yeniDersDisi); // Input alanlarını temizle adiInput[0] = '\0'; kisaAdiInput[0] = '\0'; } // Tablo (düzenleme ile) if (ImGui::BeginTable("DersDisiTablosu", 3, ImGuiTableFlags_Borders)) { // No sütunu için bir sütun daha eklendi ImGui::TableSetupColumn("No"); ImGui::TableSetupColumn("Adı"); ImGui::TableSetupColumn("Kısa Adı"); ImGui::TableHeadersRow(); for (int i = 0; i < dersDisiListesi.size(); ++i) { ImGui::TableNextRow(); ImGui::TableNextColumn(); ImGui::Text("%d", dersDisiListesi[i].no); // No'yu göster ImGui::TableNextColumn(); ImGui::Text("%s", dersDisiListesi[i].dersDisiAdi.c_str()); ImGui::TableNextColumn(); ImGui::Text("%s", dersDisiListesi[i].kisaAdi.c_str()); } ImGui::EndTable(); } ImGui::EndChild(); ImGui::End(); } } void EkDersBaglantisiPenceresi(bool& open, int& selectedRow) { ImGuiWindowFlags window_flags = ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoDocking; if (open) { ImGui::Begin("Ek Ders Bağlantısı", &open, window_flags); ImGui::BeginChild("EkDersChild", ImVec2(500, 350), true, ImGuiWindowFlags_HorizontalScrollbar | ImGuiWindowFlags_AlwaysVerticalScrollbar); // Child pencere başlangıcı if (selectedRow >= 0 && selectedRow < derslerListesi.size()) { DersBilgisi& seciliDers = derslerListesi[selectedRow]; if (ImGui::BeginCombo("Bağlantı Türü", seciliDers.ekDersBaglantilari[seciliDers.ekDersBaglantiNo].second.c_str())) { for (int i = 0; i < seciliDers.ekDersBaglantilari.size(); ++i) { bool is_selected = (seciliDers.ekDersBaglantiNo == i); if (ImGui::Selectable(seciliDers.ekDersBaglantilari[i].second.c_str(), is_selected)) seciliDers.ekDersBaglantiNo = i; if (is_selected) ImGui::SetItemDefaultFocus(); // Seçilirse otomatik odaklan } ImGui::EndCombo(); } } else { ImGui::Text("Lütfen bir ders seçin."); } ImGui::EndChild(); // Child pencere bitişi ImGui::End(); } } void Window1Content() { static bool showDersDisiWindow = false; static bool showEkDersWindow = false; bool& showEditWindow = GetShowEditWindowRef(); static float buttonX = 390.0f; static float originalButtonX = 390.0f; static float timer = 0.0f; static bool isShaking = false; static bool isShakingEdit = false; static std::string warningMessage = ""; static std::string excelHatalari = ""; static char dersAdi[256] = ""; static char kisaAdi[256] = ""; static int haftalikDersSaati = 0; static char yerlestirmeBicimi[256] = ""; static int selectedRow = -1; static DersBilgisi editingDers; // Yeni eklenen değişkenler static int editingRow = -1; static int editingColumn = -1; static char editBuffer[256] = ""; static bool showEditWarning = false; // Düzenleme uyarısı için değişken static bool blinkErrorCells = false; static float blinkTimer = 0.0f; /*---------------------------------------------------------------------------------*/ ImGui::PushStyleColor(ImGuiCol_ChildBg, ImVec4(1.0f, 1.0f, 1.0f, 1.0f)); // Beyaz renk // Sol tarafta Child Window (Giriş alanları) ImGui::BeginChild("ÜstPanel", ImVec2(0, 210), true); ImGui::Dummy(ImVec2(0.0f, 5.0f)); /*---------------------------------------------------------------------------------*/ ImGui::SetCursorPosX(10); // Metni 10 piksel sağa kaydır ImGui::Text("Dersin Adı:"); // Etiket ekle ImGui::SameLine(); ImGui::PushStyleColor(ImGuiCol_Border, ImVec4(0.0f, 0.0f, 0.0f, 1.0f)); // Siyah renk ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 1.0f); // Kenarlık kalınlığı 2 piksel ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 5.0f); // Köşe yuvarlatma yarıçapı 5 piksel ImGui::PushItemWidth(227); // Giriş alanının genişliğini 150 piksel yap ImGui::InputText("##DersAdiInput", dersAdi, IM_ARRAYSIZE(dersAdi)); ImGui::PopItemWidth(); ImGui::PopStyleVar(2); ImGui::PopStyleColor(); ImGui::SameLine(); if (ImGui::Button("Ders Dışı")) { showDersDisiWindow = !showDersDisiWindow; } DersDisiPenceresi(showDersDisiWindow); ImGui::SameLine(); // Ek Ders Bağlantısı butonu ve penceresi if (ImGui::Button("Ek Ders Bağlantısı")) { showEkDersWindow = !showEkDersWindow; } EkDersBaglantisiPenceresi(showEkDersWindow, selectedRow); /*---------------------------------------------------------------------------------*/ ImGui::PushStyleColor(ImGuiCol_Border, ImVec4(0.0f, 0.0f, 0.0f, 1.0f)); // Siyah renk ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 1.0f); // Kenarlık kalınlığı 2 piksel ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 5.0f); // Köşe yuvarlatma yarıçapı 5 piksel ImGui::SetCursorPosX(10); // Metni 10 piksel sağa kaydır ImGui::Text("Kısa Adı: "); // Etiket ekle ImGui::PushItemWidth(227); ImGui::SameLine(); ImGui::InputText("##KisaAdiInput", kisaAdi, IM_ARRAYSIZE(kisaAdi)); ImGui::PopItemWidth(); ImGui::PopStyleVar(2); ImGui::PopStyleColor(); /*---------------------------------------------------------------------------------*/ ImGui::PushStyleColor(ImGuiCol_Border, ImVec4(0.0f, 0.0f, 0.0f, 1.0f)); // Siyah renk ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 0.5f); // Kenarlık kalınlığı 2 piksel ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 5.0f); // Köşe yuvarlatma yarıçapı 5 piksel ImGui::SetCursorPosX(10); // Metni 10 piksel sağa kaydır ImGui::Text("Haftalık Ders Saati:"); // Etiket ekle ImGui::SameLine(); ImGui::PushItemWidth(180); // Giriş alanının genişliğini 150 piksel yap // Artı ve eksi butonları için yuvarlatma ayarını değiştir ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 10.0f); // Yuvarlatma yarıçapını 10 piksel yap // InputInt'in içindeki butonlar için stil değişikliği yap ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0.8f, 0.8f, 0.8f, 1.0f)); // Buton arka plan rengi ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(0.9f, 0.9f, 0.9f, 1.0f)); // Buton üzerine gelince renk ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4(0.7f, 0.7f, 0.7f, 1.0f)); // Butona tıklayınca renk ImGui::InputInt("##HaftalikDersSaatiInput", &haftalikDersSaati); haftalikDersSaati = std::max(0, haftalikDersSaati); ImGui::PopStyleColor(4); // Buton stil değişikliklerini geri al ImGui::PopStyleVar(3); // Yuvarlatma ayarını varsayılan değerine geri döndür ImGui::PopItemWidth(); /*---------------------------------------------------------------------------------*/ ImGui::PushStyleColor(ImGuiCol_Border, ImVec4(0.0f, 0.0f, 0.0f, 1.0f)); // Siyah renk ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 1.0f); // Kenarlık kalınlığı 2 piksel ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 5.0f); // Köşe yuvarlatma yarıçapı 5 piksel ImGui::SetCursorPosX(10); // Metni 10 piksel sağa kaydır ImGui::Text("Yerleştirme Biçimi:"); // Etiket ekle ImGui::SameLine(); ImGui::PushItemWidth(180); ImGui::InputText("##YerlestirmeBicimiInput", yerlestirmeBicimi, IM_ARRAYSIZE(yerlestirmeBicimi)); ImGui::PopItemWidth(); ImGui::PopStyleColor(); ImGui::PopStyleVar(2); ImGui::PopStyleColor(); // Butonu oluşturun ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1.0f, 0.0f, 0.0f, 0.7f)); // Kırmızı renk if (ImGui::Button("Tablonuzdaki Hatalar")) { showErrorWindow = true; } ImGui::PopStyleColor(); // Butonun yanına hata sayısını yazdırın ImGui::SameLine(); // Butonla aynı satıra yazdır if (excelHatalari.empty()) { ImGui::Text("Şuan hata yok"); } else { int hataSayisi = std::count(excelHatalari.begin(), excelHatalari.end(), '\n') + 0; // Satır sayısını hesapla ImGui::Text("= Var %d tane", hataSayisi); // Hata sayısını yazdır } if (showErrorWindow) { ImGui::Begin("Excel Hataları", &showErrorWindow, ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoDocking); // Excel Hataları Log Penceresi ImGui::SetCursorPosX(10); // Log penceresini input alanının altına hizala ImGui::PushStyleColor(ImGuiCol_ChildBg, ImVec4(0.0f, 0.0f, 0.0f, 0.0f)); // Arka plan rengini şeffaf yap ImGui::BeginChild("ExcelHataLog", ImVec2(500, 350), true, ImGuiWindowFlags_HorizontalScrollbar | ImGuiWindowFlags_AlwaysVerticalScrollbar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoDocking); // Dikey scrollbar her zaman görünsün ImGui::Indent((350 / 2) - 20); ImGui::TextWrapped("Tablonuzdaki Hatalar:"); ImGui::Unindent((350 / 2) - 20); // Eski hizalama ayarlarına geri dön ImGui::Indent(10); // Metni sağa kaydır ImGui::TextWrapped("%s", excelHatalari.c_str()); ImGui::Unindent(10); // Eski hizalama ayarlarına geri dön ImGui::EndChild(); ImGui::PopStyleColor(); // Eski stil ayarlarına geri dön ImGui::End(); } // Her frame'de Excel dosyasını kontrol et DerslerExcelDosyasiniKontrolEt(excelHatalari); if (ImGui::Button("Hataları Yanıp Söndür")) { blinkErrorCells = !blinkErrorCells; // Yanıp sönmeyi başlat/durdur blinkTimer = 0.0f; // Zamanlayıcıyı sıfırla } ImGui::SameLine(); // Butonun yanına eklemek için ImGui::Text("= %s", blinkErrorCells ? "Açık" : "Kapalı"); /*---------------------------------------------------------------------------------*/ ImGui::SetCursorPos(ImVec2(buttonX, 100)); ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 5.0f); if (ImGui::Button("Ekle", ImVec2(100, 100))) { bool showWarning = false; warningMessage = ""; if (dersAdi[0] == '\0') { warningMessage += "Ders adı girilmelidir.\n"; showWarning = true; } // Haftalık ders saatini 0'dan küçük olmaması için kontrol et haftalikDersSaati = std::max(0, haftalikDersSaati); if (haftalikDersSaati == 0) { warningMessage += "Haftalık ders saati girilmelidir.\n"; showWarning = true; } if (yerlestirmeBicimi[0] == '\0') { warningMessage += "Yerleştirme biçimi girilmelidir.\n"; showWarning = true; } // Yerleştirme biçimini kontrol et ve gerekirse dönüştür if (yerlestirmeBicimi[0] != '\0') { bool gecerliYerlestirmeBicimi = true; std::string yerlestirmeStr = yerlestirmeBicimi; size_t pos = 0; std::string token; while ((pos = yerlestirmeStr.find("+")) != std::string::npos) { token = yerlestirmeStr.substr(0, pos); // Token'ın sayı olup olmadığını kontrol et if (!std::all_of(token.begin(), token.end(), ::isdigit)) { gecerliYerlestirmeBicimi = false; break; } yerlestirmeStr.erase(0, pos + 1); } // Son kalan kısmı kontrol et if (!std::all_of(yerlestirmeStr.begin(), yerlestirmeStr.end(), ::isdigit)) { gecerliYerlestirmeBicimi = false; } if (!gecerliYerlestirmeBicimi) { warningMessage += "Geçersiz yerleştirme biçimi.\n"; showWarning = true; } else { // 01 gibi değerleri 1'e dönüştür int toplamYerlestirme = 0; yerlestirmeStr = yerlestirmeBicimi; pos = 0; while ((pos = yerlestirmeStr.find("+")) != std::string::npos) { token = yerlestirmeStr.substr(0, pos); toplamYerlestirme += std::stoi(token); yerlestirmeStr.erase(0, pos + 1); } toplamYerlestirme += std::stoi(yerlestirmeStr); // Yerleştirme biçimi stringini toplam değerle güncelle sprintf(yerlestirmeBicimi, "%d", toplamYerlestirme); // Haftalık ders saati ve yerleştirme biçimi uyuşmasını kontrol et if (haftalikDersSaati != toplamYerlestirme) { warningMessage += "Haftalık ders saati ve yerleştirme biçimi uyuşmuyor.\n"; showWarning = true; } } } if (showWarning) { // Windows uyarı sesi çal MessageBeep(MB_ICONEXCLAMATION); // Butonu titreştir (sadece bir kere) if (!isShaking) { isShaking = true; } } else { DersBilgisi yeniDers; yeniDers.dersAdi = dersAdi; yeniDers.kisaAdi = kisaAdi; yeniDers.haftalikDersSaati = haftalikDersSaati; yeniDers.yerlestirmeBicimi = yerlestirmeBicimi; derslerListesi.push_back(yeniDers); // Input alanlarını temizle memset(dersAdi, 0, sizeof(dersAdi)); memset(kisaAdi, 0, sizeof(kisaAdi)); haftalikDersSaati = 0; memset(yerlestirmeBicimi, 0, sizeof(yerlestirmeBicimi)); std::thread kaydetmeThread(DersleriExcelKaydet); kaydetmeThread.detach(); // Thread'i ayır ve arka planda çalışmasını sağla //Ne olur ne olmaz diye ekledim... Çöktü bir defa belki bunlar olmadığından ama emin değilim... OkutulanDerslerExcelKaydet(); OkutulanDersleriYukleExcel(); } } if (isShaking) { timer += ImGui::GetIO().DeltaTime; if (timer <= 0.2f) { // 0.2 saniye boyunca titreşim buttonX = originalButtonX + 5.0f * sinf(timer * 25.0f); // Daha hızlı titreşim } else { isShaking = false; timer = 0.0f; buttonX = originalButtonX; // Butonu orijinal konumuna geri getir } } if (isShakingEdit) { // Düzenleme penceresi için isShakingEdit kullan timer += ImGui::GetIO().DeltaTime; if (timer <= 0.2f) { buttonX = originalButtonX + 5.0f * sinf(timer * 25.0f); } else { isShakingEdit = false; timer = 0.0f; buttonX = originalButtonX; } } ImGui::SameLine(); if (ImGui::Button("Seçileni Sil", ImVec2(125, 100))) { if (selectedRow >= 0 && selectedRow < derslerListesi.size()) { derslerListesi.erase(derslerListesi.begin() + selectedRow); selectedRow = -1; DersleriExcelKaydet(); } } ImGui::SameLine(); if (ImGui::Button("Seçileni Düzenle", ImVec2(125, 100))) { if (selectedRow >= 0 && selectedRow < derslerListesi.size()) { showEditWindow = true; editingDers = derslerListesi[selectedRow]; } } ImGui::PopStyleVar(); ImGui::EndChild(); ImGui::SameLine(); ImGui::Separator(); ImGui::SetCursorPosX(5); ImGui::PushStyleColor(ImGuiCol_ChildBg, IM_COL32_WHITE); ImGui::BeginChild("TabloChild", ImVec2(0, 560), true, ImGuiWindowFlags_HorizontalScrollbar); bool anyButtonClicked = false; bool isTableAreaClicked = false; if (ImGui::BeginTable("Dersler Tablosu", 6, ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg | ImGuiTableFlags_ScrollY, ImVec2(0, 0))) { ImGui::TableSetupColumn("No", ImGuiTableColumnFlags_WidthFixed, 50.0f); ImGui::TableSetupColumn("Dersin Adı", ImGuiTableColumnFlags_WidthFixed, 200.0f); ImGui::TableSetupColumn("Kısa Adı", ImGuiTableColumnFlags_WidthFixed, 100.0f); ImGui::TableSetupColumn("HDS", ImGuiTableColumnFlags_WidthFixed, 70.0f); ImGui::TableSetupColumn("Yer.Biç.", ImGuiTableColumnFlags_WidthFixed, 100.0f); ImGui::TableSetupColumn("Grubu", ImGuiTableColumnFlags_WidthFixed, 100.0f); ImGui::TableHeadersRow(); for (int i = 0; i < derslerListesi.size(); i++) { ImGui::TableNextRow(); ImVec4 rowColor = (i % 2 == 0) ? ImVec4(0.9f, 0.9f, 0.9f, 1.0f) : ImVec4(1.0f, 1.0f, 1.0f, 1.0f); if (i == selectedRow) { rowColor = ImVec4(0.7f, 0.7f, 1.0f, 1.0f); // Seçili satır için mor renk } ImGui::TableSetBgColor(ImGuiTableBgTarget_RowBg0, ImGui::ColorConvertFloat4ToU32(rowColor)); ImGui::TableNextColumn(); ImGui::Text("%d", i + 1); for (int col = 1; col <= 4; col++) { ImGui::TableNextColumn(); if (editingRow == i && editingColumn == col) { ImGui::PushItemWidth(-1); if (col == 3) { // HDS sütunu int tempValue = derslerListesi[i].haftalikDersSaati; if (ImGui::InputInt("##edit", &tempValue, 0, 0, ImGuiInputTextFlags_EnterReturnsTrue)) { // HDS değerini 0 veya daha büyük bir değerle sınırla std::lock_guard<std::mutex> lock(excelDosyasiMutex); // Mutex kilidi derslerListesi[i].haftalikDersSaati = std::max(0, tempValue); // HDS ve Yerleştirme Biçimi kontrolü if (!CheckYerlestirmeBicimi(derslerListesi[i].haftalikDersSaati, derslerListesi[i].yerlestirmeBicimi)) { showEditWarning = true; } else { showEditWarning = false; } editingRow = -1; editingColumn = -1; std::thread kaydetmeThread(DersleriExcelKaydet); kaydetmeThread.detach(); } } else { // Diğer sütunlar if (ImGui::InputText("##edit", editBuffer, IM_ARRAYSIZE(editBuffer), ImGuiInputTextFlags_EnterReturnsTrue)) { std::lock_guard<std::mutex> lock(excelDosyasiMutex); // Mutex kilidi switch (col) { case 1: derslerListesi[i].dersAdi = editBuffer; break; case 2: derslerListesi[i].kisaAdi = editBuffer; break; case 4: // Yerleştirme Biçimini sadece sayı ve "+" içerecek şekilde sınırla derslerListesi[i].yerlestirmeBicimi = ValidateYerlestirmeBicimi(editBuffer); // HDS ve Yerleştirme Biçimi kontrolü if (!CheckYerlestirmeBicimi(derslerListesi[i].haftalikDersSaati, derslerListesi[i].yerlestirmeBicimi)) { showEditWarning = true; } else { showEditWarning = false; } break; } editingRow = -1; editingColumn = -1; std::thread kaydetmeThread(DersleriExcelKaydet); kaydetmeThread.detach(); } } ImGui::PopItemWidth(); if (!ImGui::IsItemHovered() && ImGui::IsMouseClicked(0)) { editingRow = -1; editingColumn = -1; } } else { std::string id = "##" + std::to_string(col) + "_" + std::to_string(i); bool isHovered = ImGui::IsItemHovered(); if (isHovered) { ImGui::TableSetBgColor(ImGuiTableBgTarget_RowBg0, IM_COL32(173, 216, 230, 255)); // Açık mavi renk } if (ImGui::Selectable(id.c_str(), false, ImGuiSelectableFlags_AllowItemOverlap)) { selectedRow = i; } if (ImGui::IsItemHovered() && ImGui::IsMouseDoubleClicked(0)) { editingRow = i; editingColumn = col; switch (col) { case 1: strcpy(editBuffer, derslerListesi[i].dersAdi.c_str()); break; case 2: strcpy(editBuffer, derslerListesi[i].kisaAdi.c_str()); break; case 3: sprintf(editBuffer, "%d", derslerListesi[i].haftalikDersSaati); break; case 4: strcpy(editBuffer, derslerListesi[i].yerlestirmeBicimi.c_str()); break; } } if (ImGui::IsItemVisible()) { ImGui::SameLine(); if (HucreHataKontrol(i + 1, col, excelHatalari) && blinkErrorCells) { // Yanıp sönme efekti uygula if (static_cast<int>(blinkTimer * 2) % 2 == 0) { ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(1.0f, 0.0f, 0.0f, 1.0f)); // Kırmızı renk } } switch (col) { case 1: ImGui::Text("%s", derslerListesi[i].dersAdi.c_str()); break; case 2: ImGui::Text("%s", derslerListesi[i].kisaAdi.c_str()); break; case 3: ImGui::Text("%d", derslerListesi[i].haftalikDersSaati); break; case 4: ImGui::Text("%s", derslerListesi[i].yerlestirmeBicimi.c_str()); break; } } if (HucreHataKontrol(i + 1, col, excelHatalari) && blinkErrorCells && static_cast<int>(blinkTimer * 2) % 2 == 0) { ImGui::TableSetBgColor(ImGuiTableBgTarget_CellBg, IM_COL32(0, 50, 100, 100)); // Kırmızı arka plan } else { ImGui::TableSetBgColor(ImGuiTableBgTarget_CellBg, ImGui::ColorConvertFloat4ToU32(rowColor)); // Normal arka plan } ImGui::PopStyleColor(); // <-- Bu satırı buraya taşıyın if (isHovered) { ImGui::TableSetBgColor(ImGuiTableBgTarget_RowBg0, ImGui::ColorConvertFloat4ToU32(rowColor)); } } } ImGui::TableNextColumn(); if (ImGui::IsItemVisible()) ImGui::Text(""); // Grubu boş bırakıldı } if (ImGui::IsWindowHovered() && ImGui::IsMouseClicked(0)) { anyButtonClicked = true; } if (anyButtonClicked && !ImGui::IsItemHovered()) { selectedRow = -1; // Seçili satırı sıfırla anyButtonClicked = false; } isTableAreaClicked = ImGui::IsWindowHovered(ImGuiHoveredFlags_ChildWindows); ImGui::EndTable(); } ImGui::EndChild(); ImGui::PopStyleColor(); if (ImGui::IsMouseClicked(0) && !isTableAreaClicked && !ImGui::IsAnyItemHovered()) { selectedRow = -1; } ImGui::PopStyleColor(); // Düzenleme penceresi if (showEditWindow) { ImGui::SetNextWindowSize(ImVec2(750, 250), ImGuiCond_FirstUseEver); // Pencere yapıştırmayı ve boyutlandırmayı devre dışı bırak ImGuiWindowFlags flags = ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoDocking ; static bool isDragging = false; static ImVec2 dragDelta; if (ImGui::Begin("Seçilen Dersi Düzenle", &showEditWindow, flags)) { // Sürükleme için başlık çubuğunu al ImVec2 windowPos = ImGui::GetWindowPos(); float titleBarHeight = ImGui::GetFrameHeight(); ImRect titleBarRect(windowPos, ImVec2(windowPos.x + ImGui::GetWindowWidth(), windowPos.y + titleBarHeight)); // Mouse pozisyonunu al ImVec2 mousePos = ImGui::GetMousePos(); // Başlık çubuğunda tıklama kontrolü if (titleBarRect.Contains(mousePos) && ImGui::IsMouseClicked(0)) { isDragging = true; dragDelta.x = mousePos.x - windowPos.x; // x bileşenini ayrı ayrı çıkar dragDelta.y = mousePos.y - windowPos.y; // y bileşenini ayrı ayrı çıkar } ImGui::PushStyleColor(ImGuiCol_ChildBg, ImVec4(1.0f, 1.0f, 1.0f, 1.0f)); ImGui::BeginChild("ÜstPanel", ImVec2(350, 200), true); ImGui::Dummy(ImVec2(0.0f, 5.0f)); ImGui::SetCursorPosX(10); ImGui::Text("Dersin Adı:"); ImGui::SameLine(); ImGui::PushStyleColor(ImGuiCol_Border, ImVec4(0.0f, 0.0f, 0.0f, 1.0f)); ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 1.0f); ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 5.0f); ImGui::PushItemWidth(227); char tempDersAdi[256]; strcpy(tempDersAdi, editingDers.dersAdi.c_str()); if (ImGui::InputText("##DersAdiInput", tempDersAdi, IM_ARRAYSIZE(tempDersAdi))) { editingDers.dersAdi = tempDersAdi; } ImGui::PopItemWidth(); ImGui::PopStyleVar(2); ImGui::PopStyleColor(); ImGui::SetCursorPosX(10); ImGui::Text("Kısa Adı: "); ImGui::SameLine(); ImGui::PushStyleColor(ImGuiCol_Border, ImVec4(0.0f, 0.0f, 0.0f, 1.0f)); ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 1.0f); ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 5.0f); ImGui::PushItemWidth(227); char tempKisaAdi[256]; strcpy(tempKisaAdi, editingDers.kisaAdi.c_str()); if (ImGui::InputText("##KisaAdiInput", tempKisaAdi, IM_ARRAYSIZE(tempKisaAdi))) { editingDers.kisaAdi = tempKisaAdi; } ImGui::PopItemWidth(); ImGui::PopStyleVar(2); ImGui::PopStyleColor(); ImGui::SetCursorPosX(10); ImGui::Text("Haftalık Ders Saati:"); ImGui::SameLine(); ImGui::PushStyleColor(ImGuiCol_Border, ImVec4(0.0f, 0.0f, 0.0f, 1.0f)); ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 1.0f); ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 5.0f); ImGui::PushItemWidth(180); ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 10.0f); ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0.8f, 0.8f, 0.8f, 1.0f)); ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(0.9f, 0.9f, 0.9f, 1.0f)); ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4(0.7f, 0.7f, 0.7f, 1.0f)); if (ImGui::InputInt("##HaftalikDersSaatiInput", &editingDers.haftalikDersSaati)) { editingDers.haftalikDersSaati = std::max(0, editingDers.haftalikDersSaati); if (!CheckYerlestirmeBicimi(editingDers.haftalikDersSaati, editingDers.yerlestirmeBicimi)) { showEditWarning = true; } else { showEditWarning = false; } } ImGui::PopStyleColor(3); ImGui::PopStyleVar(3); ImGui::PopStyleColor(); ImGui::SetCursorPosX(10); ImGui::Text("Yerleştirme Biçimi:"); ImGui::SameLine(); ImGui::PushStyleColor(ImGuiCol_Border, ImVec4(0.0f, 0.0f, 0.0f, 1.0f)); ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 1.0f); ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 5.0f); ImGui::PushItemWidth(180); char tempYerlestirmeBicimi[256]; strcpy(tempYerlestirmeBicimi, editingDers.yerlestirmeBicimi.c_str()); if (ImGui::InputText("##YerlestirmeBicimiInput", tempYerlestirmeBicimi, IM_ARRAYSIZE(tempYerlestirmeBicimi))) { editingDers.yerlestirmeBicimi = tempYerlestirmeBicimi; // Yerleştirme biçimi değiştiğinde, HDS'yi kontrol et ve gerekirse uyarı göster if (!CheckYerlestirmeBicimi(editingDers.haftalikDersSaati, editingDers.yerlestirmeBicimi)) { showEditWarning = true; } else { showEditWarning = false; } } ImGui::PopItemWidth(); ImGui::PopStyleVar(2); ImGui::PopStyleColor(); ImGui::EndChild(); ImGui::SetCursorPos(ImVec2(400, 50)); ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 5.0f); if (ImGui::Button("Kaydet", ImVec2(100, 50))) { auto future = std::async(std::launch::async, DersleriExcelKaydet); if (selectedRow >= 0 && selectedRow < derslerListesi.size()) { // Kaydetmeden önce doğrulamaları yap bool showWarning = false; warningMessage = ""; if (editingDers.dersAdi[0] == '\0') { warningMessage += "Ders adı girilmelidir.\n"; showWarning = true; } if (editingDers.haftalikDersSaati == 0) { warningMessage += "Haftalık ders saati girilmelidir.\n"; showWarning = true; } if (editingDers.yerlestirmeBicimi[0] == '\0') { warningMessage += "Yerleştirme biçimi girilmelidir.\n"; showWarning = true; } else { if (!CheckYerlestirmeBicimi(editingDers.haftalikDersSaati, editingDers.yerlestirmeBicimi)) { warningMessage += "Haftalık ders saati ve yerleştirme biçimi uyuşmuyor.\n"; showWarning = true; } } if (showWarning) { // Windows uyarı sesi çal MessageBeep(MB_ICONEXCLAMATION); // Butonu titreştir (sadece bir kere) if (!isShakingEdit) { isShakingEdit = true; } } else { derslerListesi[selectedRow] = editingDers; DersleriExcelKaydet(); showEditWindow = false; showEditWarning = false; // Uyarıyı kapat } } } ImGui::SameLine(); if (ImGui::Button("İptal", ImVec2(100, 50))) { showEditWindow = false; showEditWarning = false; // Uyarıyı kapat ImGui::SetWindowFocus(nullptr); // Pencerenin odağını kaldır ImGui::ClearActiveID(); // ImGui'nin aktif ID'sini temizle ImGui::End(); } ImGui::PopStyleVar(); ImGui::SetCursorPos(ImVec2(450, 120)); // Düzenleme uyarısını göster if (showEditWarning) { ImGui::TextWrapped("X numaralı dersin Yer.Biç ve HDS'si aynı değil"); } if (!showEditWindow) { showEditWindow = false; showEditWarning = false; ImGui::SetWindowFocus(nullptr); // Pencerenin odağını kaldır ImGui::ClearActiveID(); // ImGui'nin aktif ID'sini temizle ImGui::End(); } ImGui::End(); } } ImGui::SetCursorPos(ImVec2(400, 40)); ImGui::TextWrapped("%s", warningMessage.c_str()); // Her frame'de yanıp sönme zamanlayıcısını güncelle blinkTimer += ImGui::GetIO().DeltaTime; } - Assistant