freemyipod r827 - Code Review

Jump to: navigation, search
Repository:freemyipod
Revision:r826‎ | r827 | r828 >
Date:03:29, 4 December 2011
Author:theseven
Status:new
Tags:
Comment:
libUI: Make up/down buttons change integer values in settingchoosers
Modified paths:
  • /libs/ui/settingchooser.c (modified) (history)

Diff [purge]

Index: libs/ui/settingchooser.c
@@ -37,6 +37,7 @@
3838 struct settingchooser_item* item = (struct settingchooser_item*)data->selected->user;
3939 struct chooser_renderer_list_itemdata* rp;
4040 rp = (struct chooser_renderer_list_itemdata*)data->selected->renderparams;
 41+ int change = 0;
4142 bool redraw = false;
4243 bool handled = false;
4344 bool setcolors = false;
@@ -66,6 +67,22 @@
6768 state->editing = false;
6869 }
6970 break;
 71+
 72+ case 3:
 73+ if (state->editing)
 74+ {
 75+ handled = true;
 76+ change = -128;
 77+ }
 78+ break;
 79+
 80+ case 4:
 81+ if (state->editing)
 82+ {
 83+ handled = true;
 84+ change = 128;
 85+ }
 86+ break;
7087
7188 default:
7289 handled = state->editing;
@@ -80,24 +97,30 @@
8198 {
8299 case SETTINGCHOOSER_TYPE_INTEGER:
83100 handled = true;
84 - state->collect += value;
85 - int change = (state->collect * item->config.integer.step) / 128;
86 - if (!change) break;
87 - state->collect -= (change * 128) / item->config.integer.step;
88 - int* setting = (int*)item->setting;
89 - if (*setting + change < item->config.integer.min)
90 - *setting = item->config.integer.min;
91 - else if (*setting + change > item->config.integer.max)
92 - *setting = item->config.integer.max;
93 - else *setting += change;
94 - if (item->validator) item->validator(item->setting);
95 - state->changed = true;
96 - redraw = true;
 101+ change = value;
97102 break;
98103 }
99104 }
100105 break;
101106 }
 107+ if (change)
 108+ {
 109+ state->collect += change;
 110+ change = (state->collect * item->config.integer.step) / 128;
 111+ if (change)
 112+ {
 113+ state->collect -= (change * 128) / item->config.integer.step;
 114+ int* setting = (int*)item->setting;
 115+ if (*setting + change < item->config.integer.min)
 116+ *setting = item->config.integer.min;
 117+ else if (*setting + change > item->config.integer.max)
 118+ *setting = item->config.integer.max;
 119+ else *setting += change;
 120+ if (item->validator) item->validator(item->setting);
 121+ state->changed = true;
 122+ redraw = true;
 123+ }
 124+ }
102125 if (setcolors)
103126 {
104127 if (state->editing)