Index: apps/bootmenu-ipodnano2g/confirmchooser.c |
— | — | @@ -0,0 +1,183 @@ |
| 2 | +//
|
| 3 | +//
|
| 4 | +// Copyright 2011 TheSeven
|
| 5 | +//
|
| 6 | +//
|
| 7 | +// This file is part of emCORE.
|
| 8 | +//
|
| 9 | +// emCORE is free software: you can redistribute it and/or
|
| 10 | +// modify it under the terms of the GNU General Public License as
|
| 11 | +// published by the Free Software Foundation, either version 2 of the
|
| 12 | +// License, or (at your option) any later version.
|
| 13 | +//
|
| 14 | +// emCORE is distributed in the hope that it will be useful,
|
| 15 | +// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 16 | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
| 17 | +// See the GNU General Public License for more details.
|
| 18 | +//
|
| 19 | +// You should have received a copy of the GNU General Public License along
|
| 20 | +// with emCORE. If not, see <http://www.gnu.org/licenses/>.
|
| 21 | +//
|
| 22 | +//
|
| 23 | +
|
| 24 | +
|
| 25 | +#include "emcoreapp.h"
|
| 26 | +#include "libui.h"
|
| 27 | +#include "confirmchooser.h"
|
| 28 | +#include "main.h"
|
| 29 | +#include "util.h"
|
| 30 | +#include "settings.h"
|
| 31 | +
|
| 32 | +
|
| 33 | +static struct chooser_renderer_list_itemdata confirmchooser_rparams_yes =
|
| 34 | +{
|
| 35 | + .size = LIBUI_POINT(164, 10),
|
| 36 | + .fill_box = LIBUI_BOX(LIBUI_POINT(0, 0), LIBUI_POINT(164, 10)),
|
| 37 | + .fill_color = 0xa0000000,
|
| 38 | + .fill_color_selected = 0xa00000ff,
|
| 39 | + .icon_pos = LIBUI_POINT_NULL,
|
| 40 | + .icon = LIBUI_SURFACE_NULL,
|
| 41 | + .icon_opacity = 0,
|
| 42 | + .icon_selected = LIBUI_SURFACE_NULL,
|
| 43 | + .icon_selected_opacity = 0,
|
| 44 | + .text = "Yes",
|
| 45 | + .text_pos = LIBUI_POINT(1, 1),
|
| 46 | + .text_color = 0xff0000ff,
|
| 47 | + .text_color_selected = 0xff3f7fff,
|
| 48 | + .render = NULL
|
| 49 | +};
|
| 50 | +
|
| 51 | +static struct chooser_renderer_list_itemdata confirmchooser_rparams_no =
|
| 52 | +{
|
| 53 | + .size = LIBUI_POINT(164, 10),
|
| 54 | + .fill_box = LIBUI_BOX(LIBUI_POINT(0, 0), LIBUI_POINT(164, 10)),
|
| 55 | + .fill_color = 0xa0000000,
|
| 56 | + .fill_color_selected = 0x60ffffff,
|
| 57 | + .icon_pos = LIBUI_POINT_NULL,
|
| 58 | + .icon = LIBUI_SURFACE_NULL,
|
| 59 | + .icon_opacity = 0,
|
| 60 | + .icon_selected = LIBUI_SURFACE_NULL,
|
| 61 | + .icon_selected_opacity = 0,
|
| 62 | + .text = "No",
|
| 63 | + .text_pos = LIBUI_POINT(1, 1),
|
| 64 | + .text_color = 0xffffffff,
|
| 65 | + .text_color_selected = 0xff7fffff,
|
| 66 | + .render = NULL
|
| 67 | +};
|
| 68 | +
|
| 69 | +static struct chooser_renderer_list_params confirmchooser_rparams =
|
| 70 | +{
|
| 71 | + .version = CHOOSER_RENDERER_LIST_PARAMS_VERSION,
|
| 72 | + .copy_dest = LIBUI_LOCATION(LIBUI_BUFFER(NULL, 176), LIBUI_POINT(0, 0)),
|
| 73 | + .copy_src = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 176), LIBUI_POINT(0, 0)),
|
| 74 | + LIBUI_POINT(176, 132)),
|
| 75 | + .bg_dest = LIBUI_LOCATION_NULL,
|
| 76 | + .bg_src = LIBUI_SURFACE_NULL,
|
| 77 | + .bg_opacity = 0,
|
| 78 | + .fill_dest = LIBUI_SURFACE_NULL,
|
| 79 | + .fill_color = 0,
|
| 80 | + .viewport = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 176), LIBUI_POINT(6, 50)),
|
| 81 | + LIBUI_POINT(164, 70)),
|
| 82 | + .blit_dest = LIBUI_POINT(0, 0),
|
| 83 | + .blit_src = LIBUI_SURFACE(LIBUI_LOCATION(LIBUI_BUFFER(NULL, 176), LIBUI_POINT(0, 0)),
|
| 84 | + LIBUI_POINT(176, 132)),
|
| 85 | + .preblit = update_display,
|
| 86 | + .postblit = NULL
|
| 87 | +};
|
| 88 | +
|
| 89 | +static struct chooser_action_handler_wheel_params confirmchooser_aparams =
|
| 90 | +{
|
| 91 | + .version = CHOOSER_ACTION_HANDLER_WHEEL_PARAMS_VERSION,
|
| 92 | + .stepsperitem = 128,
|
| 93 | + .eventfilter = NULL,
|
| 94 | + .timeout_initial = TIMEOUT_BLOCK,
|
| 95 | + .timeout_idle = TIMEOUT_BLOCK,
|
| 96 | + .timeout_item = 0,
|
| 97 | + .tick_force_redraw = true,
|
| 98 | + .buttoncount = 5,
|
| 99 | + .buttonmap =
|
| 100 | + {
|
| 101 | + CHOOSER_ACTION_HANDLER_WHEEL_ACTION_SELECT,
|
| 102 | + CHOOSER_ACTION_HANDLER_WHEEL_ACTION_SELECT,
|
| 103 | + CHOOSER_ACTION_HANDLER_WHEEL_ACTION_CANCEL,
|
| 104 | + CHOOSER_ACTION_HANDLER_WHEEL_ACTION_NEXT,
|
| 105 | + CHOOSER_ACTION_HANDLER_WHEEL_ACTION_PREV
|
| 106 | + }
|
| 107 | +};
|
| 108 | +
|
| 109 | +static struct chooser_info confirmchooser =
|
| 110 | +{
|
| 111 | + .version = CHOOSER_INFO_VERSION,
|
| 112 | + .actionhandler = NULL,
|
| 113 | + .actionhandlerparams = &confirmchooser_aparams,
|
| 114 | + .renderer = NULL,
|
| 115 | + .rendererparams = &confirmchooser_rparams,
|
| 116 | + .userparams = NULL,
|
| 117 | + .tickinterval = 10000000,
|
| 118 | + .itemcount = 7,
|
| 119 | + .defaultitem = 0,
|
| 120 | + .items =
|
| 121 | + {
|
| 122 | + {
|
| 123 | + .user = NULL,
|
| 124 | + .actionparams = NULL,
|
| 125 | + .renderparams = &confirmchooser_rparams_no
|
| 126 | + },
|
| 127 | + {
|
| 128 | + .user = NULL,
|
| 129 | + .actionparams = NULL,
|
| 130 | + .renderparams = &confirmchooser_rparams_no
|
| 131 | + },
|
| 132 | + {
|
| 133 | + .user = NULL,
|
| 134 | + .actionparams = NULL,
|
| 135 | + .renderparams = &confirmchooser_rparams_no
|
| 136 | + },
|
| 137 | + {
|
| 138 | + .user = NULL,
|
| 139 | + .actionparams = NULL,
|
| 140 | + .renderparams = &confirmchooser_rparams_no
|
| 141 | + },
|
| 142 | + {
|
| 143 | + .user = (void*)1,
|
| 144 | + .actionparams = NULL,
|
| 145 | + .renderparams = &confirmchooser_rparams_yes
|
| 146 | + },
|
| 147 | + {
|
| 148 | + .user = NULL,
|
| 149 | + .actionparams = NULL,
|
| 150 | + .renderparams = &confirmchooser_rparams_no
|
| 151 | + },
|
| 152 | + {
|
| 153 | + .user = NULL,
|
| 154 | + .actionparams = NULL,
|
| 155 | + .renderparams = &confirmchooser_rparams_no
|
| 156 | + }
|
| 157 | + }
|
| 158 | +};
|
| 159 | +
|
| 160 | +bool run_confirmchooser(const char* message)
|
| 161 | +{
|
| 162 | + memcpy(framebuf2, bg, 176 * 132 * 3);
|
| 163 | + ui->blendcolor(164, 20, 0xa0000000, framebuf2, 6, 30, 176, framebuf2, 6, 30, 176);
|
| 164 | + rendertext(framebuf2, 7, 31, 176, 0xff3333ff, 0, message);
|
| 165 | + const struct chooser_item* result = ui->chooser_run(&confirmchooser);
|
| 166 | + if (!result || !result->user) return false;
|
| 167 | + return true;
|
| 168 | +}
|
| 169 | +
|
| 170 | +void confirmchooser_init()
|
| 171 | +{
|
| 172 | + confirmchooser.actionhandler = ui->chooser_action_handler_wheel;
|
| 173 | + confirmchooser.renderer = ui->chooser_renderer_list;
|
| 174 | + confirmchooser_rparams.copy_dest.buf.addr = framebuf;
|
| 175 | + confirmchooser_rparams.copy_src.loc.buf.addr = framebuf2;
|
| 176 | + confirmchooser_rparams.viewport.loc.buf.addr = framebuf;
|
| 177 | + confirmchooser_rparams.blit_src.loc.buf.addr = framebuf;
|
| 178 | + confirmchooser_rparams_yes.render = ui->chooser_renderer_list_show_arrow_right;
|
| 179 | + confirmchooser_rparams_no.render = ui->chooser_renderer_list_show_arrow_left;
|
| 180 | +}
|
| 181 | +
|
| 182 | +void confirmchooser_apply_settings()
|
| 183 | +{
|
| 184 | +}
|
Index: apps/bootmenu-ipodnano2g/confirmchooser.h |
— | — | @@ -0,0 +1,36 @@ |
| 2 | +//
|
| 3 | +//
|
| 4 | +// Copyright 2011 TheSeven
|
| 5 | +//
|
| 6 | +//
|
| 7 | +// This file is part of emCORE.
|
| 8 | +//
|
| 9 | +// emCORE is free software: you can redistribute it and/or
|
| 10 | +// modify it under the terms of the GNU General Public License as
|
| 11 | +// published by the Free Software Foundation, either version 2 of the
|
| 12 | +// License, or (at your option) any later version.
|
| 13 | +//
|
| 14 | +// emCORE is distributed in the hope that it will be useful,
|
| 15 | +// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 16 | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
| 17 | +// See the GNU General Public License for more details.
|
| 18 | +//
|
| 19 | +// You should have received a copy of the GNU General Public License along
|
| 20 | +// with emCORE. If not, see <http://www.gnu.org/licenses/>.
|
| 21 | +//
|
| 22 | +//
|
| 23 | +
|
| 24 | +
|
| 25 | +#ifndef __APP_CONFIRMCHOOSER_H__
|
| 26 | +#define __APP_CONFIRMCHOOSER_H__
|
| 27 | +
|
| 28 | +
|
| 29 | +#include "emcoreapp.h"
|
| 30 | +
|
| 31 | +
|
| 32 | +extern bool run_confirmchooser(const char* message);
|
| 33 | +extern void confirmchooser_init();
|
| 34 | +extern void confirmchooser_apply_settings();
|
| 35 | +
|
| 36 | +
|
| 37 | +#endif
|