Added top toolbar options
This commit is contained in:
parent
fc8f414b67
commit
fd2ce71db6
12 changed files with 205 additions and 46 deletions
|
|
@ -291,9 +291,14 @@ void left_right_offset_setup(GUIManager& gui, float dropdownHeight, Clay_Floatin
|
|||
offsetY = gui.io.safeWindowRect.min.y();
|
||||
else if(offsetY + dropdownHeight > gui.io.safeWindowRect.max.y())
|
||||
offsetY -= (offsetY + dropdownHeight) - gui.io.safeWindowRect.max.y();
|
||||
float offsetX = 0.0f;
|
||||
if(isRightSide)
|
||||
offsetX = bb.max.x() + d.dropdownOffset;
|
||||
else
|
||||
offsetX = bb.min.x() - d.entrySize.x() - d.dropdownOffset;
|
||||
floatConfig = {
|
||||
.offset = {
|
||||
.x = isRightSide ? bb.max.x() + d.dropdownOffset : bb.min.x() - bb.width() - d.dropdownOffset,
|
||||
.x = offsetX,
|
||||
.y = offsetY
|
||||
},
|
||||
.zIndex = gui.get_z_index(),
|
||||
|
|
@ -306,9 +311,10 @@ void left_right_offset_setup(GUIManager& gui, float dropdownHeight, Clay_Floatin
|
|||
maxHeight = gui.io.safeWindowRect.height();
|
||||
}
|
||||
|
||||
void dropdown_many_element_popup_layout(GUIManager& gui, const char* id, const DropDownPopupLayout& d) {
|
||||
void dropdown_many_element_popup_layout(GUIManager& gui, const char* id, DropDownPopupLayout d) {
|
||||
if(!d.button->get_bb().has_value())
|
||||
return;
|
||||
d.entrySize.x() = std::min(d.entrySize.x(), gui.io.windowSize.x());
|
||||
gui.element<LayoutElement>(id, [&](LayoutElement* l, const Clay_ElementId& lId) {
|
||||
float dropdownHeight = d.entrySize.y() * d.entryCount + d.dropdownOffset;
|
||||
Clay_FloatingElementConfig floatConfig;
|
||||
|
|
|
|||
|
|
@ -50,6 +50,6 @@ struct DropDownPopupLayout {
|
|||
std::function<void(size_t i)> entryLayout;
|
||||
};
|
||||
|
||||
void dropdown_many_element_popup_layout(GUIManager& gui, const char* id, const DropDownPopupLayout& d);
|
||||
void dropdown_many_element_popup_layout(GUIManager& gui, const char* id, DropDownPopupLayout d);
|
||||
|
||||
}}
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ template <typename T, typename OptT> TextBoxData<T> textbox_options_to_data(cons
|
|||
toRet.onEnter = options.onEnter;
|
||||
toRet.onEdit = options.onEdit;
|
||||
toRet.immutable = options.immutable;
|
||||
toRet.decorations = options.decorations;
|
||||
toRet.onSelect = options.onSelect;
|
||||
toRet.onDeselect = options.onDeselect;
|
||||
toRet.emptyText = options.emptyText;
|
||||
|
|
@ -37,6 +38,7 @@ template <typename T, typename OptT> TextBoxData<T> textbox_options_to_data(cons
|
|||
|
||||
struct TextBoxOptions {
|
||||
bool immutable = false;
|
||||
bool decorations = true;
|
||||
std::string emptyText;
|
||||
std::function<void()> onEnter;
|
||||
std::function<void()> onEdit;
|
||||
|
|
@ -47,6 +49,7 @@ struct TextBoxOptions {
|
|||
struct TextBoxScalarOptions {
|
||||
int decimalPrecision = 0;
|
||||
bool immutable = false;
|
||||
bool decorations = true;
|
||||
std::string emptyText;
|
||||
std::function<void()> onEnter;
|
||||
std::function<void()> onEdit;
|
||||
|
|
@ -57,6 +60,7 @@ struct TextBoxScalarOptions {
|
|||
struct TextBoxScalarsOptions {
|
||||
int decimalPrecision = 0;
|
||||
bool immutable = false;
|
||||
bool decorations = true;
|
||||
std::string emptyText;
|
||||
std::function<void(size_t)> onEnter;
|
||||
std::function<void(size_t)> onEdit;
|
||||
|
|
@ -67,6 +71,7 @@ struct TextBoxScalarsOptions {
|
|||
struct TextBoxPathOptions {
|
||||
std::filesystem::file_type fileTypeRestriction;
|
||||
bool immutable = false;
|
||||
bool decorations = true;
|
||||
std::string emptyText;
|
||||
std::function<void()> onEnter;
|
||||
std::function<void()> onEdit;
|
||||
|
|
@ -77,6 +82,7 @@ struct TextBoxPathOptions {
|
|||
struct TextBoxHexColorOptions {
|
||||
bool hasAlpha = true;
|
||||
bool immutable = false;
|
||||
bool decorations = true;
|
||||
std::string emptyText;
|
||||
std::function<void()> onEnter;
|
||||
std::function<void()> onEdit;
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ template <typename T> struct TextBoxData {
|
|||
std::function<std::string(const T&)> toStr;
|
||||
bool singleLine = true;
|
||||
bool immutable = false;
|
||||
bool decorations = true;
|
||||
InputManager::TextInputProperties textInputProps;
|
||||
std::string emptyText;
|
||||
std::function<void()> onEdit;
|
||||
|
|
|
|||
|
|
@ -66,14 +66,16 @@ template <typename T> void TextBox<T>::clay_draw(SkCanvas* canvas, UpdateInputDa
|
|||
canvas->save();
|
||||
SkRect r = SkRect::MakeXYWH(bb.min.x(), bb.min.y(), bb.width(), bb.height());
|
||||
|
||||
canvas->drawRect(r, SkPaint(io.theme->backColor2));
|
||||
SkPaint outline(is_selected() ? io.theme->fillColor1 : io.theme->backColor2);
|
||||
outline.setStroke(true);
|
||||
outline.setStrokeWidth(2.0f);
|
||||
outline.setAntiAlias(skiaAA);
|
||||
canvas->drawRoundRect(r, 2.0f, 2.0f, outline);
|
||||
if(userInfo.decorations) {
|
||||
canvas->drawRect(r, SkPaint(io.theme->backColor2));
|
||||
SkPaint outline(is_selected() ? io.theme->fillColor1 : io.theme->backColor2);
|
||||
outline.setStroke(true);
|
||||
outline.setStrokeWidth(2.0f);
|
||||
outline.setAntiAlias(skiaAA);
|
||||
canvas->drawRoundRect(r, 2.0f, 2.0f, outline);
|
||||
}
|
||||
|
||||
canvas->clipRect(SkRect::MakeXYWH(bb.min.x(), bb.min.y(), bb.width(), bb.height()));
|
||||
canvas->clipRect(r);
|
||||
|
||||
float yOffset = bb.height() * 0.5f;
|
||||
yOffset -= textbox->get_height() * 0.5f;
|
||||
|
|
@ -105,7 +107,6 @@ template <typename T> void TextBox<T>::select() {
|
|||
if(isEmptyText)
|
||||
textbox->clear_text();
|
||||
edit = std::make_unique<RichTextUserInput>(CustomEvents::text_box_get_new_id(), textbox, cur, nullptr);
|
||||
Logger::get().log("INFO", "Select");
|
||||
CustomEvents::emit_event(CustomEvents::RefreshTextBoxInputEvent{});
|
||||
}
|
||||
}
|
||||
|
|
@ -114,7 +115,6 @@ template <typename T> void TextBox<T>::deselect() {
|
|||
if(is_selected()) {
|
||||
edit = nullptr;
|
||||
if(userInfo.onDeselect) userInfo.onDeselect();
|
||||
Logger::get().log("INFO", "Deselect");
|
||||
CustomEvents::emit_event(CustomEvents::RefreshTextBoxInputEvent{});
|
||||
reset_textbox_text();
|
||||
populate_empty_textbox();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue