Subversion Repositories tpanel

Rev

Rev 17 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 17 Rev 21
Line 32... Line 32...
32
#include "tpalette.h"
32
#include "tpalette.h"
33
#include "tcolor.h"
33
#include "tcolor.h"
34
#include "tfont.h"
34
#include "tfont.h"
35
#include "tamxnet.h"
35
#include "tamxnet.h"
36
#include "ttimer.h"
36
#include "ttimer.h"
-
 
37
#include "timagerefresh.h"
37
 
38
 
38
#define ORD_ELEM_COUNT  5
39
#define ORD_ELEM_COUNT  5
39
 
40
 
-
 
41
extern bool prg_stopped;
-
 
42
 
40
class SkFont;
43
class SkFont;
-
 
44
struct RESOURCE_T;
41
 
45
 
42
namespace Button
46
namespace Button
43
{
47
{
44
    typedef enum BUTTONTYPE
48
    typedef enum BUTTONTYPE
45
    {
49
    {
Line 225... Line 229...
225
        int top{1};
229
        int top{1};
226
        bool overflow{false};
230
        bool overflow{false};
227
        bool valid{false};
231
        bool valid{false};
228
    }POSITION_t;
232
    }POSITION_t;
229
 
233
 
-
 
234
    typedef struct THR_REFRESH_t
-
 
235
    {
-
 
236
        ulong handle{0};
-
 
237
        ulong parent{0};
-
 
238
        int bi{0};
-
 
239
        TImageRefresh *mImageRefresh{nullptr};
-
 
240
        THR_REFRESH_t *next{nullptr};
-
 
241
    }THR_REFRESH_t;
-
 
242
 
230
    class TButton
243
    class TButton
231
    {
244
    {
232
        public:
245
        public:
233
            TButton();
246
            TButton();
234
            ~TButton();
247
            ~TButton();
Line 310... Line 323...
310
            bool setWorWrap(bool state, int instance);
323
            bool setWorWrap(bool state, int instance);
311
            bool setFont(int id, int instance);
324
            bool setFont(int id, int instance);
312
            void setTop(int top);
325
            void setTop(int top);
313
            void setLeft(int left);
326
            void setLeft(int left);
314
            void setLeftTop(int left, int top);
327
            void setLeftTop(int left, int top);
-
 
328
            void setResourceName(const std::string& name, int instance);
315
            void addPushFunction(std::string& func, std::string& page);
329
            void addPushFunction(std::string& func, std::string& page);
316
            void registerSystemButton();
330
            void registerSystemButton();
317
            bool isSystemButton();
331
            bool isSystemButton();
318
            void clearPushFunctions() { pushFunc.clear(); }
332
            void clearPushFunctions() { pushFunc.clear(); }
319
            void clearPushFunction(const std::string& action);
333
            void clearPushFunction(const std::string& action);
Line 396... Line 410...
396
            {
410
            {
397
                _displayButton = displayButton;
411
                _displayButton = displayButton;
398
            }
412
            }
399
            void registerCallbackFT(std::function<void (ulong handle, const std::string& text, const std::string& font, const std::string& family, int size, int x, int y, ulong color, ulong effectColor, FONT_STYLE style, TEXT_ORIENTATION ori, TEXT_EFFECT effect, bool ww)> setText)
413
            void registerCallbackFT(std::function<void (ulong handle, const std::string& text, const std::string& font, const std::string& family, int size, int x, int y, ulong color, ulong effectColor, FONT_STYLE style, TEXT_ORIENTATION ori, TEXT_EFFECT effect, bool ww)> setText)
400
            { _setText = setText; }
414
            { _setText = setText; }
-
 
415
            void regCallPlayVideo(std::function<void (ulong handle, ulong parent, int left, int top, int width, int height, const std::string& url, const std::string& user, const std::string& pw)> playVideo) { _playVideo = playVideo; };
401
 
416
 
402
            /**
417
            /**
403
             * Make a pixel array and call the callback function to display the
418
             * Make a pixel array and call the callback function to display the
404
             * image. If there is no callback function registered, nothing
419
             * image. If there is no callback function registered, nothing
405
             * happens.
420
             * happens.
Line 487... Line 502...
487
            FEEDBACK getButtonFeedback(const std::string& fb);
502
            FEEDBACK getButtonFeedback(const std::string& fb);
488
            SkBitmap drawImageButton(SkBitmap& imgRed, SkBitmap& imgMask, int width, int height, SkColor col1, SkColor col2);
503
            SkBitmap drawImageButton(SkBitmap& imgRed, SkBitmap& imgMask, int width, int height, SkColor col1, SkColor col2);
489
 
504
 
490
            void funcTimer(const amx::ANET_BLINK& blink);
505
            void funcTimer(const amx::ANET_BLINK& blink);
491
            void funcNetwork(int state);
506
            void funcNetwork(int state);
-
 
507
            void funcResource(const RESOURCE_T *resource, const std::string& url, SkBitmap* bm, int instance);
492
 
508
 
493
        private:
509
        private:
494
            typedef struct IMAGE_t
510
            typedef struct IMAGE_t
495
            {
511
            {
496
                int number{0};
512
                int number{0};
Line 505... Line 521...
505
                }
521
                }
506
            }IMAGE_t;
522
            }IMAGE_t;
507
 
523
 
508
            std::function<void (ulong handle, ulong parent, unsigned char *buffer, int width, int height, int pixline, int left, int top)> _displayButton{nullptr};
524
            std::function<void (ulong handle, ulong parent, unsigned char *buffer, int width, int height, int pixline, int left, int top)> _displayButton{nullptr};
509
            std::function<void (ulong handle, const std::string& text, const std::string& font, const std::string& family, int size, int x, int y, ulong color, ulong effectColor, FONT_STYLE style, TEXT_ORIENTATION ori, TEXT_EFFECT effect, bool ww)> _setText{nullptr};
525
            std::function<void (ulong handle, const std::string& text, const std::string& font, const std::string& family, int size, int x, int y, ulong color, ulong effectColor, FONT_STYLE style, TEXT_ORIENTATION ori, TEXT_EFFECT effect, bool ww)> _setText{nullptr};
-
 
526
            std::function<void (ulong handle, ulong parent, int left, int top, int width, int height, const std::string& url, const std::string& user, const std::string& pw)> _playVideo{nullptr};
510
 
527
 
511
            POSITION_t calcImagePosition(int width, int height, CENTER_CODE cc, int number);
528
            POSITION_t calcImagePosition(int width, int height, CENTER_CODE cc, int number);
512
            int getBorderSize(const std::string& name);
529
            int getBorderSize(const std::string& name);
513
            void calcImageSizePercent(int imWidth, int imHeight, int btWidth, int btHeight, int btFrame, int *realX, int *realY);
530
            void calcImageSizePercent(int imWidth, int imHeight, int btWidth, int btHeight, int btFrame, int *realX, int *realY);
514
            SkColor baseColor(SkColor basePix, SkColor maskPix, SkColor col1, SkColor col2);
531
            SkColor baseColor(SkColor basePix, SkColor maskPix, SkColor col1, SkColor col2);
Line 520... Line 537...
520
            void runAnimation();    // Method started as thread for button animation
537
            void runAnimation();    // Method started as thread for button animation
521
 
538
 
522
            void getDrawOrder(const std::string& sdo, DRAW_ORDER *order);
539
            void getDrawOrder(const std::string& sdo, DRAW_ORDER *order);
523
            bool buttonFill(SkBitmap *bm, int instance);
540
            bool buttonFill(SkBitmap *bm, int instance);
524
            bool buttonBitmap(SkBitmap *bm, int instance);
541
            bool buttonBitmap(SkBitmap *bm, int instance);
-
 
542
            bool buttonDynamic(SkBitmap *bm, int instance);
525
            bool buttonIcon(SkBitmap *bm, int instance);
543
            bool buttonIcon(SkBitmap *bm, int instance);
526
            bool buttonText(SkBitmap *bm, int instance);
544
            bool buttonText(SkBitmap *bm, int instance);
527
            bool buttonBorder(SkBitmap *bm, int instance);
545
            bool buttonBorder(SkBitmap *bm, int instance);
528
            bool isClickable();
546
            bool isClickable();
529
            bool isPixelTransparent(int x, int y);
547
            bool isPixelTransparent(int x, int y);
530
            bool barLevel(SkBitmap *bm, int instance, int level);
548
            bool barLevel(SkBitmap *bm, int instance, int level);
531
            bool makeElement(int instance=-1);
549
            bool makeElement(int instance=-1);
-
 
550
            bool loadImage(SkBitmap *bm, SkBitmap& image, int instance);
532
            void _TimerCallback(ulong counter);
551
            void _TimerCallback(ulong counter);
-
 
552
            void _imageRefresh(const std::string& url);
-
 
553
            static THR_REFRESH_t *_addResource(TImageRefresh *refr, ulong handle, ulong parent, int bi);
-
 
554
            static THR_REFRESH_t *_findResource(ulong handle, ulong parent, int bi);
533
 
555
 
534
            BUTTONTYPE type;
556
            BUTTONTYPE type;
535
            int bi{0};              // button ID
557
            int bi{0};              // button ID
536
            std::string na;         // name
558
            std::string na;         // name
537
            std::string bd;         // Description --> ignored
559
            std::string bd;         // Description --> ignored
Line 586... Line 608...
586
            TFont *mFonts{nullptr}; // The font table
608
            TFont *mFonts{nullptr}; // The font table
587
            int mGlobalOO{-1};      // Opacity of the whole subpage, if any
609
            int mGlobalOO{-1};      // Opacity of the whole subpage, if any
588
            int mActInstance{0};    // Active instance
610
            int mActInstance{0};    // Active instance
589
            DRAW_ORDER mDOrder[ORD_ELEM_COUNT];  // The order to draw the elements of a button
611
            DRAW_ORDER mDOrder[ORD_ELEM_COUNT];  // The order to draw the elements of a button
590
            std::thread mThrAni;    // Thread handle for animation
612
            std::thread mThrAni;    // Thread handle for animation
-
 
613
            std::thread mThrRes;    // A resouce (download of a remote image/video) running in background
591
            static std::atomic<bool> mAniRunning; // TRUE = Animation is running
614
            static std::atomic<bool> mAniRunning; // TRUE = Animation is running
592
            int mLastLevel{0};      // The last level value for a bargraph
615
            int mLastLevel{0};      // The last level value for a bargraph
593
            bool mSystemReg{false}; // TRUE = registered as system button
616
            bool mSystemReg{false}; // TRUE = registered as system button
594
            amx::ANET_BLINK mLastBlink; // This is used for the system clock buttons
617
            amx::ANET_BLINK mLastBlink; // This is used for the system clock buttons
595
            TTimer *mTimer{nullptr};
618
            TTimer *mTimer{nullptr};    // This is for buttons displaying the time or a date. It's a thread running in background.
-
 
619
            static THR_REFRESH_t *mThrRefresh;  // If  we have a source to reread periodicaly, this starts a thread to do that.
-
 
620
            bool mResourceRead{false};  // TRUE if the resource should be read only once on startup and this is done.
596
    };
621
    };
597
 
622
 
598
    typedef struct BUTTONS_T
623
    typedef struct BUTTONS_T
599
    {
624
    {
600
        TButton *button{nullptr};
625
        TButton *button{nullptr};