Skip to content

Commit

Permalink
It's working(HelloWorld example before second press button)! but fall…
Browse files Browse the repository at this point in the history
…ing & some comments fixes
  • Loading branch information
Egor00f committed Nov 5, 2024
1 parent 754aa14 commit 25f99d2
Show file tree
Hide file tree
Showing 17 changed files with 180 additions and 124 deletions.
7 changes: 1 addition & 6 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,7 @@
}
},

"postCreateCommand":
{
"Install programs": "apt update && apt install fasm p7zip-full wget cmake",
"Install toolchain": "cd /workspaces && git clone https://github.com/Egor00f/kolibrios-gcc-toolchain.git && kolibrios-gcc-toolchain/./install",
"Clone kolibrios repo": "cd /workspaces && git clone https://git.kolibrios.org/KolibriOS/kolibrios.git"
}
"postCreateCommand": "bash .devcontainer/postCreateCommand.sh"


}
7 changes: 7 additions & 0 deletions .devcontainer/postCreateCommand.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apt update
apt install fasm p7zip-full wget cmake

git clone https://github.com/Egor00f/kolibrios-gcc-toolchain.git
kolibrios-gcc-toolchain/./install
cd ..
git clone https://git.kolibrios.org/KolibriOS/kolibrios.git
3 changes: 2 additions & 1 deletion Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,13 @@ kolibrios-gcc-toolchain/./install
Остальные зависимости:
```
apt update
apt install fasm cmake make
apt install fasm cmake
```

### Сама сборка

Сборка:

```
mkdir build
cd build
Expand Down
15 changes: 7 additions & 8 deletions examples/CheckBox/Checkbox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,22 @@ int main()
{
Window window("Checkbox example");

auto frame = window.AddElement(Frame(
std::shared_ptr<Frame> frame(window.AddElement(Frame(
UDim(0.2f, 0.2f),
UDim(0.6f, 0.4f)));
UDim(0.6f, 0.4f))));
frame->SetColor(Globals::SystemColors.work_area);

auto checkbox = window.AddElement(CheckBox(
std::shared_ptr<CheckBox> checkbox(window.AddElement(CheckBox(
UDim(0.1f, 0.25f),
UDim(0.2f, 0.5f)
));
)));
checkbox->SetParent(frame);

auto textLabel = window.AddElement(TextLabel(
std::shared_ptr<TextLabel> textLabel(window.AddElement(TextLabel(
UDim(0.3f, 0.0f),
UDim(0.7f, 1.0f),
"<- checkbox"
));
)));
textLabel->SetParent(frame);

window.RenderAllElements();
Expand Down Expand Up @@ -51,6 +51,5 @@ int main()
}
}


return 0;
}
}
14 changes: 8 additions & 6 deletions examples/HelloWorld/HelloWorld.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,18 @@ int main()
);

// Добавление текстовой метки
TextLabel* label = wndw->AddElement(TextLabel(
std::shared_ptr<TextLabel> label(wndw->AddElement(TextLabel(
UDim(0.0f, 0, 0.0f, 0), // Координаты текстовой метки (самый левый верхний угол окна)
UDim(0.6f, 0, 1.0f, 0), // Рамер текстовой метки (3/5 ширины окна и в полную высоту окна)
"Hello World",
{32, 36} // Размер символов 32x36
)
);
));

// Добавление кнопки
TextButton* button = wndw->AddElement(TextButton(UDim(0.6f, 0, 0.4f, 0), UDim(0.2f, 0, 0.2f, 0)));
std::shared_ptr<TextButton> button(wndw->AddElement(TextButton(UDim(0.6f, 0, 0.4f, 0), UDim(0.2f, 0, 0.2f, 0))));

logger << microlog::LogLevel::Info << "Button ID: " << button->GetId() << std::endl;

// Отрисовка всех элементов, чтоб они были видны
wndw->RenderAllElements();
Expand All @@ -40,12 +42,12 @@ int main()

case Event::Button: // Была нажата какая-то кнопка

if(static_cast<BaseButton*>(wndw->GetPressedButton().get()) == static_cast<BaseButton*>(button))
if(wndw->GetPressedButton().get() == static_cast<BaseButton*>(button.get()))
{
logger << "You Press Button";
logger << "You Press Button" << std::endl;
OS::Notify("You Press Buttons");

label->SetTextColor(Color(rand()));
label->SetTextColor(Color(std::rand()));
}

break;
Expand Down
15 changes: 7 additions & 8 deletions examples/MousePosition/mousePosition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

using namespace KolibriLib;

TextLabel *MousePosAbs;
TextLabel *MousePosRelative;
std::shared_ptr<TextLabel> MousePosAbs;
std::shared_ptr<TextLabel> MousePosRelative;

void update()
{
Expand All @@ -24,17 +24,16 @@ int main()

Window wnd("Mouse Pos");

MousePosAbs = wnd.AddElement(TextLabel(
MousePosAbs.reset(wnd.AddElement(TextLabel(
UDim(0.2f, 0.2f),
UDim(0.6f, 0.2f),
"idk"));
"idk")));
MousePosAbs->SetAlign(TextLabel::Align::Left);


MousePosRelative = wnd.AddElement(TextLabel(
MousePosRelative.reset(wnd.AddElement(TextLabel(
UDim(0.2f, 0.4f),
UDim(0.6f, 0.2f),
"idk"));
"idk")));

wnd.RenderAllElements();

Expand Down Expand Up @@ -73,4 +72,4 @@ int main()
}

return 0;
}
}
18 changes: 12 additions & 6 deletions include/kolibriLib/UI/buttons/ButtonsIDController.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,12 @@ namespace KolibriLib
/**
* @brief Указатели на кнопки, использующие этот ID
*/
std::vector<std::shared_ptr<BaseButton>> pointers;
std::vector<BaseButton*> pointers;

/**
* @brief Конструктор по умолчанию
*/
node() = default;

/**
* @brief Конструктор
Expand All @@ -44,7 +49,7 @@ namespace KolibriLib
* @param Id IS кнопки
* @param p указатель на кнопку
*/
node(ButtonID Id, std::shared_ptr<BaseButton> p);
node(ButtonID Id, BaseButton* p);

node &operator=(const node &) = default;

Expand Down Expand Up @@ -81,21 +86,22 @@ namespace KolibriLib
* @return ID кнопки, который не занят
* @todo Надо оптимизировать алгоритм поиска, а то он кривой и медленный
*/
ButtonID GetFreeButtonID(std::shared_ptr<BaseButton> ptr);
ButtonID GetFreeButtonID(BaseButton* ptr);

/**
* @brief Занять ID кнопки
* @param id ID кнопки
* @param ptr указатель на кнопку
*/
void TakeUpButtonID(const ButtonID &id, std::shared_ptr<BaseButton> ptr);
void TakeUpButtonID(const ButtonID &id, BaseButton* ptr);

/**
* @brief Освободить ID
* @param id ID который нужно освободить
* @param ptr указатель на кнопку, которая занимала этот ID
* @todo Надо оптимизировать алгоритм поиска, а то он кривой и медленный
*/
void FreeButtonID(const ButtonID &id);
void FreeButtonID(const ButtonID &id, BaseButton* ptr);

/**
* @brief Получить список всех занятых ID кнопок
Expand All @@ -116,7 +122,7 @@ namespace KolibriLib
* @param ID ID кнопки
* @return указатель на ту самую кнопку
*/
std::vector<std::shared_ptr<BaseButton>> GetPointerToButton(const ButtonID &ID) const;
std::vector<BaseButton*> GetPointerToButton(const ButtonID &ID) const;

/**
* @brief Убрать лишнее
Expand Down
1 change: 1 addition & 0 deletions include/kolibriLib/UI/buttons/baseButton.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ namespace KolibriLib
mutable bool _status = false;

private:

/**
* @brief Тип кнопки
* @details false - системная кнопка, true кастомная
Expand Down
4 changes: 2 additions & 2 deletions include/kolibriLib/UI/buttons/buttonsBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,9 @@ namespace KolibriLib
* \param id id кнопки
* \param color цвет
*/
inline void DefineButton(const Coord &coord, const Size &size, const ButtonID &id, Colors::Color color = Globals::SystemColors.work_button)
inline void DefineButton(const Coord &coord, const Size &size, ButtonID id, Colors::Color color = Globals::SystemColors.work_button)
{
assert((id == ButtonIDNotSet || id >= ButtonIDEnd) && "Wrong button id!");
assert((id != ButtonIDNotSet || id < ButtonIDEnd));

_ksys_define_button(
static_cast<std::uint32_t>(coord.x),
Expand Down
12 changes: 7 additions & 5 deletions include/kolibriLib/system/os.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ namespace KolibriLib
/// @brief Активность мыши
Mouse = KSYS_EVENT_MOUSE,

/// @brief Программу открыли в дебагере
/// @brief Программу открыли в отладчике
Debug = KSYS_EVENT_DEBUG,

/// @brief Выход
Expand Down Expand Up @@ -229,21 +229,23 @@ namespace KolibriLib
* \brief Запустить программу
* \param AppName Полное имя исполняемого файла
* \param args аргументы. Максимум 256 символов
* @param ec ошибка файловой системы
* @param debug режим дебага
* @param ec код ошибки файловой системы
* @param debug Запустить в режиме отладки
* \return PID запущенной программы
* @return -1 если произошла ошибка
* @note Если процесс запускается как отлаживаемый, он создаётся в замороженном состоянии
*/
Thread::PID Exec(const filesystem::Path &AppName, const std::string &args, filesystem::FilesystemErrors &ec, bool debug = false) noexcept;

/**
* @brief Запустить программу
* @param AppName Полное имя исполняемого файла
* @param args аргументы. Максимум 256 символов
* @param debug режим дебага
* @param debug Запустить в режиме отладки
* \return PID запущенной программы
* @return -1 если произошла ошибка
* @throw Код ошибки файловой системы
* @throw Код ошибки файловой системы (filesystem::FilesystemErrors)
* @note Если процесс запускается как отлаживаемый, он создаётся в замороженном состоянии
*/
Thread::PID Exec(const filesystem::Path &AppName, const std::string &args, bool debug = false);

Expand Down
Loading

0 comments on commit 25f99d2

Please sign in to comment.