From 2d19b297a98d8be87c487f6b93e098dce9ca908c Mon Sep 17 00:00:00 2001 From: Paul ProductEngine Date: Fri, 13 May 2011 18:23:11 +0300 Subject: STORM-1202 FIXED Time spin control Implemented time spin control which is like spin control, but shows and allows to edit time string in "hh:mm PM/AM" format. Implemented according to the WLRS spec. --- indra/llui/lltimectrl.h | 125 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 125 insertions(+) create mode 100644 indra/llui/lltimectrl.h (limited to 'indra/llui/lltimectrl.h') diff --git a/indra/llui/lltimectrl.h b/indra/llui/lltimectrl.h new file mode 100644 index 0000000000..81d4477da4 --- /dev/null +++ b/indra/llui/lltimectrl.h @@ -0,0 +1,125 @@ +/** + * @file lltimectrl.h + * @brief Time control + * + * $LicenseInfo:firstyear=2002&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2011, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#ifndef LLTIMECTRL_H_ +#define LLTIMECTRL_H_ + +#include "stdtypes.h" +#include "llbutton.h" +#include "v4color.h" +#include "llrect.h" + +class LLLineEditor; + +class LLTimeCtrl +: public LLUICtrl +{ +public: + struct Params : public LLInitParam::Block + { + Optional label_width; + Optional allow_text_entry; + + Optional text_enabled_color; + Optional text_disabled_color; + + Optional up_button; + Optional down_button; + + Params(); + }; +protected: + LLTimeCtrl(const Params&); + friend class LLUICtrlFactory; + + U32 getHours() const { return mHours; } + U32 getMinutes() const { return mMinutes; } + +private: + + enum EDayPeriod + { + AM, + PM + }; + + enum EEditingPart + { + HOURS, + MINUTES, + DAYPART, + NONE + }; + + virtual void onFocusLost(); + virtual BOOL handleKeyHere(KEY key, MASK mask); + + void onUpBtn(); + void onDownBtn(); + + void onTextEntry(LLLineEditor* line_editor); + + void validateHours(const LLWString& wstr); + void validateMinutes(const LLWString& wstr); + bool isTimeStringValid(const LLWString& wstr); + + bool isPMAMStringValid(const LLWString& wstr); + bool isHoursStringValid(const LLWString& wstr); + bool isMinutesStringValid(const LLWString& wstr); + + LLWString getHoursWString(const LLWString& wstr); + LLWString getMinutesWString(const LLWString& wstr); + + void increaseMinutes(); + void increaseHours(); + + void decreaseMinutes(); + void decreaseHours(); + + void switchDayPeriod(); + + void buildTimeString(); + + EEditingPart getEditingPart(); + + class LLTextBox* mLabelBox; + + class LLLineEditor* mEditor; + LLUIColor mTextEnabledColor; + LLUIColor mTextDisabledColor; + + class LLButton* mUpBtn; + class LLButton* mDownBtn; + + U32 mHours; + U32 mMinutes; + EDayPeriod mCurrentDayPeriod; + + std::string mTimeString; + + BOOL mAllowEdit; +}; +#endif /* LLTIMECTRL_H_ */ -- cgit v1.2.3 From 657e434fd59139436e8b97e5ecd01ca686e82269 Mon Sep 17 00:00:00 2001 From: Vadim ProductEngine Date: Mon, 30 May 2011 22:34:56 +0300 Subject: STORM-1253 WIP New day cycle editor. Done: * Creating new local day cycles. * Editing existing local day cycles. * Deleting day cycles. To do: * Editing region day cycle, dealing with skies in region scope. * Handle teleport while editing a day cycle. * Update UI when a day cycle or sky preset gets deleted. * Make the time ctrl increase/decrease consistently. --- indra/llui/lltimectrl.h | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'indra/llui/lltimectrl.h') diff --git a/indra/llui/lltimectrl.h b/indra/llui/lltimectrl.h index 81d4477da4..aebc5b6eab 100644 --- a/indra/llui/lltimectrl.h +++ b/indra/llui/lltimectrl.h @@ -37,6 +37,7 @@ class LLLineEditor; class LLTimeCtrl : public LLUICtrl { + LOG_CLASS(LLTimeCtrl); public: struct Params : public LLInitParam::Block { @@ -51,13 +52,17 @@ public: Params(); }; + + F32 getTime24() const; // 0.0 - 24.0 + U32 getHours24() const; // 0 - 23 + U32 getMinutes() const; // 0 - 59 + + void setTime24(F32 time); // 0.0 - 23.98(3) + protected: LLTimeCtrl(const Params&); friend class LLUICtrlFactory; - U32 getHours() const { return mHours; } - U32 getMinutes() const { return mMinutes; } - private: enum EDayPeriod @@ -101,7 +106,7 @@ private: void switchDayPeriod(); - void buildTimeString(); + void updateText(); EEditingPart getEditingPart(); @@ -114,11 +119,9 @@ private: class LLButton* mUpBtn; class LLButton* mDownBtn; - U32 mHours; - U32 mMinutes; - EDayPeriod mCurrentDayPeriod; - - std::string mTimeString; + U32 mHours; // 1 - 12 + U32 mMinutes; // 0 - 59 + EDayPeriod mCurrentDayPeriod; // AM/PM BOOL mAllowEdit; }; -- cgit v1.2.3 From af1b7a4ac87f81b56fe1ff49d29c6bd7c3bffa9c Mon Sep 17 00:00:00 2001 From: Vadim ProductEngine Date: Wed, 1 Jun 2011 16:53:19 +0300 Subject: STORM-1253 WIP Time control: the up/down buttons now work consistently across the whole day; time values are snapped to 5 minutes. --- indra/llui/lltimectrl.h | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) (limited to 'indra/llui/lltimectrl.h') diff --git a/indra/llui/lltimectrl.h b/indra/llui/lltimectrl.h index aebc5b6eab..b5f268c76a 100644 --- a/indra/llui/lltimectrl.h +++ b/indra/llui/lltimectrl.h @@ -42,6 +42,7 @@ public: struct Params : public LLInitParam::Block { Optional label_width; + Optional snap_to; Optional allow_text_entry; Optional text_enabled_color; @@ -84,32 +85,35 @@ private: void onUpBtn(); void onDownBtn(); - void onTextEntry(LLLineEditor* line_editor); - void validateHours(const LLWString& wstr); - void validateMinutes(const LLWString& wstr); bool isTimeStringValid(const LLWString& wstr); - bool isPMAMStringValid(const LLWString& wstr); - bool isHoursStringValid(const LLWString& wstr); - bool isMinutesStringValid(const LLWString& wstr); - - LLWString getHoursWString(const LLWString& wstr); - LLWString getMinutesWString(const LLWString& wstr); - void increaseMinutes(); void increaseHours(); void decreaseMinutes(); void decreaseHours(); + bool isPM() const; void switchDayPeriod(); void updateText(); EEditingPart getEditingPart(); + static std::string getHoursString(const std::string& str); + static std::string getMinutesString(const std::string& str); + static std::string getAMPMString(const std::string& str); + + static bool isHoursStringValid(const std::string& str); + static bool isMinutesStringValid(const std::string& str); + static bool isPMAMStringValid(const std::string& str); + + static U32 parseHours(const std::string& str); + static U32 parseMinutes(const std::string& str); + static bool parseAMPM(const std::string& str); + class LLTextBox* mLabelBox; class LLLineEditor* mEditor; @@ -119,9 +123,8 @@ private: class LLButton* mUpBtn; class LLButton* mDownBtn; - U32 mHours; // 1 - 12 - U32 mMinutes; // 0 - 59 - EDayPeriod mCurrentDayPeriod; // AM/PM + U32 mTime; // minutes since midnight: 0 - 1439 + U32 mSnapToMin; // interval in minutes to snap to BOOL mAllowEdit; }; -- cgit v1.2.3