/*
 * File: Screen_Mode_Change.c
 *
 * Created: Created: Saturday October 2025 21:07:48
 *   Author: Chris
 */


// ============================================================================================
// Includes
#include "../Screens.h"
#include "../UI_Control.h"
#include "../Mode_Manager.h"

#include "../Display.h"
#include "../Display_Objects.h"
#include "../Display_Default_Configurations.h"

#include "Common_Screen_Elements.h"


// ============================================================================================
// Defines


// ============================================================================================
// Variables
extern const uint16_t _Image_Forest_Pine_Midi_64x64[];
extern const uint16_t _Image_Steel_Blue_Jam_Happy_64x64[];
extern const uint16_t _Image_Stone_Blue_Light_On_64x64[];

static Mode _Mode;
static uint32_t _Counter;


// ============================================================================================
// Function Declarations
void Screen_Setup_Mode_Change(Screen_Transition_Direction direction_out, Screen_Transition_Direction direction_in, Easing type, uint32_t frame_duration, Mode mode);

static void Screen_Init                (Screen_Transition_Direction direction_out, Screen_Transition_Direction direction_in, Easing type, uint32_t frame_duration);
static void Screen_Tick                (void);
static void Screen_Click               (uint button_return_value);
static void Screen_Touch_Event         (int16_t x, int16_t y);
static void Screen_Action_CW           (Object_ID object_id);
static void Screen_Action_CCW          (Object_ID object_id);
static void Screen_On_Object_Focused   (Object_ID object_id);
static void Screen_On_Object_Defocused (Object_ID object_id);
static void Screen_On_Object_Select    (Object_ID object_id);
static void Screen_On_Object_Deselect  (Object_ID object_id);


/*******************************************************************
    Functions
*******************************************************************/
void Screen_Setup_Mode_Change(Screen_Transition_Direction direction_out, Screen_Transition_Direction direction_in, Easing type, uint32_t frame_duration, Mode mode)
{
    _Mode = mode;
    _Counter = 0;
   
    Screen_Init(direction_out, direction_in, type, frame_duration);
}

void Screen_Init(Screen_Transition_Direction direction_out, Screen_Transition_Direction direction_in, Easing type, uint32_t frame_duration)
{
    // _Screen_Last                   = Screen_Init;    // We don't want that here...
    _Screen_Tick                   = Screen_Tick;
    _Screen_Click                  = Screen_Click;
    _Screen_Touch_Event            = Screen_Touch_Event;
    _Screen_Action_CW              = Screen_Action_CW;
    _Screen_Action_CCW             = Screen_Action_CCW;
    _Screen_On_Objects_Focused     = Screen_On_Object_Focused;
    _Screen_On_Objects_Defocused   = Screen_On_Object_Defocused;
    _Screen_On_Object_Select       = Screen_On_Object_Select;
    _Screen_On_Object_Deselect     = Screen_On_Object_Deselect;

    Display_Objects_Clear();
    Display_Screen_Transition_Start(direction_out, direction_in, type, frame_duration);


    //////////////////////////////
    // Add Display Objects here //
    //////////////////////////////

    Common_Screen_Element_Init_Current_Mode(_Mode);
}

void Screen_Tick(void)
{
    const uint32_t Counter_Max = 50;
    
    if(_Counter == Counter_Max)
    {
		if(_Screen_Idle_Active == true) {
			Screen_Setup_Idle(TRANSITION_NONE, TRANSITION_NONE, SCREEN_TRANSITION_DEFAULT_EASING, SCREEN_TRANSITION_DEFAULT_FRAMES);
		} else {
			_Screen_Last(TRANSITION_NONE, TRANSITION_NONE, SCREEN_TRANSITION_DEFAULT_EASING, SCREEN_TRANSITION_DEFAULT_FRAMES);
		}
	}
    
    _Counter++;
}

void Screen_Click(uint button_return_value)
{

}

void Screen_Touch_Event(int16_t x, int16_t y)
{

}

void Screen_Action_CW(Object_ID object_id)
{

}

void Screen_Action_CCW(Object_ID object_id)
{

}

void Screen_On_Object_Focused(Object_ID object_id)
{

}

void Screen_On_Object_Defocused(Object_ID object_id)
{

}

void Screen_On_Object_Select(Object_ID object_id)
{

}

void Screen_On_Object_Deselect(Object_ID object_id)
{

}


/*******************************************************************
    Internal Functions
*******************************************************************/

