Static buttons are easier to tap with touch screen
This commit is contained in:
parent
cd45d1e8cd
commit
d9172f4848
5 changed files with 25 additions and 2 deletions
|
|
@ -36,6 +36,12 @@ void ScrollArea::layout(const Clay_ElementId& id, const Options& options) {
|
||||||
},
|
},
|
||||||
.clip = {.horizontal = opts.clipHorizontal, .vertical = opts.clipVertical, .childOffset = {.x = scrollOffset.x(), .y = scrollOffset.y()}}
|
.clip = {.horizontal = opts.clipHorizontal, .vertical = opts.clipVertical, .childOffset = {.x = scrollOffset.x(), .y = scrollOffset.y()}}
|
||||||
}) {
|
}) {
|
||||||
|
if(scrollData.contentDimensions.height > scrollData.scrollContainerDimensions.height) {
|
||||||
|
gui.in_dynamic_area([&] {
|
||||||
|
opts.innerContent({.contentDimensions = contentDimensions, .containerDimensions = containerDimensions, .scrollOffset = &scrollOffset});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
opts.innerContent({.contentDimensions = contentDimensions, .containerDimensions = containerDimensions, .scrollOffset = &scrollOffset});
|
opts.innerContent({.contentDimensions = contentDimensions, .containerDimensions = containerDimensions, .scrollOffset = &scrollOffset});
|
||||||
clamp_scroll();
|
clamp_scroll();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ void SelectableButton::layout(const Clay_ElementId& id, const Data& d) {
|
||||||
SkColor4f backgroundColorHighlight;
|
SkColor4f backgroundColorHighlight;
|
||||||
SkColor4f backgroundColor;
|
SkColor4f backgroundColor;
|
||||||
|
|
||||||
|
inDynamicArea = gui.is_dynamic_area();
|
||||||
instantResponse = d.instantResponse;
|
instantResponse = d.instantResponse;
|
||||||
onClick = [&, this, d] {
|
onClick = [&, this, d] {
|
||||||
if(d.onClickButton)
|
if(d.onClickButton)
|
||||||
|
|
@ -112,7 +113,7 @@ void SelectableButton::input_finger_touch_callback(const InputManager::FingerTou
|
||||||
}
|
}
|
||||||
|
|
||||||
void SelectableButton::input_finger_motion_callback(const InputManager::FingerMotionCallbackArgs& motion) {
|
void SelectableButton::input_finger_motion_callback(const InputManager::FingerMotionCallbackArgs& motion) {
|
||||||
if(isHovering || isHeld) {
|
if((isHovering || isHeld) && (inDynamicArea || !mouseHovering)) {
|
||||||
isHovering = false;
|
isHovering = false;
|
||||||
isHeld = false;
|
isHeld = false;
|
||||||
gui.set_to_layout();
|
gui.set_to_layout();
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,7 @@ class SelectableButton : public Element {
|
||||||
virtual void input_finger_motion_callback(const InputManager::FingerMotionCallbackArgs& motion) override;
|
virtual void input_finger_motion_callback(const InputManager::FingerMotionCallbackArgs& motion) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
bool inDynamicArea = false;
|
||||||
bool instantResponse = false;
|
bool instantResponse = false;
|
||||||
bool isHeld = false;
|
bool isHeld = false;
|
||||||
bool isHovering = false;
|
bool isHovering = false;
|
||||||
|
|
|
||||||
|
|
@ -588,6 +588,17 @@ void GUIManager::clay_error_handler(Clay_ErrorData errorData) {
|
||||||
Logger::get().log("INFO", "[Clay Error] " + std::string(errorData.errorText.chars));
|
Logger::get().log("INFO", "[Clay Error] " + std::string(errorData.errorText.chars));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GUIManager::in_dynamic_area(const std::function<void()>& f) {
|
||||||
|
bool oldDynamicArea = dynamicArea;
|
||||||
|
dynamicArea = true;
|
||||||
|
f();
|
||||||
|
dynamicArea = oldDynamicArea;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool GUIManager::is_dynamic_area() {
|
||||||
|
return dynamicArea;
|
||||||
|
}
|
||||||
|
|
||||||
void GUIManager::new_id(const char* id, const std::function<void()>& f) {
|
void GUIManager::new_id(const char* id, const std::function<void()>& f) {
|
||||||
push_id(id);
|
push_id(id);
|
||||||
f();
|
f();
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,9 @@ class GUIManager {
|
||||||
|
|
||||||
UpdateInputData io;
|
UpdateInputData io;
|
||||||
|
|
||||||
|
void in_dynamic_area(const std::function<void()>& f);
|
||||||
|
bool is_dynamic_area();
|
||||||
|
|
||||||
void new_id(const char* id, const std::function<void()>& f);
|
void new_id(const char* id, const std::function<void()>& f);
|
||||||
void new_id(int64_t id, const std::function<void()>& f);
|
void new_id(int64_t id, const std::function<void()>& f);
|
||||||
|
|
||||||
|
|
@ -139,6 +142,7 @@ class GUIManager {
|
||||||
|
|
||||||
int16_t zIndex = 0;
|
int16_t zIndex = 0;
|
||||||
Element* parentElement = nullptr;
|
Element* parentElement = nullptr;
|
||||||
|
bool dynamicArea = false;
|
||||||
std::optional<SCollision::AABB<float>> clippingRegion;
|
std::optional<SCollision::AABB<float>> clippingRegion;
|
||||||
|
|
||||||
std::function<void()> postCallbackFunc;
|
std::function<void()> postCallbackFunc;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue