diff --git a/docs/classfluent__tray_1_1_fluent_tray-members.html b/docs/classfluent__tray_1_1_fluent_tray-members.html index d49cd50..7707dd0 100644 --- a/docs/classfluent__tray_1_1_fluent_tray-members.html +++ b/docs/classfluent__tray_1_1_fluent_tray-members.html @@ -86,6 +86,8 @@ + + @@ -96,6 +98,8 @@ + + diff --git a/docs/classfluent__tray_1_1_fluent_tray.html b/docs/classfluent__tray_1_1_fluent_tray.html index 8587987..23cd2dd 100644 --- a/docs/classfluent__tray_1_1_fluent_tray.html +++ b/docs/classfluent__tray_1_1_fluent_tray.html @@ -147,6 +147,18 @@ + + + + + + + + + + + + @@ -354,6 +366,62 @@

+

◆ back() [1/2]

+ +
+
+

add_menu(const std::string &label_text="", const std::string &icon_path="", bool toggleable=false, const std::string &checkmark="✓", const std::function< bool(void)> &callback=[] {return true ;}, const std::function< bool(void)> &unchecked_callback=[] {return true ;})fluent_tray::FluentTrayinline
add_separator()fluent_tray::FluentTrayinline
back()fluent_tray::FluentTrayinline
back() constfluent_tray::FluentTrayinline
begin() noexceptfluent_tray::FluentTrayinline
cbegin() const noexceptfluent_tray::FluentTrayinline
cend() const noexceptfluent_tray::FluentTrayinline
FluentTray()fluent_tray::FluentTrayinlineexplicit
FluentTray(const FluentTray &)=deletefluent_tray::FluentTray
FluentTray(FluentTray &&)=defaultfluent_tray::FluentTray
front()fluent_tray::FluentTrayinline
front() constfluent_tray::FluentTrayinline
hide_menu_window()fluent_tray::FluentTrayinline
operator=(const FluentTray &)=deletefluent_tray::FluentTray
operator=(FluentTray &&)=defaultfluent_tray::FluentTray
std::vector< FluentMenu >::const_iterator cend () const noexcept
 Returns a constant iterator to the end of menus.
 
FluentMenufront ()
 Returns the reference to the beginning of menus.
 
const FluentMenufront () const
 Returns the const reference to the beginning of menus.
 
FluentMenuback ()
 Returns the reference to the last of menus.
 
const FluentMenuback () const
 Returns the const reference to the last of menus.
 
std::size_t count_menus () const noexcept
 Returns the number of menus.
 
+ + + + +
+ + + + + + + +
FluentMenu & fluent_tray::FluentTray::back ()
+
+inline
+
+ +

Returns the reference to the last of menus.

+
Returns
Reference to the first element.
+ +
+ + +

◆ back() [2/2]

+ +
+
+ + + + + +
+ + + + + + + +
const FluentMenu & fluent_tray::FluentTray::back () const
+
+inline
+
+ +

Returns the const reference to the last of menus.

+
Returns
Const reference to the first element.
+
@@ -597,6 +665,62 @@

Returns
Iterator to the last element.
+ + +
+

◆ front() [1/2]

+ +
+
+ + + + + +
+ + + + + + + +
FluentMenu & fluent_tray::FluentTray::front ()
+
+inline
+
+ +

Returns the reference to the beginning of menus.

+
Returns
Reference to the first element.
+ +
+
+ +

◆ front() [2/2]

+ +
+
+ + + + + +
+ + + + + + + +
const FluentMenu & fluent_tray::FluentTray::front () const
+
+inline
+
+ +

Returns the const reference to the beginning of menus.

+
Returns
Const reference to the first element.
+
diff --git a/docs/fluent__tray_8hpp_source.html b/docs/fluent__tray_8hpp_source.html index f87e85c..fe79281 100644 --- a/docs/fluent__tray_8hpp_source.html +++ b/docs/fluent__tray_8hpp_source.html @@ -893,532 +893,560 @@
937 get_message(msg) ;
938
939 if(GetForegroundWindow() != hwnd_ && visible_) {
- -
941 }
-
942
-
943 for(std::size_t i = 0 ; i < menus_.size() ; i ++) {
-
944 auto& menu = menus_[i] ;
-
945 if(menu.is_mouse_over()) {
-
946 if(!mouse_is_over_[i]) {
-
947 if(!change_menu_back_color(menu, ash_color_)) {
-
948 return false ;
-
949 }
-
950 }
-
951 mouse_is_over_[i] = true ;
-
952 }
-
953 else {
-
954 if(mouse_is_over_[i]) {
-
955 if(!change_menu_back_color(menu, back_color_)) {
-
956 return false ;
-
957 }
-
958 }
-
959 mouse_is_over_[i] = false ;
-
960 }
-
961 }
-
962
-
963 return true ;
-
964 }
- -
965
-
- -
972 std::chrono::milliseconds sleep_time=std::chrono::milliseconds(1)) {
-
973
-
974 while(true) {
-
975 if(status_ == TrayStatus::SHOULD_STOP) {
-
976 status_ = TrayStatus::STOPPED ;
-
977 break ;
-
978 }
-
979
-
980 if(!update()) {
-
981 return false ;
-
982 }
-
983
-
984 Sleep(static_cast<int>(sleep_time.count())) ;
-
985 }
-
986 return true ;
-
987 }
+
940 if(!hide_menu_window()) {
+
941 fail() ;
+
942 return false ;
+
943 }
+
944 }
+
945
+
946 for(std::size_t i = 0 ; i < menus_.size() ; i ++) {
+
947 auto& menu = menus_[i] ;
+
948 if(menu.is_mouse_over()) {
+
949 if(!mouse_is_over_[i]) {
+
950 if(!change_menu_back_color(menu, ash_color_)) {
+
951 fail() ;
+
952 return false ;
+
953 }
+
954 }
+
955 mouse_is_over_[i] = true ;
+
956 }
+
957 else {
+
958 if(mouse_is_over_[i]) {
+
959 if(!change_menu_back_color(menu, back_color_)) {
+
960 fail() ;
+
961 return false ;
+
962 }
+
963 }
+
964 mouse_is_over_[i] = false ;
+
965 }
+
966 }
+
967
+
968 return true ;
+
969 }
+
970
+
+ +
977 std::chrono::milliseconds sleep_time=std::chrono::milliseconds(1)) {
+
978
+
979 while(true) {
+
980 if(status_ == TrayStatus::SHOULD_STOP) {
+
981 status_ = TrayStatus::STOPPED ;
+
982 break ;
+
983 }
+
984
+
985 if(!update()) {
+
986 return false ;
+
987 }
988
-
-
993 HWND window_handle() const noexcept {
-
994 return hwnd_ ;
-
995 }
+
989 Sleep(static_cast<int>(sleep_time.count())) ;
+
990 }
+
991 return true ;
+
992 }
+
+
993
+
+
998 HWND window_handle() const noexcept {
+
999 return hwnd_ ;
+
1000 }
-
996
-
- -
1002 LONG max_label_size = 0 ;
-
1003 for(auto& menu : menus_) {
-
1004 SIZE size ;
-
1005 if(!menu.calculate_required_dims(font_, size)) {
-
1006 return false ;
-
1007 }
-
1008 if(max_label_size < size.cx) {
-
1009 max_label_size = size.cx ;
-
1010 }
-
1011 }
-
1012
-
1013 // Update the sizes
-
1014 auto menu_width = max_label_size + 2 * menu_x_pad_ ;
-
1015 auto menu_height = menu_font_size_ + 2 * menu_y_pad_ ;
-
1016 auto popup_width = 2 * menu_x_margin_ + menu_width ;
-
1017 auto popup_height = static_cast<LONG>(
-
1018 menus_.size() * (menu_y_margin_ + menu_height) + menu_y_margin_) ;
-
1019
-
1020 POINT cursor_pos ;
-
1021 if(!GetCursorPos(&cursor_pos)) {
-
1022 return false ;
-
1023 }
+
1001
+
+ +
1007 LONG max_label_size = 0 ;
+
1008 for(auto& menu : menus_) {
+
1009 SIZE size ;
+
1010 if(!menu.calculate_required_dims(font_, size)) {
+
1011 return false ;
+
1012 }
+
1013 if(max_label_size < size.cx) {
+
1014 max_label_size = size.cx ;
+
1015 }
+
1016 }
+
1017
+
1018 // Update the sizes
+
1019 auto menu_width = max_label_size + 2 * menu_x_pad_ ;
+
1020 auto menu_height = menu_font_size_ + 2 * menu_y_pad_ ;
+
1021 auto popup_width = 2 * menu_x_margin_ + menu_width ;
+
1022 auto popup_height = static_cast<LONG>(
+
1023 menus_.size() * (menu_y_margin_ + menu_height) + menu_y_margin_) ;
1024
-
1025 RECT work_rect ;
-
1026 if(!SystemParametersInfo(
-
1027 SPI_GETWORKAREA, 0, reinterpret_cast<PVOID>(&work_rect), 0)) {
-
1028 return false ;
-
1029 }
-
1030
-
1031 auto screen_width = GetSystemMetrics(SM_CXSCREEN) ;
-
1032 auto screen_height = GetSystemMetrics(SM_CYSCREEN) ;
-
1033
-
1034 auto work_width = work_rect.right - work_rect.left ;
-
1035 auto work_height = work_rect.bottom - work_rect.top ;
-
1036
-
1037 auto taskbar_width = screen_width - work_width ;
-
1038 auto taskbar_height = screen_height - work_height ;
-
1039
-
1040 auto pos = cursor_pos ;
-
1041 if(taskbar_width == 0) { // horizontal taskbar
-
1042 if(cursor_pos.y <= taskbar_height) {
-
1043 //top
-
1044 pos.y = taskbar_height ;
-
1045 }
-
1046 else {
-
1047 //bottom
-
1048 // add 20% offset
-
1049 pos.y = screen_height - (popup_height + 12 * taskbar_height / 10) ;
+
1025 POINT cursor_pos ;
+
1026 if(!GetCursorPos(&cursor_pos)) {
+
1027 return false ;
+
1028 }
+
1029
+
1030 RECT work_rect ;
+
1031 if(!SystemParametersInfo(
+
1032 SPI_GETWORKAREA, 0, reinterpret_cast<PVOID>(&work_rect), 0)) {
+
1033 return false ;
+
1034 }
+
1035
+
1036 auto screen_width = GetSystemMetrics(SM_CXSCREEN) ;
+
1037 auto screen_height = GetSystemMetrics(SM_CYSCREEN) ;
+
1038
+
1039 auto work_width = work_rect.right - work_rect.left ;
+
1040 auto work_height = work_rect.bottom - work_rect.top ;
+
1041
+
1042 auto taskbar_width = screen_width - work_width ;
+
1043 auto taskbar_height = screen_height - work_height ;
+
1044
+
1045 auto pos = cursor_pos ;
+
1046 if(taskbar_width == 0) { // horizontal taskbar
+
1047 if(cursor_pos.y <= taskbar_height) {
+
1048 //top
+
1049 pos.y = taskbar_height ;
1050 }
-
1051 pos.x = cursor_pos.x - popup_width / 2 ;
-
1052 }
-
1053 else { // vertical taskbar
-
1054 if(pos.x <= taskbar_width) {
-
1055 //left
-
1056 pos.x = taskbar_width ;
-
1057 }
-
1058 else {
-
1059 //right
-
1060 // add 20% offset
-
1061 pos.x = popup_width + 12 * taskbar_width / 10 ;
+
1051 else {
+
1052 //bottom
+
1053 // add 20% offset
+
1054 pos.y = screen_height - (popup_height + 12 * taskbar_height / 10) ;
+
1055 }
+
1056 pos.x = cursor_pos.x - popup_width / 2 ;
+
1057 }
+
1058 else { // vertical taskbar
+
1059 if(pos.x <= taskbar_width) {
+
1060 //left
+
1061 pos.x = taskbar_width ;
1062 }
-
1063
-
1064 pos.y = cursor_pos.y - popup_height / 2 ;
-
1065 }
-
1066
-
1067 if(!SetWindowPos(
-
1068 hwnd_, HWND_TOP,
-
1069 pos.x, pos.y, popup_width, popup_height,
-
1070 SWP_SHOWWINDOW)) {
-
1071 return false ;
-
1072 }
-
1073
-
1074 for(std::size_t i = 0 ; i < menus_.size() ; i ++) {
-
1075 auto& menu = menus_[i] ;
-
1076 auto y = \
-
1077 menu_y_margin_
-
1078 + static_cast<LONG>(i) * (menu_height + menu_y_margin_) ;
-
1079 if(!SetWindowPos(
-
1080 menu.window_handle(), HWND_TOP,
-
1081 menu_x_margin_, y,
-
1082 menu_width, menu_height,
-
1083 SWP_SHOWWINDOW)) {
-
1084 return false ;
-
1085 }
-
1086
-
1087 if(!menu.set_color(text_color_, back_color_, ash_color_)) {
-
1088 return false ;
-
1089 }
-
1090 }
-
1091 std::fill(mouse_is_over_.begin(), mouse_is_over_.end(), false) ;
-
1092
-
1093 if(!SetForegroundWindow(hwnd_)) {
-
1094 return false ;
+
1063 else {
+
1064 //right
+
1065 // add 20% offset
+
1066 pos.x = popup_width + 12 * taskbar_width / 10 ;
+
1067 }
+
1068
+
1069 pos.y = cursor_pos.y - popup_height / 2 ;
+
1070 }
+
1071
+
1072 if(!SetWindowPos(
+
1073 hwnd_, HWND_TOP,
+
1074 pos.x, pos.y, popup_width, popup_height,
+
1075 SWP_SHOWWINDOW)) {
+
1076 return false ;
+
1077 }
+
1078
+
1079 for(std::size_t i = 0 ; i < menus_.size() ; i ++) {
+
1080 auto& menu = menus_[i] ;
+
1081 auto y = \
+
1082 menu_y_margin_
+
1083 + static_cast<LONG>(i) * (menu_height + menu_y_margin_) ;
+
1084 if(!SetWindowPos(
+
1085 menu.window_handle(), HWND_TOP,
+
1086 menu_x_margin_, y,
+
1087 menu_width, menu_height,
+
1088 SWP_SHOWWINDOW)) {
+
1089 return false ;
+
1090 }
+
1091
+
1092 if(!menu.set_color(text_color_, back_color_, ash_color_)) {
+
1093 return false ;
+
1094 }
1095 }
-
1096
-
1097 visible_ = true ;
-
1098
-
1099 return true ;
-
1100 }
-
+
1096 std::fill(mouse_is_over_.begin(), mouse_is_over_.end(), false) ;
+
1097
+
1098 if(!SetForegroundWindow(hwnd_)) {
+
1099 return false ;
+
1100 }
1101
-
- -
1107 if(!ShowWindow(hwnd_, SW_HIDE)) {
-
1108 return false ;
-
1109 }
-
1110 visible_ = false ;
-
1111
-
1112 std::fill(mouse_is_over_.begin(), mouse_is_over_.end(), false) ;
-
1113 return true ;
-
1114 }
+
1102 visible_ = true ;
+
1103
+
1104 return true ;
+
1105 }
-
1115
-
-
1120 TrayStatus status() const noexcept {
-
1121 return status_ ;
-
1122 }
+
1106
+
+ +
1112 ShowWindow(hwnd_, SW_HIDE) ;
+
1113 visible_ = false ;
+
1114 std::fill(mouse_is_over_.begin(), mouse_is_over_.end(), false) ;
+
1115 return true ;
+
1116 }
-
1123
-
-
1127 void stop() noexcept {
-
1128 status_ = TrayStatus::SHOULD_STOP ;
-
1129 }
+
1117
+
+
1122 TrayStatus status() const noexcept {
+
1123 return status_ ;
+
1124 }
-
1130
-
-
1135 std::vector<FluentMenu>::iterator begin() noexcept {
-
1136 return menus_.begin() ;
-
1137 }
+
1125
+
+
1129 void stop() noexcept {
+
1130 status_ = TrayStatus::SHOULD_STOP ;
+
1131 }
-
1138
-
-
1143 std::vector<FluentMenu>::iterator end() noexcept {
-
1144 return menus_.end() ;
-
1145 }
+
1132
+
+
1137 std::vector<FluentMenu>::iterator begin() noexcept {
+
1138 return menus_.begin() ;
+
1139 }
-
1146
-
-
1151 std::vector<FluentMenu>::const_iterator cbegin() const noexcept {
-
1152 return menus_.cbegin() ;
-
1153 }
+
1140
+
+
1145 std::vector<FluentMenu>::iterator end() noexcept {
+
1146 return menus_.end() ;
+
1147 }
-
1154
-
-
1159 std::vector<FluentMenu>::const_iterator cend() const noexcept {
-
1160 return menus_.cend() ;
-
1161 }
+
1148
+
+
1153 std::vector<FluentMenu>::const_iterator cbegin() const noexcept {
+
1154 return menus_.cbegin() ;
+
1155 }
-
1162
-
-
1167 std::size_t count_menus() const noexcept {
-
1168 return menus_.size() ;
-
1169 }
+
1156
+
+
1161 std::vector<FluentMenu>::const_iterator cend() const noexcept {
+
1162 return menus_.cend() ;
+
1163 }
-
1170
-
- -
1180 LONG font_size=0,
-
1181 LONG font_weight=0,
-
1182 const std::string& font_name="") {
-
1183 NONCLIENTMETRICS metrics ;
-
1184 metrics.cbSize = sizeof(metrics) ;
-
1185
-
1186 if(!SystemParametersInfo(
-
1187 SPI_GETNONCLIENTMETRICS,
-
1188 metrics.cbSize, &metrics, 0)) {
-
1189 return false ;
-
1190 }
-
1191
-
1192 auto& logfont = metrics.lfCaptionFont ;
-
1193 if(font_size != 0) {
-
1194 logfont.lfHeight = font_size ;
-
1195 }
-
1196 else {
-
1197 logfont.lfHeight = 20 ;
-
1198 }
-
1199 if(font_weight != 0) {
-
1200 logfont.lfWeight = font_weight ;
-
1201 }
-
1202 else {
-
1203 logfont.lfWeight = FW_MEDIUM ;
-
1204 }
-
1205
-
1206 if(!font_name.empty()) {
-
1207 std::wstring font_name_wide ;
-
1208 if(!util::string2wstring(font_name, font_name_wide)) {
-
1209 return false ;
-
1210 }
-
1211 auto dst = logfont.lfFaceName ;
-
1212
-
1213 if(font_name_wide.size() < LF_FACESIZE) {
-
1214 std::wmemcpy(dst, font_name_wide.c_str(), sizeof(WCHAR) * font_name_wide.length()) ;
-
1215 dst[font_name_wide.size()] = L'\0' ;
-
1216 }
-
1217 else {
-
1218 std::wmemcpy(dst, font_name_wide.c_str(), sizeof(WCHAR) * (LF_FACESIZE - 1)) ;
-
1219 dst[LF_FACESIZE - 1] = L'\0' ;
-
1220 }
-
1221 }
-
1222
-
1223 auto font = CreateFontIndirectW(&logfont) ;
-
1224 if(!font) {
-
1225 return false ;
-
1226 }
-
1227 font_ = font ;
-
1228 menu_font_size_ = std::abs(logfont.lfHeight) ;
-
1229
-
1230 return true;
-
1231 }
+
1164
+
+ +
1170 return menus_.front() ;
+
1171 }
-
1232
-
- -
1241 const COLORREF& text_color=CLR_INVALID,
-
1242 const COLORREF& back_color=CLR_INVALID,
-
1243 unsigned char color_decay=10) {
-
1244 if(back_color == CLR_INVALID) {
-
1245 // Get Taskbar color
-
1246 APPBARDATA abd ;
-
1247 abd.cbSize = sizeof(abd) ;
-
1248 if(!SHAppBarMessage(ABM_GETTASKBARPOS, &abd)) {
-
1249 return false ;
-
1250 }
-
1251
-
1252 if(auto dc = GetDC(NULL)) {
-
1253 // Get Taskbar color
-
1254 back_color_ = GetPixel(dc, abd.rc.left + 1, abd.rc.top + 1) ;
-
1255 if(back_color_ == CLR_INVALID) {
-
1256 // if failed, use COLOR_WINDOW color.
-
1257 back_color_ = GetSysColor(COLOR_WINDOW) ;
-
1258 }
-
1259 if(!ReleaseDC(NULL, dc)) {
-
1260 return false ;
-
1261 }
-
1262 }
-
1263 }
-
1264 else {
-
1265 back_color_ = back_color ;
-
1266 }
-
1267
-
1268 auto back_gray_color_ = util::rgb2gray(back_color_) ;
-
1269
-
1270 unsigned char ash_value = back_gray_color_ ;
-
1271 if(back_gray_color_ < 128) {
-
1272 ash_value = static_cast<decltype(ash_value)>(
-
1273 (std::min)(ash_value + color_decay, 255)) ;
-
1274 }
-
1275 else {
-
1276 ash_value = static_cast<decltype(ash_value)>(
-
1277 (std::max)(ash_value - color_decay, 0)) ;
-
1278 }
-
1279 ash_color_ = RGB(ash_value, ash_value, ash_value) ;
-
1280
-
1281 if(text_color == CLR_INVALID) {
-
1282 text_color_ = GetSysColor(COLOR_WINDOWTEXT) ;
-
1283 if(back_gray_color_ < 128) {
-
1284 // if dark background, use light text color.
-
1285 text_color_ = 0x00FFFFFF & ~text_color_ ;
-
1286 }
-
1287 }
-
1288 else {
-
1289 text_color_ = text_color ;
-
1290 }
-
1291
-
1292 if(back_brush_) {
-
1293 // Release old handle.
-
1294 if(!DeleteObject(back_brush_)) {
-
1295 return false ;
-
1296 }
-
1297 }
-
1298 back_brush_ = CreateSolidBrush(back_color_) ;
-
1299 if(back_brush_ == NULL) {
-
1300 return false ;
-
1301 }
-
1302
-
1303 if(!SetClassLongPtr(
-
1304 hwnd_, GCLP_HBRBACKGROUND,
-
1305 reinterpret_cast<LONG_PTR>(back_brush_))) {
-
1306 return false ;
-
1307 }
-
1308
-
1309 return true ;
-
1310 }
+
1172
+
+
1177 const FluentMenu& front() const {
+
1178 return menus_.front() ;
+
1179 }
+
+
1180
+
+ +
1186 return menus_.back() ;
+
1187 }
-
1311
-
-
1316 bool change_icon(const std::string& icon_path) {
-
1317 if(icon_data_.cbSize > 0) {
-
1318 if(!Shell_NotifyIconW(NIM_DELETE, &icon_data_)) {
-
1319 return false ;
-
1320 }
-
1321 }
-
1322
-
1323 ZeroMemory(&icon_data_, sizeof(icon_data_)) ;
-
1324
-
1325 if(icon_path.empty()) {
-
1326 icon_data_.cbSize = 0 ;
-
1327 return true ;
-
1328 }
-
1329
-
1330 std::wstring icon_path_wide ;
-
1331 if(!util::string2wstring(icon_path, icon_path_wide)) {
-
1332 return false ;
+
1188
+
+
1193 const FluentMenu& back() const {
+
1194 return menus_.back() ;
+
1195 }
+
+
1196
+
+
1201 std::size_t count_menus() const noexcept {
+
1202 return menus_.size() ;
+
1203 }
+
+
1204
+
+ +
1214 LONG font_size=0,
+
1215 LONG font_weight=0,
+
1216 const std::string& font_name="") {
+
1217 NONCLIENTMETRICSW metrics ;
+
1218 metrics.cbSize = sizeof(metrics) ;
+
1219
+
1220 if(!SystemParametersInfoW(
+
1221 SPI_GETNONCLIENTMETRICS,
+
1222 metrics.cbSize, &metrics, 0)) {
+
1223 return false ;
+
1224 }
+
1225
+
1226 auto& logfont = metrics.lfCaptionFont ;
+
1227 if(font_size != 0) {
+
1228 logfont.lfHeight = font_size ;
+
1229 }
+
1230 else {
+
1231 logfont.lfHeight = 20 ;
+
1232 }
+
1233 if(font_weight != 0) {
+
1234 logfont.lfWeight = font_weight ;
+
1235 }
+
1236 else {
+
1237 logfont.lfWeight = FW_MEDIUM ;
+
1238 }
+
1239
+
1240 if(!font_name.empty()) {
+
1241 std::wstring font_name_wide ;
+
1242 if(!util::string2wstring(font_name, font_name_wide)) {
+
1243 return false ;
+
1244 }
+
1245 auto& dst = logfont.lfFaceName ;
+
1246
+
1247 if(font_name_wide.size() < LF_FACESIZE) {
+
1248 std::wmemcpy(
+
1249 dst, font_name_wide.c_str(), font_name_wide.length()) ;
+
1250 dst[font_name_wide.size()] = L'\0' ;
+
1251 }
+
1252 else {
+
1253 std::wmemcpy(
+
1254 dst, font_name_wide.c_str(), LF_FACESIZE - 1) ;
+
1255 dst[LF_FACESIZE - 1] = L'\0' ;
+
1256 }
+
1257 }
+
1258
+
1259 auto font = CreateFontIndirectW(&logfont) ;
+
1260 if(!font) {
+
1261 return false ;
+
1262 }
+
1263 font_ = font ;
+
1264 menu_font_size_ = std::abs(logfont.lfHeight) ;
+
1265
+
1266 return true;
+
1267 }
+
+
1268
+
+ +
1277 const COLORREF& text_color=CLR_INVALID,
+
1278 const COLORREF& back_color=CLR_INVALID,
+
1279 unsigned char color_decay=10) {
+
1280 if(back_color == CLR_INVALID) {
+
1281 // Get Taskbar color
+
1282 APPBARDATA abd ;
+
1283 abd.cbSize = sizeof(abd) ;
+
1284 if(!SHAppBarMessage(ABM_GETTASKBARPOS, &abd)) {
+
1285 return false ;
+
1286 }
+
1287
+
1288 if(auto dc = GetDC(NULL)) {
+
1289 // Get Taskbar color
+
1290 back_color_ = GetPixel(dc, abd.rc.left + 1, abd.rc.top + 1) ;
+
1291 if(back_color_ == CLR_INVALID) {
+
1292 // if failed, use COLOR_WINDOW color.
+
1293 back_color_ = GetSysColor(COLOR_WINDOW) ;
+
1294 }
+
1295 if(!ReleaseDC(NULL, dc)) {
+
1296 return false ;
+
1297 }
+
1298 }
+
1299 }
+
1300 else {
+
1301 back_color_ = back_color ;
+
1302 }
+
1303
+
1304 auto back_gray_color_ = util::rgb2gray(back_color_) ;
+
1305
+
1306 unsigned char ash_value = back_gray_color_ ;
+
1307 if(back_gray_color_ < 128) {
+
1308 ash_value = static_cast<decltype(ash_value)>(
+
1309 (std::min)(ash_value + color_decay, 255)) ;
+
1310 }
+
1311 else {
+
1312 ash_value = static_cast<decltype(ash_value)>(
+
1313 (std::max)(ash_value - color_decay, 0)) ;
+
1314 }
+
1315 ash_color_ = RGB(ash_value, ash_value, ash_value) ;
+
1316
+
1317 if(text_color == CLR_INVALID) {
+
1318 text_color_ = GetSysColor(COLOR_WINDOWTEXT) ;
+
1319 if(back_gray_color_ < 128) {
+
1320 // if dark background, use light text color.
+
1321 text_color_ = 0x00FFFFFF & ~text_color_ ;
+
1322 }
+
1323 }
+
1324 else {
+
1325 text_color_ = text_color ;
+
1326 }
+
1327
+
1328 if(back_brush_) {
+
1329 // Release old handle.
+
1330 if(!DeleteObject(back_brush_)) {
+
1331 return false ;
+
1332 }
1333 }
-
1334
-
1335 if(!util::exists(icon_path_wide)) {
+
1334 back_brush_ = CreateSolidBrush(back_color_) ;
+
1335 if(back_brush_ == NULL) {
1336 return false ;
1337 }
1338
-
1339 icon_data_.cbSize = sizeof(icon_data_) ;
-
1340 icon_data_.hWnd = hwnd_ ;
-
1341 icon_data_.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP ;
-
1342 icon_data_.uCallbackMessage = MESSAGE_ID ;
-
1343 icon_data_.hIcon = static_cast<HICON>(
-
1344 LoadImageW(
-
1345 NULL, icon_path_wide.c_str(),
-
1346 IMAGE_ICON, 0, 0, LR_LOADFROMFILE)) ;
-
1347 wcscpy_s(icon_data_.szTip, app_name_.c_str()) ;
-
1348 icon_data_.dwState = NIS_SHAREDICON ;
-
1349 icon_data_.dwStateMask = NIS_SHAREDICON ;
-
1350
-
1351 if(!Shell_NotifyIconW(NIM_ADD, &icon_data_)) {
-
1352 return false ;
-
1353 }
- -
1355
-
1356 return true ;
-
1357 }
+
1339 if(!SetClassLongPtr(
+
1340 hwnd_, GCLP_HBRBACKGROUND,
+
1341 reinterpret_cast<LONG_PTR>(back_brush_))) {
+
1342 return false ;
+
1343 }
+
1344
+
1345 return true ;
+
1346 }
+
1347
+
+
1352 bool change_icon(const std::string& icon_path) {
+
1353 if(icon_data_.cbSize > 0) {
+
1354 if(!Shell_NotifyIconW(NIM_DELETE, &icon_data_)) {
+
1355 return false ;
+
1356 }
+
1357 }
1358
-
1359 private:
-
1360 static LRESULT CALLBACK callback(
-
1361 HWND hwnd,
-
1362 UINT msg,
-
1363 WPARAM wparam,
-
1364 LPARAM lparam) {
-
1365 auto get_instance = [hwnd]() -> FluentTray* {
-
1366 auto upper_addr = GetWindowLongW(hwnd, 0) ;
-
1367 if(!upper_addr) {
-
1368 return nullptr ;
-
1369 }
+
1359 ZeroMemory(&icon_data_, sizeof(icon_data_)) ;
+
1360
+
1361 if(icon_path.empty()) {
+
1362 icon_data_.cbSize = 0 ;
+
1363 return true ;
+
1364 }
+
1365
+
1366 std::wstring icon_path_wide ;
+
1367 if(!util::string2wstring(icon_path, icon_path_wide)) {
+
1368 return false ;
+
1369 }
1370
-
1371 auto lower_addr = GetWindowLongW(hwnd, sizeof(LONG)) ;
-
1372 if(!lower_addr) {
-
1373 return nullptr ;
-
1374 }
-
1375
-
1376 FluentTray* self ;
-
1377 util::concatenate_bits(upper_addr, lower_addr, self) ;
-
1378 return self ;
-
1379 } ;
-
1380
-
1381 if(msg == WM_DESTROY || msg == WM_QUIT || msg == WM_CLOSE) {
-
1382 if(auto self = get_instance()) {
-
1383 self->stop() ;
-
1384 return 0 ;
-
1385 }
-
1386 }
-
1387 else if(msg == WM_ACTIVATE && wparam == WA_INACTIVE) {
-
1388 if(auto self = get_instance()) {
-
1389 if(!self->hide_menu_window()) {
-
1390 self->fail() ;
-
1391 }
-
1392 return 0 ;
-
1393 }
-
1394 }
-
1395 else if(msg == WM_DRAWITEM) {
-
1396 if(auto self = get_instance()) {
-
1397 auto item = reinterpret_cast<LPDRAWITEMSTRUCT>(lparam) ;
-
1398 auto menu_idx = self->get_menu_index_from_window(item->hwndItem) ;
-
1399 if(menu_idx < 0) {
-
1400 return FALSE ;
-
1401 }
-
1402 auto& menu = self->menus_[menu_idx] ;
-
1403 if(!menu.draw_menu(item, self->font_)) {
-
1404 self->fail() ;
-
1405 return FALSE ;
-
1406 }
-
1407 return TRUE ;
-
1408 }
-
1409 }
-
1410 else if(msg == WM_CTLCOLORBTN) {
-
1411 if(auto self = get_instance()) {
-
1412 auto menu_idx = self->get_menu_index_from_window(reinterpret_cast<HWND>(lparam)) ;
-
1413 if(menu_idx < 0) {
-
1414 return DefWindowProc(hwnd, msg, wparam, lparam) ;
-
1415 }
-
1416 auto& menu = self->menus_[menu_idx] ;
-
1417 return reinterpret_cast<LRESULT>(menu.background_brush()) ;
-
1418 }
-
1419 }
-
1420 else if(msg == WM_COMMAND) {
-
1421 if(auto self = get_instance()) {
-
1422 auto menu_idx = self->get_menu_index_from_id(LOWORD(wparam)) ;
-
1423 if(menu_idx < 0) {
-
1424 return FALSE ;
-
1425 }
-
1426 auto& menu = self->menus_[menu_idx] ;
-
1427 if(!menu.process_click_event()) {
-
1428 self->stop() ;
-
1429 return FALSE ;
-
1430 }
-
1431 if(menu.is_toggleable()) {
-
1432 // Update the toggle menu for checkmark
-
1433 if(!InvalidateRect(menu.window_handle(), NULL, TRUE)) {
-
1434 return false ;
-
1435 }
-
1436 }
-
1437 return TRUE ;
-
1438 }
-
1439 }
-
1440 else if(msg == MESSAGE_ID) { //On NotifyIcon
-
1441 if(auto self = get_instance()) {
-
1442 if(lparam == WM_LBUTTONUP || lparam == WM_RBUTTONUP) {
-
1443 self->show_menu_window() ;
-
1444 return 0 ;
-
1445 }
-
1446 }
-
1447 }
-
1448
-
1449 return DefWindowProc(hwnd, msg, wparam, lparam) ;
-
1450 }
-
1451
-
1452 int get_menu_index_from_window(HWND hwnd) {
-
1453 int i = 0 ;
-
1454 for(auto& m : menus_) {
-
1455 if(m.window_handle() == hwnd) {
-
1456 return i ;
-
1457 }
-
1458 i ++ ;
-
1459 }
-
1460 return -1 ;
-
1461 }
-
1462
-
1463 int get_menu_index_from_id(WORD id) {
-
1464 int i = 0 ;
-
1465 for(auto& m : menus_) {
-
1466 if(m.id() == static_cast<std::size_t>(id)) {
-
1467 return i ;
-
1468 }
-
1469 i ++ ;
-
1470 }
-
1471 return -1 ;
-
1472 }
-
1473
-
1474 void get_message(MSG& message) {
-
1475 if(PeekMessage(&message, hwnd_, 0, 0, PM_REMOVE)) {
-
1476 DispatchMessage(&message) ;
-
1477 }
-
1478 }
-
1479
-
1480 void fail() noexcept {
-
1481 status_ = TrayStatus::FAILED ;
-
1482 }
-
1483
-
1484 bool change_menu_back_color(FluentMenu& menu, COLORREF new_color) {
-
1485 if(!menu.set_color(
-
1486 text_color_, new_color, ash_color_)) {
-
1487 return false ;
-
1488 }
-
1489 // Redraw
-
1490 if(!InvalidateRect(menu.window_handle(), NULL, TRUE)) {
-
1491 return false ;
-
1492 }
-
1493 return true ;
-
1494 }
-
1495 } ;
+
1371 if(!util::exists(icon_path_wide)) {
+
1372 return false ;
+
1373 }
+
1374
+
1375 icon_data_.cbSize = sizeof(icon_data_) ;
+
1376 icon_data_.hWnd = hwnd_ ;
+
1377 icon_data_.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP ;
+
1378 icon_data_.uCallbackMessage = MESSAGE_ID ;
+
1379 icon_data_.hIcon = static_cast<HICON>(
+
1380 LoadImageW(
+
1381 NULL, icon_path_wide.c_str(),
+
1382 IMAGE_ICON, 0, 0, LR_LOADFROMFILE)) ;
+
1383 wcscpy_s(icon_data_.szTip, app_name_.c_str()) ;
+
1384 icon_data_.dwState = NIS_SHAREDICON ;
+
1385 icon_data_.dwStateMask = NIS_SHAREDICON ;
+
1386
+
1387 if(!Shell_NotifyIconW(NIM_ADD, &icon_data_)) {
+
1388 return false ;
+
1389 }
+ +
1391
+
1392 return true ;
+
1393 }
+
+
1394
+
1395 private:
+
1396 static LRESULT CALLBACK callback(
+
1397 HWND hwnd,
+
1398 UINT msg,
+
1399 WPARAM wparam,
+
1400 LPARAM lparam) {
+
1401 auto get_instance = [hwnd]() -> FluentTray* {
+
1402 auto upper_addr = GetWindowLongW(hwnd, 0) ;
+
1403 if(!upper_addr) {
+
1404 return nullptr ;
+
1405 }
+
1406
+
1407 auto lower_addr = GetWindowLongW(hwnd, sizeof(LONG)) ;
+
1408 if(!lower_addr) {
+
1409 return nullptr ;
+
1410 }
+
1411
+
1412 FluentTray* self ;
+
1413 util::concatenate_bits(upper_addr, lower_addr, self) ;
+
1414 return self ;
+
1415 } ;
+
1416
+
1417 if(msg == WM_DESTROY || msg == WM_QUIT || msg == WM_CLOSE) {
+
1418 if(auto self = get_instance()) {
+
1419 self->stop() ;
+
1420 return 0 ;
+
1421 }
+
1422 }
+
1423 else if(msg == WM_ACTIVATE && wparam == WA_INACTIVE) {
+
1424 if(auto self = get_instance()) {
+
1425 if(!self->hide_menu_window()) {
+
1426 self->fail() ;
+
1427 }
+
1428 return 0 ;
+
1429 }
+
1430 }
+
1431 else if(msg == WM_DRAWITEM) {
+
1432 if(auto self = get_instance()) {
+
1433 auto item = reinterpret_cast<LPDRAWITEMSTRUCT>(lparam) ;
+
1434 auto menu_idx = self->get_menu_index_from_window(item->hwndItem) ;
+
1435 if(menu_idx < 0) {
+
1436 return FALSE ;
+
1437 }
+
1438 auto& menu = self->menus_[menu_idx] ;
+
1439 if(!menu.draw_menu(item, self->font_)) {
+
1440 self->fail() ;
+
1441 return FALSE ;
+
1442 }
+
1443 return TRUE ;
+
1444 }
+
1445 }
+
1446 else if(msg == WM_CTLCOLORBTN) {
+
1447 if(auto self = get_instance()) {
+
1448 auto menu_idx = self->get_menu_index_from_window(reinterpret_cast<HWND>(lparam)) ;
+
1449 if(menu_idx < 0) {
+
1450 return DefWindowProc(hwnd, msg, wparam, lparam) ;
+
1451 }
+
1452 auto& menu = self->menus_[menu_idx] ;
+
1453 return reinterpret_cast<LRESULT>(menu.background_brush()) ;
+
1454 }
+
1455 }
+
1456 else if(msg == WM_COMMAND) {
+
1457 if(auto self = get_instance()) {
+
1458 auto menu_idx = self->get_menu_index_from_id(LOWORD(wparam)) ;
+
1459 if(menu_idx < 0) {
+
1460 return FALSE ;
+
1461 }
+
1462 auto& menu = self->menus_[menu_idx] ;
+
1463 if(!menu.process_click_event()) {
+
1464 self->stop() ;
+
1465 return FALSE ;
+
1466 }
+
1467 if(menu.is_toggleable()) {
+
1468 // Update the toggle menu for checkmark
+
1469 if(!InvalidateRect(menu.window_handle(), NULL, TRUE)) {
+
1470 return false ;
+
1471 }
+
1472 }
+
1473 return TRUE ;
+
1474 }
+
1475 }
+
1476 else if(msg == MESSAGE_ID) { //On NotifyIcon
+
1477 if(auto self = get_instance()) {
+
1478 if(lparam == WM_LBUTTONUP || lparam == WM_RBUTTONUP) {
+
1479 self->show_menu_window() ;
+
1480 return 0 ;
+
1481 }
+
1482 }
+
1483 }
+
1484
+
1485 return DefWindowProc(hwnd, msg, wparam, lparam) ;
+
1486 }
+
1487
+
1488 int get_menu_index_from_window(HWND hwnd) {
+
1489 int i = 0 ;
+
1490 for(auto& m : menus_) {
+
1491 if(m.window_handle() == hwnd) {
+
1492 return i ;
+
1493 }
+
1494 i ++ ;
+
1495 }
+
1496 return -1 ;
+
1497 }
+
1498
+
1499 int get_menu_index_from_id(WORD id) {
+
1500 int i = 0 ;
+
1501 for(auto& m : menus_) {
+
1502 if(m.id() == static_cast<std::size_t>(id)) {
+
1503 return i ;
+
1504 }
+
1505 i ++ ;
+
1506 }
+
1507 return -1 ;
+
1508 }
+
1509
+
1510 void get_message(MSG& message) {
+
1511 if(PeekMessage(&message, hwnd_, 0, 0, PM_REMOVE)) {
+
1512 DispatchMessage(&message) ;
+
1513 }
+
1514 }
+
1515
+
1516 void fail() noexcept {
+
1517 status_ = TrayStatus::FAILED ;
+
1518 }
+
1519
+
1520 bool change_menu_back_color(FluentMenu& menu, COLORREF new_color) {
+
1521 if(!menu.set_color(
+
1522 text_color_, new_color, ash_color_)) {
+
1523 return false ;
+
1524 }
+
1525 // Redraw
+
1526 if(!InvalidateRect(menu.window_handle(), NULL, TRUE)) {
+
1527 return false ;
+
1528 }
+
1529 return true ;
+
1530 }
+
1531 } ;
-
1496}
-
1497
-
1498#endif
+
1532}
+
1533
+
1534#endif
Class with information on each menu.
Definition fluent_tray.hpp:258
bool is_mouse_over() const
Checks whether the mouse cursor is over the menu or not.
Definition fluent_tray.hpp:403
bool set_color(const COLORREF &text_color=CLR_INVALID, const COLORREF &back_color=CLR_INVALID, const COLORREF &border_color=CLR_INVALID) noexcept
Set the menu color.
Definition fluent_tray.hpp:508
@@ -1445,29 +1473,33 @@
FluentMenu(const FluentMenu &)=default
Class with information on the entire tray.
Definition fluent_tray.hpp:680
virtual ~FluentTray() noexcept
Definition fluent_tray.hpp:744
-
std::vector< FluentMenu >::iterator end() noexcept
Returns an iterator to the end of menus.
Definition fluent_tray.hpp:1143
+
std::vector< FluentMenu >::iterator end() noexcept
Returns an iterator to the end of menus.
Definition fluent_tray.hpp:1145
FluentTray & operator=(const FluentTray &)=delete
-
bool show_menu_window()
Show the menu window above the tray icon.
Definition fluent_tray.hpp:1001
+
bool show_menu_window()
Show the menu window above the tray icon.
Definition fluent_tray.hpp:1006
bool create_tray(const std::string &app_name, const std::string &icon_path="", LONG menu_x_margin=5, LONG menu_y_margin=5, LONG menu_x_pad=5, LONG menu_y_pad=5, unsigned char opacity=255, bool round_corner=true)
Initialize tray and create icon on tray.
Definition fluent_tray.hpp:765
-
void stop() noexcept
Exit the tray successfully.
Definition fluent_tray.hpp:1127
+
void stop() noexcept
Exit the tray successfully.
Definition fluent_tray.hpp:1129
FluentTray & operator=(FluentTray &&)=default
bool add_menu(const std::string &label_text="", const std::string &icon_path="", bool toggleable=false, const std::string &checkmark="✓", const std::function< bool(void)> &callback=[] {return true ;}, const std::function< bool(void)> &unchecked_callback=[] {return true ;})
Add a menu in order from the top.
Definition fluent_tray.hpp:898
-
bool set_font(LONG font_size=0, LONG font_weight=0, const std::string &font_name="")
Set font information to draw menus.
Definition fluent_tray.hpp:1179
-
TrayStatus status() const noexcept
Get the current status of tray.
Definition fluent_tray.hpp:1120
-
bool change_icon(const std::string &icon_path)
Load the image file and change the icon.
Definition fluent_tray.hpp:1316
+
bool set_font(LONG font_size=0, LONG font_weight=0, const std::string &font_name="")
Set font information to draw menus.
Definition fluent_tray.hpp:1213
+
TrayStatus status() const noexcept
Get the current status of tray.
Definition fluent_tray.hpp:1122
+
const FluentMenu & back() const
Returns the const reference to the last of menus.
Definition fluent_tray.hpp:1193
+
bool change_icon(const std::string &icon_path)
Load the image file and change the icon.
Definition fluent_tray.hpp:1352
FluentTray()
Create tray object.
Definition fluent_tray.hpp:714
-
std::size_t count_menus() const noexcept
Returns the number of menus.
Definition fluent_tray.hpp:1167
-
bool update_with_loop(std::chrono::milliseconds sleep_time=std::chrono::milliseconds(1))
Create a message loop to update the tray.
Definition fluent_tray.hpp:971
-
std::vector< FluentMenu >::const_iterator cbegin() const noexcept
Returns a constant iterator to the beginning of menus.
Definition fluent_tray.hpp:1151
-
std::vector< FluentMenu >::const_iterator cend() const noexcept
Returns a constant iterator to the end of menus.
Definition fluent_tray.hpp:1159
-
bool set_color(const COLORREF &text_color=CLR_INVALID, const COLORREF &back_color=CLR_INVALID, unsigned char color_decay=10)
Set colors to draw menus.
Definition fluent_tray.hpp:1240
+
std::size_t count_menus() const noexcept
Returns the number of menus.
Definition fluent_tray.hpp:1201
+
bool update_with_loop(std::chrono::milliseconds sleep_time=std::chrono::milliseconds(1))
Create a message loop to update the tray.
Definition fluent_tray.hpp:976
+
std::vector< FluentMenu >::const_iterator cbegin() const noexcept
Returns a constant iterator to the beginning of menus.
Definition fluent_tray.hpp:1153
+
std::vector< FluentMenu >::const_iterator cend() const noexcept
Returns a constant iterator to the end of menus.
Definition fluent_tray.hpp:1161
+
const FluentMenu & front() const
Returns the const reference to the beginning of menus.
Definition fluent_tray.hpp:1177
+
bool set_color(const COLORREF &text_color=CLR_INVALID, const COLORREF &back_color=CLR_INVALID, unsigned char color_decay=10)
Set colors to draw menus.
Definition fluent_tray.hpp:1276
void add_separator()
Add a separator line under the last menu item added.
Definition fluent_tray.hpp:921
-
bool hide_menu_window()
Hide the menu window above the tray icon.
Definition fluent_tray.hpp:1106
+
bool hide_menu_window()
Hide the menu window above the tray icon.
Definition fluent_tray.hpp:1111
FluentTray(const FluentTray &)=delete
+
FluentMenu & front()
Returns the reference to the beginning of menus.
Definition fluent_tray.hpp:1169
FluentTray(FluentTray &&)=default
-
HWND window_handle() const noexcept
Refer to the handle of menu window.
Definition fluent_tray.hpp:993
-
std::vector< FluentMenu >::iterator begin() noexcept
Returns an iterator to the beginning of menus.
Definition fluent_tray.hpp:1135
+
HWND window_handle() const noexcept
Refer to the handle of menu window.
Definition fluent_tray.hpp:998
+
std::vector< FluentMenu >::iterator begin() noexcept
Returns an iterator to the beginning of menus.
Definition fluent_tray.hpp:1137
bool update()
Get window message and update tray.
Definition fluent_tray.hpp:931
+
FluentMenu & back()
Returns the reference to the last of menus.
Definition fluent_tray.hpp:1185
#define FLUENT_TRAY_MESSAGE_ID_OFFSET
Unique message identifier.
Definition fluent_tray.hpp:82
bool exists(const std::wstring &path)
Checks if the file exists.
Definition fluent_tray.hpp:231
constexpr std::size_t bit2mask(std::size_t bits) noexcept
Generates a mask with the specified number of lower bits set to 1.
Definition fluent_tray.hpp:168
diff --git a/docs/functions.html b/docs/functions.html index 8d8e478..85216c2 100644 --- a/docs/functions.html +++ b/docs/functions.html @@ -83,6 +83,7 @@

- a -

    - b -

    @@ -113,6 +114,7 @@

    - e -

      - f -

      diff --git a/docs/functions_func.html b/docs/functions_func.html index a59b803..58fb03b 100644 --- a/docs/functions_func.html +++ b/docs/functions_func.html @@ -83,6 +83,7 @@

      - a -

        - b -

        @@ -113,6 +114,7 @@

        - e -

          - f -

          diff --git a/docs/search/all_1.js b/docs/search/all_1.js index ae790d5..5655109 100644 --- a/docs/search/all_1.js +++ b/docs/search/all_1.js @@ -1,7 +1,8 @@ var searchData= [ - ['background_5fbrush_0',['background_brush',['../classfluent__tray_1_1_fluent_menu.html#ac01651560401f01ca7197ba6d02b2e48',1,'fluent_tray::FluentMenu']]], - ['begin_1',['begin',['../classfluent__tray_1_1_fluent_tray.html#ae125994bac6b48aa54e0276829983598',1,'fluent_tray::FluentTray']]], - ['bit2mask_2',['bit2mask',['../namespacefluent__tray_1_1util.html#a342a1de166e89ef94dfd171c84fd2cfe',1,'fluent_tray::util']]], - ['build_3',['Build',['../index.html#autotoc_md3',1,'']]] + ['back_0',['back',['../classfluent__tray_1_1_fluent_tray.html#afce8252232da76937872e263d5fe925f',1,'fluent_tray::FluentTray::back()'],['../classfluent__tray_1_1_fluent_tray.html#a63dfc8e752b444100a525f27b1b96db1',1,'fluent_tray::FluentTray::back() const']]], + ['background_5fbrush_1',['background_brush',['../classfluent__tray_1_1_fluent_menu.html#ac01651560401f01ca7197ba6d02b2e48',1,'fluent_tray::FluentMenu']]], + ['begin_2',['begin',['../classfluent__tray_1_1_fluent_tray.html#ae125994bac6b48aa54e0276829983598',1,'fluent_tray::FluentTray']]], + ['bit2mask_3',['bit2mask',['../namespacefluent__tray_1_1util.html#a342a1de166e89ef94dfd171c84fd2cfe',1,'fluent_tray::util']]], + ['build_4',['Build',['../index.html#autotoc_md3',1,'']]] ]; diff --git a/docs/search/all_5.js b/docs/search/all_5.js index 142ecd7..f9e8794 100644 --- a/docs/search/all_5.js +++ b/docs/search/all_5.js @@ -7,5 +7,6 @@ var searchData= ['fluent_5ftray_3a_3autil_4',['util',['../namespacefluent__tray_1_1util.html',1,'fluent_tray']]], ['fluent_5ftray_5fmessage_5fid_5foffset_5',['FLUENT_TRAY_MESSAGE_ID_OFFSET',['../fluent__tray_8hpp.html#a5f249b81cc5c7fbeee48724fbc1ede20',1,'fluent_tray.hpp']]], ['fluentmenu_6',['FluentMenu',['../classfluent__tray_1_1_fluent_menu.html',1,'fluent_tray::FluentMenu'],['../classfluent__tray_1_1_fluent_menu.html#a55a1de08b1e116b71f2225b76fa1a8ff',1,'fluent_tray::FluentMenu::FluentMenu(bool toggleable=false, const std::function< bool(void)> &callback=[] {return true ;}, const std::function< bool(void)> &unchecked_callback=[] {return true ;})'],['../classfluent__tray_1_1_fluent_menu.html#ae65751fe8b47abcae26e99d2cc092c85',1,'fluent_tray::FluentMenu::FluentMenu(const FluentMenu &)=default'],['../classfluent__tray_1_1_fluent_menu.html#a68503bfb45988babdad9d70be8633698',1,'fluent_tray::FluentMenu::FluentMenu(FluentMenu &&)=default']]], - ['fluenttray_7',['FluentTray',['../classfluent__tray_1_1_fluent_tray.html',1,'fluent_tray::FluentTray'],['../classfluent__tray_1_1_fluent_tray.html#a6a6631acc765ddc89ba36976bbe0175f',1,'fluent_tray::FluentTray::FluentTray()'],['../classfluent__tray_1_1_fluent_tray.html#ac538f9a69ab74ead314a5004f717080f',1,'fluent_tray::FluentTray::FluentTray(const FluentTray &)=delete'],['../classfluent__tray_1_1_fluent_tray.html#adc5d4b971a378080dea22225c0a8e3a1',1,'fluent_tray::FluentTray::FluentTray(FluentTray &&)=default']]] + ['fluenttray_7',['FluentTray',['../classfluent__tray_1_1_fluent_tray.html',1,'fluent_tray::FluentTray'],['../classfluent__tray_1_1_fluent_tray.html#a6a6631acc765ddc89ba36976bbe0175f',1,'fluent_tray::FluentTray::FluentTray()'],['../classfluent__tray_1_1_fluent_tray.html#ac538f9a69ab74ead314a5004f717080f',1,'fluent_tray::FluentTray::FluentTray(const FluentTray &)=delete'],['../classfluent__tray_1_1_fluent_tray.html#adc5d4b971a378080dea22225c0a8e3a1',1,'fluent_tray::FluentTray::FluentTray(FluentTray &&)=default']]], + ['front_8',['front',['../classfluent__tray_1_1_fluent_tray.html#acd10bcf8769e9851026dd1302323cc90',1,'fluent_tray::FluentTray::front()'],['../classfluent__tray_1_1_fluent_tray.html#a974f39be7c66bf61750de98331b063c3',1,'fluent_tray::FluentTray::front() const']]] ]; diff --git a/docs/search/functions_1.js b/docs/search/functions_1.js index 3375426..8f3be7b 100644 --- a/docs/search/functions_1.js +++ b/docs/search/functions_1.js @@ -1,6 +1,7 @@ var searchData= [ - ['background_5fbrush_0',['background_brush',['../classfluent__tray_1_1_fluent_menu.html#ac01651560401f01ca7197ba6d02b2e48',1,'fluent_tray::FluentMenu']]], - ['begin_1',['begin',['../classfluent__tray_1_1_fluent_tray.html#ae125994bac6b48aa54e0276829983598',1,'fluent_tray::FluentTray']]], - ['bit2mask_2',['bit2mask',['../namespacefluent__tray_1_1util.html#a342a1de166e89ef94dfd171c84fd2cfe',1,'fluent_tray::util']]] + ['back_0',['back',['../classfluent__tray_1_1_fluent_tray.html#afce8252232da76937872e263d5fe925f',1,'fluent_tray::FluentTray::back()'],['../classfluent__tray_1_1_fluent_tray.html#a63dfc8e752b444100a525f27b1b96db1',1,'fluent_tray::FluentTray::back() const']]], + ['background_5fbrush_1',['background_brush',['../classfluent__tray_1_1_fluent_menu.html#ac01651560401f01ca7197ba6d02b2e48',1,'fluent_tray::FluentMenu']]], + ['begin_2',['begin',['../classfluent__tray_1_1_fluent_tray.html#ae125994bac6b48aa54e0276829983598',1,'fluent_tray::FluentTray']]], + ['bit2mask_3',['bit2mask',['../namespacefluent__tray_1_1util.html#a342a1de166e89ef94dfd171c84fd2cfe',1,'fluent_tray::util']]] ]; diff --git a/docs/search/functions_5.js b/docs/search/functions_5.js index 3c9dced..9763fd0 100644 --- a/docs/search/functions_5.js +++ b/docs/search/functions_5.js @@ -1,5 +1,6 @@ var searchData= [ ['fluentmenu_0',['FluentMenu',['../classfluent__tray_1_1_fluent_menu.html#a55a1de08b1e116b71f2225b76fa1a8ff',1,'fluent_tray::FluentMenu::FluentMenu(bool toggleable=false, const std::function< bool(void)> &callback=[] {return true ;}, const std::function< bool(void)> &unchecked_callback=[] {return true ;})'],['../classfluent__tray_1_1_fluent_menu.html#ae65751fe8b47abcae26e99d2cc092c85',1,'fluent_tray::FluentMenu::FluentMenu(const FluentMenu &)=default'],['../classfluent__tray_1_1_fluent_menu.html#a68503bfb45988babdad9d70be8633698',1,'fluent_tray::FluentMenu::FluentMenu(FluentMenu &&)=default']]], - ['fluenttray_1',['FluentTray',['../classfluent__tray_1_1_fluent_tray.html#a6a6631acc765ddc89ba36976bbe0175f',1,'fluent_tray::FluentTray::FluentTray()'],['../classfluent__tray_1_1_fluent_tray.html#ac538f9a69ab74ead314a5004f717080f',1,'fluent_tray::FluentTray::FluentTray(const FluentTray &)=delete'],['../classfluent__tray_1_1_fluent_tray.html#adc5d4b971a378080dea22225c0a8e3a1',1,'fluent_tray::FluentTray::FluentTray(FluentTray &&)=default']]] + ['fluenttray_1',['FluentTray',['../classfluent__tray_1_1_fluent_tray.html#a6a6631acc765ddc89ba36976bbe0175f',1,'fluent_tray::FluentTray::FluentTray()'],['../classfluent__tray_1_1_fluent_tray.html#ac538f9a69ab74ead314a5004f717080f',1,'fluent_tray::FluentTray::FluentTray(const FluentTray &)=delete'],['../classfluent__tray_1_1_fluent_tray.html#adc5d4b971a378080dea22225c0a8e3a1',1,'fluent_tray::FluentTray::FluentTray(FluentTray &&)=default']]], + ['front_2',['front',['../classfluent__tray_1_1_fluent_tray.html#acd10bcf8769e9851026dd1302323cc90',1,'fluent_tray::FluentTray::front()'],['../classfluent__tray_1_1_fluent_tray.html#a974f39be7c66bf61750de98331b063c3',1,'fluent_tray::FluentTray::front() const']]] ]; diff --git a/include/fluent_tray.hpp b/include/fluent_tray.hpp index 7ec4271..1b1417f 100644 --- a/include/fluent_tray.hpp +++ b/include/fluent_tray.hpp @@ -1162,6 +1162,38 @@ namespace fluent_tray return menus_.cend() ; } + /** + * @brief Returns the reference to the beginning of menus. + * @return Reference to the first element. + */ + FluentMenu& front() { + return menus_.front() ; + } + + /** + * @brief Returns the const reference to the beginning of menus. + * @return Const reference to the first element. + */ + const FluentMenu& front() const { + return menus_.front() ; + } + + /** + * @brief Returns the reference to the last of menus. + * @return Reference to the first element. + */ + FluentMenu& back() { + return menus_.back() ; + } + + /** + * @brief Returns the const reference to the last of menus. + * @return Const reference to the first element. + */ + const FluentMenu& back() const { + return menus_.back() ; + } + /** * @brief Returns the number of menus. * @return The number of menus.