965 | | return new WorkspacesView(BRect (0, 0, 75, 15), false); |
| 965 | // Calculate the correct size of the Deskbar replicant first |
| 966 | |
| 967 | BScreen screen; |
| 968 | float screenWidth = screen.Frame().Width(); |
| 969 | float screenHeight = screen.Frame().Height(); |
| 970 | float aspectRatio = screenWidth / screenHeight; |
| 971 | uint32 columns, rows; |
| 972 | BPrivate::get_workspaces_layout(&columns, &rows); |
| 973 | |
| 974 | // ╔═╤═╕ A Deskbar replicant can be 16px tall and 129px wide at most. |
| 975 | // ║ │ │ We use 1px for the top and left borders (shown as double) |
| 976 | // ╟─┼─┤ and divide the remainder equally. However, we keep in mind |
| 977 | // ║ │ │ that the actual width and height of each workspace is smaller |
| 978 | // ╙─┴─┘ by 1px, because of bottom/right borders (shown as single). |
| 979 | // When calculating workspace width, we must ensure that the assumed |
| 980 | // actual workspace height is not negative. Zero is OK. |
| 981 | |
| 982 | float height = 16; |
| 983 | float rowHeight = floor((height - 1) / rows); |
| 984 | if(rowHeight < 1) |
| 985 | rowHeight = 1; |
| 986 | |
| 987 | float columnWidth = floor((rowHeight - 1) * aspectRatio) + 1; |
| 988 | |
| 989 | float width = columnWidth * columns + 1; |
| 990 | if(width > 129) |
| 991 | width = 129; |
| 992 | |
| 993 | return new WorkspacesView(BRect (0, 0, width, height), false); |