Changeset f6df5a3 in mainline for uspace/lib/ui/src/pbutton.c
- Timestamp:
- 2020-10-13T20:06:47Z (4 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- c9a7adc
- Parents:
- 47728678
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/ui/src/pbutton.c
r47728678 rf6df5a3 44 44 #include "../private/pbutton.h" 45 45 #include "../private/resource.h" 46 47 /** Caption movement when button is pressed down */ 48 enum { 49 ui_pb_press_dx = 2, 50 ui_pb_press_dy = 2 51 }; 46 52 47 53 /** Create new push button. … … 106 112 errno_t rc; 107 113 108 rc = gfx_color_new_rgb_i16(0xc8c8, 0xc8c8, 0xc8c8, &color); 109 if (rc != EOK) 110 goto error; 114 if (pbutton->held) { 115 rc = gfx_color_new_rgb_i16(0x8000, 0, 0, &color); 116 if (rc != EOK) 117 goto error; 118 } else { 119 rc = gfx_color_new_rgb_i16(0xc8c8, 0xc8c8, 0xc8c8, &color); 120 if (rc != EOK) 121 goto error; 122 } 111 123 112 124 rc = gfx_set_color(pbutton->res->gc, color); … … 132 144 pos.y = (pbutton->rect.p0.y + pbutton->rect.p1.y) / 2; 133 145 146 if (pbutton->held) { 147 pos.x += ui_pb_press_dx; 148 pos.y += ui_pb_press_dy; 149 } 150 134 151 gfx_text_fmt_init(&fmt); 135 152 fmt.halign = gfx_halign_center; … … 149 166 } 150 167 168 /** Press down button. 169 * 170 * This does not automatically repaint the button. 171 * 172 * @param pbutton Push button 173 */ 174 void ui_pbutton_press(ui_pbutton_t *pbutton) 175 { 176 pbutton->held = true; 177 } 178 179 /** Release button. 180 * 181 * This does not automatically repaint the button. 182 * 183 * @param pbutton Push button 184 */ 185 void ui_pbutton_release(ui_pbutton_t *pbutton) 186 { 187 pbutton->held = false; 188 } 189 151 190 /** @} 152 191 */
Note:
See TracChangeset
for help on using the changeset viewer.