cancel
Showing results for 
Search instead for 
Did you mean: 

Adding screens to swipe container after they've been removed.

RCramer
Associate

Upon entering a screen which contains a swipe container 'sub_settings_swipe_container' I'm performing some logic based on where the screen is getting it's brightness from. Either manually set via a scrollwheel elsewhere or through a CAN message.

void sub_settings_swipeView::setupScreen()
{
	sub_settings_swipeViewBase::setupScreen();
 
	sub_settings_swipe_container.setSelectedPage(navigate_to_screen != 0xff ? navigate_to_screen : 0);
 
	current_page = sub_settings_swipe_container.getSelectedPage();
 
	//	Global_Settings_2_2
	switch(FFC.brightness_source)
	{
		case can_source:
			can_button.setSelected(true);
			manual_button.setSelected(false);
			sub_settings_swipe_container.add(sub_1_settings_1);
			sub_settings_swipe_container.add(sub_1_settings_2);
			sub_settings_swipe_container.setPageIndicatorXY(98, 212);
	
			//	Global_Settings_2_4
			CAN_brightness_scroll_wheel.animateToItem(ceil((FFC.CAN_Backlight_Adjust*100)-50), 3);
			CAN_brightness_scroll_wheel.invalidate();
	
			can_found.setVisible(true);
			can_not_found.setVisible(false);
			can_found.invalidate();
			can_not_found.invalidate();
			break;
	
		case manual_source:
			can_button.setSelected(false);
			manual_button.setSelected(true);
			sub_settings_swipe_container.remove(sub_1_settings_1);
			sub_settings_swipe_container.remove(sub_1_settings_2);
			sub_settings_swipe_container.setPageIndicatorXY(113, 212);
			break;
	}
 
	can_button.invalidate();
	manual_button.invalidate();
	sub_settings_swipe_container.invalidate();
}

Upon entering this screen... I look at what is saved to memory, the switch/case statement on FFC.brightness_source, and populate the screen accordingly. The issue is, when I enter this screen and the source is set to can_source, the code dies at the step where I go to add(sub_1_settings_1).

However, if the brightness source is set to manual, it removes these screens just fine, and then I can toggle them on/off with the can_button/manual_button radio buttons. This is handled in the handleTickEvent()

void sub_settings_swipeView::handleTickEvent()
{
	previous_page = current_page;
	current_page = sub_settings_swipe_container.getSelectedPage();
 
	switch(current_page)
	{
		case sub_1_settings_page_0:
			previous_brightness_source = brightness_source;
 
			if(can_button.getSelected())
				brightness_source = can_source;
			else
				brightness_source = manual_source;
 
			if(brightness_source != previous_brightness_source)
			{
				switch(brightness_source)
				{
					case can_source:
						sub_settings_swipe_container.add(sub_1_settings_1);
						sub_settings_swipe_container.add(sub_1_settings_2);
						sub_settings_swipe_container.setPageIndicatorXY(98, 212);
						break;
 
					case manual_source:
						sub_settings_swipe_container.remove(sub_1_settings_1);
						sub_settings_swipe_container.remove(sub_1_settings_2);
						sub_settings_swipe_container.setPageIndicatorXY(113, 212);
						break;
				}
				sub_settings_swipe_container.invalidate();
			}
			break;

To reiterate, the adding/removing of screens works in the handleTickEvent(), but adding screens dies in the setupScreen function. Any tips or advice?

Thanks,

Ryan

1 ACCEPTED SOLUTION

Accepted Solutions
MM..1
Chief II

Seems as your sub settings exist and is added in screen base then you cant add it in setup, but you can remove.

View solution in original post

2 REPLIES 2
MM..1
Chief II

Seems as your sub settings exist and is added in screen base then you cant add it in setup, but you can remove.

RCramer
Associate

Thank you MM..1! I removed the .add(sub_1_settings_1) and add(sub_1_settings_2) and that fixed the issue I was seeing! Not sure what I was thinking when I thought those needed to be there. Like you said, those screens are already included in the base when the screen was setup.

Much appreciated!