Skip to content

Commit

Permalink
Correction du slider, et de la sauvegarde des permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
paxo-rch committed Nov 1, 2024
1 parent db1ea47 commit fc5eb67
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 20 deletions.
3 changes: 2 additions & 1 deletion lib/applications/src/app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ namespace AppManager {
std::string fullname = prefix.size() ? (prefix + "." + dir) : (dir);
libsystem::log("Loading app \"" + fullname + "\".");

std::cout << "path: " << appPath.str() << std::endl;

if (root) {
app = std::make_shared<App>(
Expand All @@ -234,7 +235,7 @@ namespace AppManager {
directory / dir / "manifest.json",
true
);
} else if (allowedFiles.find(appPath.str() + "\n") != std::string::npos) {
} else if (allowedFiles.find((appPath / "app.lua").str() + "\n") != std::string::npos) {
app = std::make_shared<App>(
dir,
storage::Path(directory) / dir / "app.lua",
Expand Down
20 changes: 19 additions & 1 deletion lib/gui/src/elements/Slider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ namespace gui::elements
m_innerTextColor = graphics::constPackRGB565(250, 250, 250); // COLOR_LIGHT_GREY;
m_outerTextColor = COLOR_BLACK;
m_isPercentage = false;
m_hasEvents = true;
}

Slider::~Slider() = default;
Expand Down Expand Up @@ -100,7 +101,24 @@ namespace gui::elements

void Slider::slide()
{
setValue(floor((touchX - getAbsoluteX()) * (m_maxValue - m_minValue) / m_width));
//m_positionValue = (touchX - getAbsoluteX());
//m_Value = (m_positionValue * (m_maxValue - m_minValue)) / m_width + m_minValue;
float value = (touchX - getAbsoluteX()) * (m_maxValue - m_minValue) / m_width + m_minValue;
value = value<m_minValue?m_minValue:value>m_maxValue?m_maxValue:value;

if(m_Value!=value)
{
setValue(value);
m_hasChanged = true;
}
}

void Slider::widgetUpdate()
{
if(widgetPressed == this && (globalPressedState == PressedState::PRESSED || globalPressedState == PressedState::SCROLLX) && touchX >= 0 && touchY >= 0)
{
slide();
}
}

void Slider::render()
Expand Down
4 changes: 4 additions & 0 deletions lib/gui/src/elements/Slider.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,10 @@ namespace gui::elements
* @brief set the value and redraw the slider based on the position clicked
*
*/

void slide();
void widgetUpdate();
bool hasChanged() { return m_hasChanged; m_hasChanged = false; }

private:
uint16_t m_minValue;
Expand All @@ -123,6 +126,7 @@ namespace gui::elements

bool m_displayValue;
bool m_isPercentage;
bool m_hasChanged;

color_t m_innerTextColor;
color_t m_outerTextColor;
Expand Down
11 changes: 2 additions & 9 deletions lib/lua/src/lua_slider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,8 @@ void LuaSlider::onChange(sol::protected_function func)

void LuaSlider::specificUpdate()
{

if (this->widget->isFocused(true))
if (onChangeFunc && widget->hasChanged())
{
int oldValue = widget->getValue();
widget->slide();

if (onChangeFunc && oldValue != widget->getValue())
{
onChangeFunc();
}
onChangeFunc();
}
}
2 changes: 1 addition & 1 deletion storage/sys_apps/settings/app.lua
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ function systemSettings()
end)

local sleepTimeBox = createBox(win2, 100, 73)
local textsleepTime = gui:label(sleepTimeBox, 16, 0, 177, 55)
local textsleepTime = gui:label(sleepTimeBox, 16, 0, 177, 50)
textsleepTime:setFontSize(24)
textsleepTime:setVerticalAlignment(CENTER_ALIGNMENT)
textsleepTime:setText("Veille: " .. int(settings.getStandBySleepTime()/1000) .. "s")
Expand Down
Binary file modified storage/system/config.bfc
Binary file not shown.
11 changes: 3 additions & 8 deletions storage/system/permissions/auth.list
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
./storage/apps/alarme/sub/.task/app.lua
./storage/apps/snake/app.lua
./storage/apps/demineur/app.lua
./storage/apps/phone/app.lua
./storage/apps/calendrier/app.lua
./storage/apps/alarme/sub/.task/app.lua
./storage/apps/alarme/app.lua
./storage/apps/calendrier/app.lua
./storage/apps/messages/app.lua
./storage/apps/phone/app.lua
./storage/apps/demineur/app.lua
./storage/apps/contacts/app.lua
./storage/apps/snake/app.lua
./storage/apps/phone/app.lua
./storage/apps/contacts/app.lua
./storage/apps/calendrier/app.lua
./storage/apps/calculatrice/app.lua

0 comments on commit fc5eb67

Please sign in to comment.