Merged in SL-16917 (pull request #886)

SL-16917: Move cardinal directions to the edge of the minimap

Approved-by: Andrey Lihatskiy
Approved-by: Vir Linden
master
Sabrina Shanman 2022-02-24 21:12:20 +00:00
commit f856483c12
2 changed files with 52 additions and 54 deletions

58
indra/newview/llfloatermap.cpp Normal file → Executable file
View File

@ -51,7 +51,7 @@
// The minor cardinal direction labels are hidden if their height is more
// than this proportion of the map.
const F32 MAP_MINOR_DIR_THRESHOLD = 0.07f;
const F32 MAP_MINOR_DIR_THRESHOLD = 0.035f;
//
// Member functions
@ -97,6 +97,15 @@ BOOL LLFloaterMap::postBuild()
mTextBoxSouthWest = getChild<LLTextBox> ("floater_map_southwest");
mTextBoxNorthWest = getChild<LLTextBox> ("floater_map_northwest");
mTextBoxNorth->reshapeToFitText();
mTextBoxEast->reshapeToFitText();
mTextBoxWest->reshapeToFitText();
mTextBoxSouth->reshapeToFitText();
mTextBoxSouthEast->reshapeToFitText();
mTextBoxNorthEast->reshapeToFitText();
mTextBoxSouthWest->reshapeToFitText();
mTextBoxNorthWest->reshapeToFitText();
updateMinorDirections();
// Get the drag handle all the way in back
@ -138,23 +147,44 @@ BOOL LLFloaterMap::handleDoubleClick(S32 x, S32 y, MASK mask)
return TRUE;
}
void LLFloaterMap::setDirectionPos( LLTextBox* text_box, F32 rotation )
void LLFloaterMap::setDirectionPos(LLTextBox *text_box, F32 rotation)
{
// Rotation is in radians.
// Rotation of 0 means x = 1, y = 0 on the unit circle.
// Rotation is in radians.
// Rotation of 0 means x = 1, y = 0 on the unit circle.
F32 map_half_height = (F32)(getRect().getHeight() / 2) - getHeaderHeight()/2;
F32 map_half_width = (F32)(getRect().getWidth() / 2) ;
F32 text_half_height = (F32)(text_box->getRect().getHeight() / 2);
F32 text_half_width = (F32)(text_box->getRect().getWidth() / 2);
F32 radius = llmin( map_half_height - text_half_height, map_half_width - text_half_width );
F32 map_half_height = (F32) (getRect().getHeight() / 2) - (getHeaderHeight() / 2);
F32 map_half_width = (F32) (getRect().getWidth() / 2);
F32 text_half_height = (F32) (text_box->getRect().getHeight() / 2);
F32 text_half_width = (F32) (text_box->getRect().getWidth() / 2);
F32 extra_padding = (F32) (mTextBoxNorth->getRect().getWidth() / 2);
F32 pos_half_height = map_half_height - text_half_height - extra_padding;
F32 pos_half_width = map_half_width - text_half_width - extra_padding;
// Inset by a little to account for position display.
radius -= 8.f;
F32 corner_angle = atan2(pos_half_height, pos_half_width);
F32 rotation_mirrored_into_top = abs(fmodf(rotation, F_PI));
if (rotation < 0)
{
rotation_mirrored_into_top = F_PI - rotation_mirrored_into_top;
}
F32 rotation_mirrored_into_top_right = (F_PI_BY_TWO - abs(rotation_mirrored_into_top - F_PI_BY_TWO));
bool at_left_right_edge = rotation_mirrored_into_top_right < corner_angle;
text_box->setOrigin(
ll_round(map_half_width - text_half_width + radius * cos( rotation )),
ll_round(map_half_height - text_half_height + radius * sin( rotation )) );
F32 part_x = cos(rotation);
F32 part_y = sin(rotation);
F32 y;
F32 x;
if (at_left_right_edge)
{
x = std::copysign(pos_half_width, part_x);
y = x * part_y / part_x;
}
else
{
y = std::copysign(pos_half_height, part_y);
x = y * part_x / part_y;
}
text_box->setOrigin(ll_round(map_half_width + x - text_half_width), ll_round(map_half_height + y - text_half_height));
}
void LLFloaterMap::updateMinorDirections()

View File

@ -37,105 +37,73 @@
<text
type="string"
length="1"
bottom="218"
label="N"
layout="topleft"
left="0"
name="floater_map_north"
right="10"
text_color="1 1 1 0.7"
top="189">
text_color="1 1 1 0.7">
N
</text>
<text
type="string"
length="1"
bottom="218"
label="E"
layout="topleft"
left="0"
name="floater_map_east"
right="10"
text_color="1 1 1 0.7"
top="189">
text_color="1 1 1 0.7">
E
</text>
<text
type="string"
length="1"
bottom="205"
label="W"
layout="topleft"
left="0"
name="floater_map_west"
right="11"
text_color="1 1 1 0.7"
top="175">
text_color="1 1 1 0.7">
W
</text>
<text
type="string"
length="1"
bottom="218"
label="S"
layout="topleft"
left="0"
name="floater_map_south"
right="10"
text_color="1 1 1 0.7"
top="189">
text_color="1 1 1 0.7">
S
</text>
<text
type="string"
length="1"
bottom="218"
label="SE"
layout="topleft"
left="0"
name="floater_map_southeast"
right="20"
text_color="1 1 1 0.7"
top="189">
text_color="1 1 1 0.7">
SE
</text>
<text
type="string"
length="1"
bottom="218"
label="NE"
layout="topleft"
left="0"
name="floater_map_northeast"
right="20"
text_color="1 1 1 0.7"
top="189">
text_color="1 1 1 0.7">
NE
</text>
<text
type="string"
length="1"
bottom="218"
label="SW"
layout="topleft"
left="0"
name="floater_map_southwest"
right="20"
text_color="1 1 1 0.7"
top="189">
text_color="1 1 1 0.7">
SW
</text>
<text
type="string"
length="1"
bottom="218"
label="NW"
layout="topleft"
left="0"
name="floater_map_northwest"
right="20"
text_color="1 1 1 0.7"
top="189">
text_color="1 1 1 0.7">
NW
</text>
</floater>