-------------------------------------------------------------
#pragma once
#include <string>
#include <unordered_map>
#include <vector>
#include "imgui.h"
class TeacherColorManager {
public:
static TeacherColorManager& getInstance();
ImVec4 getTeacherColor(int teacherIndex);
void setTeacherColor(int teacherIndex, ImVec4 color);
void saveColors();
void loadColors();
private:
TeacherColorManager();
~TeacherColorManager() = default;
TeacherColorManager(const TeacherColorManager&) = delete;
TeacherColorManager& operator=(const TeacherColorManager&) = delete;
std::vector<ImVec4> teacherColors;
std::vector<ImVec4> defaultColors;
std::string colorFilePath;
void initializeDefaultColors();
};
---------
#include "TeacherColorManager.h"
#include <fstream>
#include <iostream> // Hata ayıklama için
TeacherColorManager& TeacherColorManager::getInstance() {
static TeacherColorManager instance;
return instance;
}
TeacherColorManager::TeacherColorManager() {
colorFilePath = "teacher_colors.bin";
initializeDefaultColors();
loadColors();
}
void TeacherColorManager::initializeDefaultColors() {
defaultColors = {
ImVec4(0.90f, 0.90f, 1.00f, 1.0f), // Çok açık mavi
ImVec4(1.00f, 0.90f, 0.90f, 1.0f), // Çok açık kırmızı
ImVec4(0.90f, 1.00f, 0.90f, 1.0f), // Çok açık yeşil
ImVec4(1.00f, 1.00f, 0.90f, 1.0f), // Çok açık sarı
ImVec4(1.00f, 0.90f, 1.00f, 1.0f), // Çok açık magenta
ImVec4(0.90f, 1.00f, 1.00f, 1.0f), // Çok açık cyan
ImVec4(0.80f, 0.80f, 1.00f, 1.0f), // Açık mavi
ImVec4(1.00f, 0.80f, 0.80f, 1.0f), // Açık kırmızı
ImVec4(0.80f, 1.00f, 0.80f, 1.0f), // Açık yeşil
ImVec4(1.00f, 1.00f, 0.80f, 1.0f), // Açık sarı
ImVec4(1.00f, 0.80f, 1.00f, 1.0f), // Açık magenta
ImVec4(0.80f, 1.00f, 1.00f, 1.0f), // Açık cyan
ImVec4(0.70f, 0.70f, 1.00f, 1.0f), // Biraz daha açık mavi
ImVec4(1.00f, 0.70f, 0.70f, 1.0f), // Biraz daha açık kırmızı
ImVec4(0.70f, 1.00f, 0.70f, 1.0f), // Biraz daha açık yeşil
ImVec4(1.00f, 1.00f, 0.70f, 1.0f), // Biraz daha açık sarı
ImVec4(1.00f, 0.70f, 1.00f, 1.0f), // Biraz daha açık magenta
ImVec4(0.70f, 1.00f, 1.00f, 1.0f), // Biraz daha açık cyan
ImVec4(0.65f, 0.65f, 1.00f, 1.0f), // Açık lavanta
ImVec4(1.00f, 0.65f, 0.65f, 1.0f), // Açık şeftali
ImVec4(0.65f, 1.00f, 0.65f, 1.0f), // Açık nane yeşili
ImVec4(1.00f, 1.00f, 0.65f, 1.0f), // Açık krem
ImVec4(1.00f, 0.65f, 1.00f, 1.0f), // Açık orkide
ImVec4(0.65f, 1.00f, 1.00f, 1.0f), // Açık gökyüzü mavisi
ImVec4(0.60f, 0.60f, 1.00f, 1.0f), // Açık menekşe
ImVec4(1.00f, 0.60f, 0.60f, 1.0f), // Açık somon
ImVec4(0.60f, 1.00f, 0.60f, 1.0f), // Açık fıstık yeşili
ImVec4(1.00f, 1.00f, 0.60f, 1.0f), // Açık limon
ImVec4(1.00f, 0.60f, 1.00f, 1.0f), // Açık fuşya
ImVec4(0.60f, 1.00f, 1.00f, 1.0f), // Açık turkuaz
ImVec4(0.55f, 0.55f, 1.00f, 1.0f), // Açık leylak
ImVec4(1.00f, 0.55f, 0.55f, 1.0f), // Açık mercan
ImVec4(0.55f, 1.00f, 0.55f, 1.0f), // Açık deniz köpüğü
ImVec4(1.00f, 1.00f, 0.55f, 1.0f), // Açık mısır püskülü
ImVec4(1.00f, 0.55f, 1.00f, 1.0f), // Açık şeker pembesi
ImVec4(0.55f, 1.00f, 1.00f, 1.0f), // Açık akuamarin
ImVec4(0.50f, 0.50f, 1.00f, 1.0f), // Açık gök mavisi
ImVec4(1.00f, 0.50f, 0.50f, 1.0f), // Açık gül
ImVec4(0.50f, 1.00f, 0.50f, 1.0f), // Açık çimen yeşili
ImVec4(1.00f, 1.00f, 0.50f, 1.0f), // Açık ayçiçeği
ImVec4(1.00f, 0.50f, 1.00f, 1.0f), // Açık orkide
ImVec4(0.50f, 1.00f, 1.00f, 1.0f), // Açık deniz mavisi
ImVec4(0.45f, 0.45f, 1.00f, 1.0f), // Açık eflatun
ImVec4(1.00f, 0.45f, 0.45f, 1.0f), // Açık kiraz çiçeği
ImVec4(0.45f, 1.00f, 0.45f, 1.0f), // Açık lime
ImVec4(1.00f, 1.00f, 0.45f, 1.0f), // Açık kanari sarısı
ImVec4(1.00f, 0.45f, 1.00f, 1.0f), // Açık erik çiçeği
ImVec4(0.45f, 1.00f, 1.00f, 1.0f) // Açık buz mavisi
};
}
ImVec4 TeacherColorManager::getTeacherColor(int teacherIndex) {
if (teacherIndex >= 0) {
if (teacherIndex < teacherColors.size()) {
return teacherColors[teacherIndex];
}
else {
// Eğer teacherColors'da renk yoksa, defaultColors'dan al
ImVec4 defaultColor = defaultColors[teacherIndex % defaultColors.size()];
// Yeni rengi teacherColors'a ekle
setTeacherColor(teacherIndex, defaultColor);
return defaultColor;
}
}
return ImVec4(1.0f, 1.0f, 1.0f, 1.0f); // Hata durumunda beyaz döndür
}
void TeacherColorManager::setTeacherColor(int teacherIndex, ImVec4 color) {
if (teacherIndex >= 0) {
if (teacherIndex >= teacherColors.size()) {
teacherColors.resize(teacherIndex + 1, ImVec4(1.0f, 1.0f, 1.0f, 1.0f));
}
teacherColors[teacherIndex] = color;
saveColors();
}
}
void TeacherColorManager::saveColors() {
std::ofstream file(colorFilePath, std::ios::binary);
if (file.is_open()) {
size_t size = teacherColors.size();
file.write(reinterpret_cast<const char*>(&size), sizeof(size));
file.write(reinterpret_cast<const char*>(teacherColors.data()), size * sizeof(ImVec4));
file.close();
}
else {
std::cerr << "Error: Could not save colors to file." << std::endl;
}
}
void TeacherColorManager::loadColors() {
std::ifstream file(colorFilePath, std::ios::binary);
if (file.is_open()) {
size_t size;
file.read(reinterpret_cast<char*>(&size), sizeof(size));
teacherColors.resize(size);
file.read(reinterpret_cast<char*>(teacherColors.data()), size * sizeof(ImVec4));
file.close();
std::cout << "Colors loaded from file. Total colors: " << size << std::endl;
}
else {
std::cout << "No saved colors found. Using default colors." << std::endl;
teacherColors.clear(); // Varsayılan renkleri kullanmak için teacherColors'ı temizle
}
}
---------------------------------------------------------
//Öğretmenler Content
void OgretmenlerContent() {
static int selectedOgretmenIndex = -1;
static int selectedDersIndex = -1;
ImGui::PushStyleColor(ImGuiCol_ChildBg, ImVec4(1.0f, 1.0f, 1.0f, 1.0f));
ImGui::PushStyleColor(ImGuiCol_TableRowBg, ImVec4(1.0f, 1.0f, 1.0f, 1.0f));
ImGui::PushStyleColor(ImGuiCol_TableRowBgAlt, ImVec4(0.95f, 0.95f, 0.95f, 1.0f));
ImGui::BeginChild("##DersProgrami", ImVec2(0, 580), true);
ImVec2 tableSize = ImVec2(1800, 400);
if (ImGui::BeginTable("##DersProgramiTablosu", 19, ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg | ImGuiTableFlags_SizingFixedFit, tableSize)) {
ImGui::TableSetupColumn("Gün \\ Saat", ImGuiTableColumnFlags_WidthFixed | ImGuiTableColumnFlags_NoClip, 100.0f);
for (int i = 1; i <= 18; i++) {
ImGui::TableSetupColumn(std::to_string(i).c_str(), ImGuiTableColumnFlags_WidthFixed | ImGuiTableColumnFlags_NoClip, 83.0f);
}
ImGui::TableHeadersRow();
const char* gunler[] = { "Pazartesi", "Salı", "Çarşamba", "Perşembe", "Cuma" };
for (int gun = 0; gun < IM_ARRAYSIZE(gunler); gun++) {
ImGui::TableNextRow(ImGuiTableRowFlags_None, 106.0f);
ImGui::TableNextColumn();
ImGui::Text("%s", gunler[gun]);
for (int i = 1; i < 19; i++) {
ImGui::TableNextColumn();
ImVec2 cellPos = ImGui::GetCursorScreenPos();
ImVec2 cellSize = ImVec2(ImGui::GetColumnWidth(), 106.0f);
ImGui::PushID(gun * 100 + i);
if (ImGui::InvisibleButton("##DersEkle", cellSize)) {
if (selectedOgretmenIndex != -1 && selectedDersIndex != -1) {
std::string sinifAdi = siniflarListesi[selectedDersIndex].sinifAdi;
std::string dersAdi = derslerListesi[selectedDersIndex].dersAdi;
std::string ogretmenAdSoyad = ogretmenlerListesi[selectedOgretmenIndex].adSoyad;
std::string hucreIcerigi = sinifAdi + "\n" + dersAdi + "\n" + ogretmenAdSoyad;
dersProgrami.hucresiIcerikleri[gun][i - 1] = hucreIcerigi;
dersProgrami.tablo1[gun][i - 1] = { sinifAdi, dersAdi, ogretmenAdSoyad };
SenkronizeTablolar(gun, i - 1);
DersProgramiExcelKaydet();
}
}
ImGui::PopID();
if (!dersProgrami.hucresiIcerikleri[gun][i - 1].empty()) {
std::istringstream iss(dersProgrami.hucresiIcerikleri[gun][i - 1]);
std::string sinifAdi, dersAdi, ogretmenAdi;
std::getline(iss, sinifAdi);
std::getline(iss, dersAdi);
std::getline(iss, ogretmenAdi);
int ogretmenIndex = -1;
auto ogretmenIt = std::find_if(ogretmenlerListesi.begin(), ogretmenlerListesi.end(),
[&](const OgretmenBilgisi& ogretmen) { return ogretmen.adSoyad == ogretmenAdi; });
if (ogretmenIt != ogretmenlerListesi.end()) {
ogretmenIndex = std::distance(ogretmenlerListesi.begin(), ogretmenIt);
}
ImVec4 cellColor = ImVec4(1.0f, 1.0f, 1.0f, 1.0f);
if (ogretmenIndex != -1) {
cellColor = TeacherColorManager::getInstance().getTeacherColor(ogretmenIndex);
}
ImGui::GetWindowDrawList()->AddRectFilled(
cellPos,
ImVec2(cellPos.x + cellSize.x, cellPos.y + cellSize.y),
ImGui::ColorConvertFloat4ToU32(cellColor)
);
ImGui::PushClipRect(cellPos, ImVec2(cellPos.x + cellSize.x, cellPos.y + cellSize.y), true);
float lineHeight = ImGui::GetTextLineHeight();
float textY = cellPos.y + (cellSize.y - lineHeight * 3) / 2;
const char* lines[] = { sinifAdi.c_str(), dersAdi.c_str(), ogretmenAdi.c_str() };
for (int idx = 0; idx < 3; idx++) {
ImVec2 textPos = ImVec2(cellPos.x + 2.0f, textY + lineHeight * idx);
ImVec2 clipMax = ImVec2(cellPos.x + cellSize.x - 2.0f, textY + lineHeight * (idx + 1));
ImGui::RenderTextClipped(
textPos,
clipMax,
lines[idx],
NULL,
NULL,
ImVec2(0.5f, 0.0f)
);
}
ImGui::PopClipRect();
ImGui::PushID(gun * 100 + i);
ImGui::SetCursorScreenPos(cellPos);
ImGui::InvisibleButton("cell", cellSize);
if (ImGui::IsItemHovered()) {
ImGui::BeginTooltip();
ImGui::TextUnformatted(dersProgrami.hucresiIcerikleri[gun][i - 1].c_str());
ImGui::EndTooltip();
}
ImGui::PopID();
}
}
}
ImGui::EndTable();
}
ImGui::EndChild();
// Sol Bölüm (Öğretmen Listesi)
ImGui::BeginChild("##OgretmenlerChild", ImVec2(800, 300), true);
if (ImGui::BeginTable("##ÖğretmenlerDış", 1, ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg)) {
// Başlığı ortalamak için hücre dolgusunu kullan
ImGui::TableNextRow();
ImGui::TableNextColumn();
float columnWidth = ImGui::GetColumnWidth();
float textWidth = ImGui::CalcTextSize("Öğretmenler").x;
float padding = (columnWidth - textWidth) / 2.0f;
ImGui::SetCursorPosX(ImGui::GetCursorPosX() + padding);
ImGui::Text("Öğretmenler");
if (ImGui::BeginTable("##Öğretmenler", 5, ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg)) {
ImGui::TableSetupColumn("No", ImGuiTableColumnFlags_WidthStretch, 0.2f);
ImGui::TableSetupColumn("Adı Soyadı", ImGuiTableColumnFlags_WidthStretch);
ImGui::TableSetupColumn("Branşı", ImGuiTableColumnFlags_WidthStretch);
ImGui::TableSetupColumn("Sahip Olduğu Ders Sayısı", ImGuiTableColumnFlags_WidthStretch);
ImGui::TableSetupColumn("Geri Kalan Ders Sayısı", ImGuiTableColumnFlags_WidthStretch);
ImGui::TableHeadersRow();
for (int i = 0; i < ogretmenlerListesi.size(); i++) {
ImGui::TableNextRow();
ImGui::PushID(i);
ImGui::TableNextColumn();
ImVec4 currentColor = TeacherColorManager::getInstance().getTeacherColor(i);
// Renk seçici butonunun boyutunu ayarla
ImVec2 buttonSize(38, 25);
// Renk seçici butonunun konumunu al
ImVec2 buttonPos = ImGui::GetCursorPos();
// Renk seçici butonu
if (ImGui::ColorButton("##color", currentColor, 0, buttonSize)) {
ImGui::OpenPopup("color_picker");
}
// Numarayı renk seçici butonunun ortasına yerleştir
ImGui::SetCursorPos(buttonPos);
char numText[16];
snprintf(numText, sizeof(numText), "%d", i + 1);
ImVec2 textSize = ImGui::CalcTextSize(numText);
ImVec2 textPos(
buttonPos.x + (buttonSize.x - textSize.x) * 0.5f,
buttonPos.y + (buttonSize.y - textSize.y) * 0.5f
);
ImGui::SetCursorPos(textPos);
ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(1.0f - currentColor.x, 1.0f - currentColor.y, 1.0f - currentColor.z, 1.0f)); // Kontrast renk
ImGui::Text("%s", numText);
ImGui::PopStyleColor();
if (ImGui::BeginPopup("color_picker")) {
if (ImGui::ColorPicker4("##picker", (float*)¤tColor)) {
TeacherColorManager::getInstance().setTeacherColor(i, currentColor);
}
ImGui::EndPopup();
}
// Tüm satırı kapsayan bir Selectable oluştur
ImGui::SameLine();
ImGui::SetCursorPosX(ImGui::GetCursorPosX() - buttonSize.x);
if (ImGui::Selectable("##row", selectedOgretmenIndex == i, ImGuiSelectableFlags_SpanAllColumns)) {
selectedOgretmenIndex = i;
}
// Seçili satırın arka plan rengini değiştir
if (selectedOgretmenIndex == i) {
ImU32 row_bg_color = ImGui::GetColorU32(ImVec4(0.7f, 0.7f, 0.7f, 1.0f)); // Gri renk
ImGui::TableSetBgColor(ImGuiTableBgTarget_RowBg0, row_bg_color);
}
ImGui::TableNextColumn();
ImGui::Text("%s", ogretmenlerListesi[i].adSoyad.c_str());
ImGui::TableNextColumn();
ImGui::Text("%s", ogretmenlerListesi[i].bransi.c_str());
ImGui::TableNextColumn();
int dersSayisi = 0;
for (const auto& atama : ogretmenDersAtamalari) {
if (atama.ogretmenAdSoyad == ogretmenlerListesi[i].adSoyad) {
dersSayisi++;
}
}
ImGui::Text("%d", dersSayisi);
ImGui::TableNextColumn();
// ... (Geri Kalan Ders Sayısı) ...
ImGui::PopID();
}
ImGui::EndTable();
}
ImGui::EndTable();
}
ImGui::EndChild();
ImGui::SameLine();
ImGui::BeginChild("##OgretmenlerChild1", ImVec2(700, 300), true);
if (ImGui::BeginTable("##ÖğretmenlerDış1", 1, ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg)) {
// Başlığı ortalamak için hücre dolgusunu kullan
ImGui::TableNextRow();
ImGui::TableNextColumn();
float columnWidth = ImGui::GetColumnWidth();
float textWidth = ImGui::CalcTextSize("Sınıfların Dersleri").x;
float padding = (columnWidth - textWidth) / 2.0f;
ImGui::SetCursorPosX(ImGui::GetCursorPosX() + padding);
ImGui::Text("Sınıfların Dersleri");
if (ImGui::BeginTable("##SınıflarınDersleri", 6, ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg)) {
ImGui::TableSetupColumn("Sınıf", ImGuiTableColumnFlags_WidthStretch, 0.3f);
ImGui::TableSetupColumn("Dersin Adı", ImGuiTableColumnFlags_WidthStretch);
ImGui::TableSetupColumn("Kısa Adı", ImGuiTableColumnFlags_WidthStretch, 0.6f);
ImGui::TableSetupColumn("Haftalık saat", ImGuiTableColumnFlags_WidthStretch, 0.7f);
ImGui::TableSetupColumn("Derslik", ImGuiTableColumnFlags_WidthStretch);
ImGui::TableSetupColumn("Atanmayan Saat", ImGuiTableColumnFlags_WidthStretch, 0.7f);
ImGui::TableHeadersRow();
size_t numRows = std::min(siniflarListesi.size(), derslerListesi.size());
for (size_t i = 0; i < numRows; i++) {
ImGui::TableNextRow();
ImGui::PushID(static_cast<int>(i));
ImGui::TableNextColumn();
// Tüm satırı kapsayan bir Selectable oluştur
if (ImGui::Selectable("##row", selectedDersIndex == static_cast<int>(i), ImGuiSelectableFlags_SpanAllColumns)) {
selectedDersIndex = static_cast<int>(i);
}
// Seçili satırın arka plan rengini değiştir
if (selectedDersIndex == static_cast<int>(i)) {
ImU32 row_bg_color = ImGui::GetColorU32(ImVec4(0.7f, 0.7f, 0.7f, 1.0f));
ImGui::TableSetBgColor(ImGuiTableBgTarget_RowBg0, row_bg_color);
}
// Sütun içeriklerini ekle
ImGui::SameLine();
ImGui::Text("%s", siniflarListesi[i].sinifAdi.c_str());
ImGui::TableNextColumn();
ImGui::Text("%s", derslerListesi[i].dersAdi.c_str());
ImGui::TableNextColumn();
ImGui::Text("%s", derslerListesi[i].kisaAdi.c_str());
ImGui::TableNextColumn();
ImGui::Text("%d", derslerListesi[i].haftalikDersSaati);
ImGui::TableNextColumn();
ImGui::Text("%s", derslerListesi[i].yerlestirmeBicimi.c_str());
ImGui::TableNextColumn();
// Atanmayan Saat için veri ekleyin
ImGui::Text("N/A");
ImGui::PopID();
}
ImGui::EndTable();
}
ImGui::EndTable();
}
ImGui::EndChild();
// Onay kutularının durumlarını tutacak boolean değişkenler //// Sonra bunlar esxcel dosyasından çekilecek ve buraya yazılacak!
static bool derslerArasiBosluk = false;
static bool ozellik2 = false;
static int maxSaat = 8;
ImGui::SetNextWindowSize(ImVec2(400, 250), ImGuiCond_FirstUseEver); // Her zaman boyutu ayarla
// Modal pencereyi oluştur
if (ImGui::BeginPopupModal("Özel Ayarlar Penceresi", nullptr, ImGuiWindowFlags_NoResize)) {
// Pencere boyutunu ayarla
ImGui::PushFont(largeFont); // largeFont'u kullanmaya başla
// Arka plan rengi ve stil ayarları
ImGui::PushStyleColor(ImGuiCol_WindowBg, ImVec4(0.9f, 0.9f, 0.9f, 1.0f)); // Açık gri arka plan
ImGui::PushStyleColor(ImGuiCol_FrameBg, ImVec4(0.8f, 0.8f, 0.8f, 1.0f)); // Daha açık gri çerçeve arka planı
ImGui::PushStyleColor(ImGuiCol_CheckMark, ImVec4(0.0f, 0.7f, 0.0f, 1.0f)); // Yeşil tik işareti
// Pencere içeriği buraya
ImGui::Columns(2, "OzellikSutunlari", false); // 2 sütunlu düzen oluştur
ImGui::SetColumnWidth(0, 250); // İlk sütunun genişliğini ayarla
ImGui::Text("1- Öğretmen Programlarında Dersler arasında boşluk olsun mu?");
ImGui::NextColumn();
ImGui::Checkbox("##DerslerArasiBosluk", &derslerArasiBosluk);
ImGui::NextColumn();
ImGui::Text("2- Öğretmen aynı sınıfın birden fazla dersine giriyor ise bu dersler farklı günlerde gelsin mi?");
ImGui::NextColumn();
ImGui::Checkbox("##Ozellik2", &ozellik2);
ImGui::NextColumn();
ImGui::Text("3- Bir öğretmene günde en fazla kaç saat ders verilecek:");
ImGui::NextColumn();
ImGui::InputInt("##MaxSaat", &maxSaat);
ImGui::NextColumn();
ImGui::Columns(1); // Sütunları sıfırla
// Stil ayarlarını geri al
ImGui::PopStyleColor(3);
ImGui::PopFont(); // Font ayarını geri al (varsayılan fonta dön)
if (ImGui::Button("Kapat")) {
ImGui::CloseCurrentPopup();
}
ImGui::EndPopup();
}
ImGui::SameLine();
// Sağ alt köşeye yerleştirmek için
ImGui::BeginChild("##YeniElemanlar", ImVec2(250, 300), true);
// İlk liste
ImGui::BeginChild("##Secenekler", ImVec2(0, 150), true, ImGuiWindowFlags_NoScrollWithMouse);
const char* items[] = { "Girdiği Ders Saati", "Rehber Öğretmeni", "Yönetim Görevi", "Ders Dışı (Egzersiz)", "Belletmenlik", "Sınav", "Gece Ücreti", "Koordinatörlük", "İşletmelerde Beceri Eğitimi", "Atolye Şefliği", "Alan Şefliği", "Formatörlük", "X Alan Adı" };
static int selected = 0;
static float scroll_y = 0.0f;
const float item_height = ImGui::GetTextLineHeightWithSpacing();
const int visible_items = static_cast<int>(ImGui::GetWindowHeight() / item_height);
// Scroll'u yönetmek için
if (ImGui::IsWindowHovered())
{
if (ImGui::GetIO().MouseWheel != 0)
{
int new_selected = selected;
if (ImGui::GetIO().MouseWheel < 0)
{
new_selected = std::min(selected + 1, IM_ARRAYSIZE(items) - 1);
}
else
{
new_selected = std::max(selected - 1, 0);
}
if (new_selected != selected)
{
selected = new_selected;
// Scroll pozisyonunu ayarla
if (selected * item_height < scroll_y)
{
scroll_y = selected * item_height;
}
else if ((selected + 1) * item_height > scroll_y + ImGui::GetWindowHeight())
{
scroll_y = (selected + 1) * item_height - ImGui::GetWindowHeight();
}
}
}
}
// Scroll sınırlarını kontrol et
if (scroll_y < 0) scroll_y = 0;
float max_scroll = (IM_ARRAYSIZE(items) * item_height) - ImGui::GetWindowHeight();
if (scroll_y > max_scroll) scroll_y = max_scroll;
ImGui::SetCursorPosY(ImGui::GetCursorPosY() - scroll_y);
// Sütunları ayarla
float total_width = ImGui::GetWindowWidth();
float no_width = total_width / 4; // "No" sütunu genişliği toplam genişliğin 1/4'ü
ImGui::Columns(2, "MyColumns");
ImGui::SetColumnWidth(0, no_width);
for (int i = 0; i < IM_ARRAYSIZE(items); i++)
{
ImGui::PushID(i);
// Renk seçici için
ImVec4 currentColor = TeacherOlayColorManager::getOlayInstance().getTeacherOlayColor(i);
ImVec2 buttonSize(38, 25);
ImVec2 buttonPos = ImGui::GetCursorPos();
// Renk seçici butonu
if (ImGui::ColorButton("##color", currentColor, 0, buttonSize)) {
ImGui::OpenPopup("color_picker");
}
// Numarayı renk seçici butonunun ortasına yerleştir
ImGui::SetCursorPos(buttonPos);
char numText[16];
snprintf(numText, sizeof(numText), "%d", i + 1);
ImVec2 textSize = ImGui::CalcTextSize(numText);
ImVec2 textPos(
buttonPos.x + (buttonSize.x - textSize.x) * 0.5f,
buttonPos.y + (buttonSize.y - textSize.y) * 0.5f
);
ImGui::SetCursorPos(textPos);
ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(1.0f - currentColor.x, 1.0f - currentColor.y, 1.0f - currentColor.z, 1.0f)); // Kontrast renk
ImGui::Text("%s", numText);
ImGui::PopStyleColor();
if (ImGui::BeginPopup("color_picker")) {
if (ImGui::ColorPicker4("##picker", (float*)¤tColor)) {
TeacherOlayColorManager::getOlayInstance().setTeacherOlayColor(i, currentColor);
}
ImGui::EndPopup();
}
ImGui::NextColumn();
// Selectable için
if (ImGui::Selectable(items[i], selected == i, ImGuiSelectableFlags_SpanAllColumns))
{
selected = i;
}
ImGui::NextColumn();
ImGui::PopID();
}
ImGui::Columns(1);
ImGui::EndChild();
// Butonlar
ImGui::Spacing();
if (ImGui::Button("Geç", ImVec2(120, 0))) {
// Geç butonu işlevi
}
ImGui::SameLine();
if (ImGui::Button("Durdur", ImVec2(120, 0))) {
// Durdur butonu işlevi
}
// Üçüncü tablo
ImGui::Spacing();
if (ImGui::BeginTable("##UcuncuTablo", 2, ImGuiTableFlags_Borders)) {
ImGui::TableNextRow();
ImGui::TableNextColumn(); ImGui::Text("Toplam:");
ImGui::TableNextColumn(); ImGui::Text("()");
ImGui::TableNextRow();
ImGui::TableNextColumn(); ImGui::Text("Yerleşen:");
ImGui::TableNextColumn(); ImGui::Text("()");
ImGui::TableNextRow();
ImGui::TableNextColumn(); ImGui::Text("Kalan:");
ImGui::TableNextColumn(); ImGui::Text("()");
ImGui::EndTable();
}
ImGui::EndChild();
// Butonlar
ImGui::Spacing();
ImGui::Separator();
ImGui::Spacing();
const char* butonlar[] = { "Yazdır", "Öğretmen", "Otomatik", "Rapor", "Özel Ayarlar", "Ayarlar", "Sil", "Düzenle" };
for (int i = 0; i < IM_ARRAYSIZE(butonlar); i++) {
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 5.0f);
if (ImGui::Button(butonlar[i])) {
if (i == 4) { // "Özel Ayarlar" butonu
ImGui::OpenPopup("Özel Ayarlar Penceresi"); // Modal pencereyi aç
}
}
if (i < IM_ARRAYSIZE(butonlar) - 1) ImGui::SameLine();
ImGui::PopStyleVar();
}
ImGui::PopStyleColor(3);
}