Пример #1
0
static void test_clist_remove(void)
{
    list_node_t *list = &test_clist;

    for (int i = 0; i < 3; i++) {
        set_up();
        test_clist_add_three();
        clist_remove(list, &(tests_clist_buf[i]));

        for (int j = 0; j < 3; j++) {
            if (i == j) {
                TEST_ASSERT_NULL(clist_find(list, &(tests_clist_buf[j])));
            }
            else {
                TEST_ASSERT(clist_find(list, &(tests_clist_buf[j])) == &(tests_clist_buf[j]));
            }
        }
    }

    /* list now contains 0, 1 */
    TEST_ASSERT(list->next == &(tests_clist_buf[1]));
    TEST_ASSERT(list->next->next == &(tests_clist_buf[0]));

    clist_remove(list, &(tests_clist_buf[1]));
    TEST_ASSERT(list->next == &(tests_clist_buf[0]));
    TEST_ASSERT(list->next->next == &(tests_clist_buf[0]));

    clist_remove(list, &(tests_clist_buf[0]));
    TEST_ASSERT_NULL(list->next);
}
Пример #2
0
static void test_clist_find(void)
{
    list_node_t *list = &test_clist;

    test_clist_add_three();

    for (int i = 0; i < 3; i++) {
        TEST_ASSERT(clist_find(list, &(tests_clist_buf[i])) == &(tests_clist_buf[i]));
    }

    TEST_ASSERT_NULL(clist_find(list, &(tests_clist_buf[3])));
}
Пример #3
0
static inline size_t clist_update(gui::control_list_t<T> *list, uint32_t id, T const &state)
{
    size_t index = 0;
    if (clist_find(list, id, &index))
    {
        list->State[index] = state;
        return index;
    }
    else return clist_append(list, id, state);
}
Пример #4
0
void extend_link_objects(struct clist_entry *cmain)
	{
	struct strq_entry *pos;
	for (pos = cmain->link_objects.beg; pos; pos = pos->next)
		{
		struct clist_entry *cdata = clist_find(&clist, pos->str);
		if (cdata)
			{
			if (cdata->need_compile)
				cmain->need_link = 1;
			add_link_objects(cdata, cmain);
			add_libs(cdata, cmain);
			}
		}
	}
Пример #5
0
void resolve_embedded_var(struct clist_entry *cdata, struct bufd *cmd)
	{
	if (strcmp(out.beg,"cfile")==0)
		bufd_put(cmd, cdata->cfile.beg);
	else if (strcmp(out.beg,"ofile")==0)
		bufd_put(cmd, cdata->ofile.beg);
	else if (strcmp(out.beg,"efile")==0)
		bufd_put(cmd, cdata->efile.beg);
	else if (strcmp(out.beg,"objects")==0)
		{
		int first = 1;
		struct strq_entry *pos;
		for (pos = cdata->link_objects.beg; pos; pos = pos->next)
			{
			struct clist_entry *entry = clist_find(&clist, pos->str);
			if (entry)
				{
				if (first)
					first = 0;
				else
					bufd_putc(cmd, ' ');
				bufd_put(cmd, entry->ofile.beg);
				}
			}
		for (pos = cdata->libs.beg; pos; pos = pos->next)
			{
			if (first)
				first = 0;
			else
				bufd_putc(cmd, ' ');
			bufd_put(cmd, pos->str);
			}
		}
	else
		fprintf(stderr,"Unrecognized embedded var '%s'\n", out.beg);
	}
Пример #6
0
gui::toggle_t* gui::toggle(gui::context_t *ui, uint32_t id, uint32_t x, uint32_t y, uint32_t w, uint32_t h, bool default_set, bool click, bool active)
{
    gui::toggle_t *control = NULL;
    size_t         index   = 0;
    bool           isHot   = false;
    bool           clicked = false;

    // create the control if it doesn't already exist.
    if (!clist_find(&ui->Toggles, id, &index))
    {
        gui::toggle_t    state;
        state.XYWH[0]    = x;
        state.XYWH[1]    = y;
        state.XYWH[2]    = w;
        state.XYWH[3]    = h;
        state.State      = uint32_t(index);
        state.IsHot      = false;
        state.IsActive   = false;
        state.WasClicked = false;
        state.IsOn       = default_set;
        index = clist_append(&ui->Toggles, id, state);
    }

    control = &ui->Toggles.State[index];
    control->XYWH[0] = x;
    control->XYWH[1] = y;
    control->XYWH[2] = w;
    control->XYWH[3] = h;
    isHot  = gui::pointer_over(ui, x, y, w, h);

    if (click)
    {
        control->IsHot      = isHot;
        control->WasClicked = true;
        control->IsOn       =!control->IsOn;
        return control;
    }
    if (isHot && active)
    {
        gui::make_hot(ui, id);
    }
    else
    {
        gui::make_not_hot(ui, id);
        gui::make_not_active(ui, id);
    }
    if (ui->ActiveItem == id)
    {
        if (gui::interaction_ending(ui))
        {
            if (ui->HotItem == id)
            {
                clicked = true;
            }
            gui::make_not_active(ui, id);
        }
    }
    else if (isHot && active)
    {
        if (gui::interaction_starting(ui))
        {
            gui::make_active(ui, id);
        }
    }

    control->IsHot      =(id == ui->HotItem);
    control->IsActive   =(id == ui->ActiveItem);
    control->WasClicked = clicked;
    control->IsOn       = clicked ? !control->IsOn : control->IsOn;
    return control;
}