Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Commit

Permalink
Use flat tooltips on tray. Fix math for tray tooltips. (#1698)
Browse files Browse the repository at this point in the history
  • Loading branch information
MortimerGoro authored and bluemarvin committed Aug 28, 2019
1 parent 7667417 commit 9ae3472
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ private enum State {
private State mState;
private int mTooltipDelay;
private float mTooltipDensity;
private boolean mCurvedTooltip = true;
private ViewUtils.TooltipPosition mTooltipPosition;

public UIButton(Context context, AttributeSet attrs) {
Expand Down Expand Up @@ -98,6 +99,13 @@ public void setTooltip(String text) {
}
}

public void setCurvedTooltip(boolean aEnabled) {
mCurvedTooltip = aEnabled;
if (mTooltipView != null) {
mTooltipView.setCurvedMode(aEnabled);
}
}

public void setTooltipText(@NonNull String text) {
mTooltipText = text;
}
Expand Down Expand Up @@ -204,6 +212,7 @@ public void run() {
}

mTooltipView = new TooltipWidget(getContext());
mTooltipView.setCurvedMode(mCurvedTooltip);
mTooltipView.setText(getTooltip());
mTooltipView.setLayoutParams(UIButton.this, mTooltipPosition, mTooltipDensity);
mTooltipView.show(UIWidget.CLEAR_FOCUS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ public void setLayoutParams(View targetView, ViewUtils.TooltipPosition position,
}
}

public void setCurvedMode(boolean enabled) {
mWidgetPlacement.cylinder = enabled;
}

public void setText(String text) {
mText.setText(text);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ private void initialize(Context aContext) {
notifyPrivateBrowsingClicked();
view.requestFocusFromTouch();
});
mPrivateButton.setCurvedTooltip(false);

mSettingsButton = findViewById(R.id.settingsButton);
mSettingsButton.setOnHoverListener(mButtonScaleHoverListener);
Expand All @@ -97,6 +98,7 @@ private void initialize(Context aContext) {
view.requestFocusFromTouch();
}
});
mSettingsButton.setCurvedTooltip(false);

mBookmarksButton = findViewById(R.id.bookmarksButton);
mBookmarksButton.setOnHoverListener(mButtonScaleHoverListener);
Expand All @@ -108,6 +110,7 @@ private void initialize(Context aContext) {
notifyBookmarksClicked();
view.requestFocusFromTouch();
});
mBookmarksButton.setCurvedTooltip(false);

mHistoryButton = findViewById(R.id.historyButton);
mHistoryButton.setOnHoverListener(mButtonScaleHoverListener);
Expand All @@ -119,6 +122,7 @@ private void initialize(Context aContext) {
notifyHistoryClicked();
view.requestFocusFromTouch();
});
mHistoryButton.setCurvedTooltip(false);

UIButton addWindowButton = findViewById(R.id.addwindowButton);
addWindowButton.setOnHoverListener(mButtonScaleHoverListener);
Expand All @@ -133,6 +137,7 @@ private void initialize(Context aContext) {

notifyAddWindowClicked();
});
addWindowButton.setCurvedTooltip(false);

mAudio = AudioEngine.fromContext(aContext);

Expand Down
4 changes: 2 additions & 2 deletions app/src/main/cpp/BrowserWorld.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1070,8 +1070,8 @@ BrowserWorld::LayoutWidget(int32_t aHandle) {
}
widget->SetTransform(parent ? parent->GetTransform().PostMultiply(transform) : transform);

if (!widget->GetCylinder()) {
widget->LayoutQuadWithCylinderParent(parent && parent->GetCylinder() ? parent->GetCylinder() : nullptr);
if (!widget->GetCylinder() && parent) {
widget->LayoutQuadWithCylinderParent(parent);
}
}

Expand Down
16 changes: 12 additions & 4 deletions app/src/main/cpp/Widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -603,12 +603,20 @@ Widget::SetProxifyLayer(const bool aValue) {
m.layerProxy->ToggleAll(true);
}

void Widget::LayoutQuadWithCylinderParent(const CylinderPtr& aCylinder) {
if (aCylinder) {
const float radius = aCylinder->GetTransformNode()->GetTransform().GetScale().x();
void Widget::LayoutQuadWithCylinderParent(const WidgetPtr& aParent) {
CylinderPtr cylinder = aParent->GetCylinder();
if (cylinder) {
// The widget is flat and the parent is a cylinder.
// Adjust the widget rotation based on the parent cylinder
// e.g. rotate the tray based on the parent cylindrical window.
const float radius = cylinder->GetTransformNode()->GetTransform().GetScale().x();
m.AdjustCylinderRotation(radius);
} else {
m.transformContainer->SetTransform(vrb::Matrix::Identity());
// The widget is flat and the parent is flat. Copy the parent transformContainer matrix (used for cylinder rotations)
// because the parent widget can still be recursively rotated based on a parent cylinder.
// e.g. Place the tray tooltips on the correct tray position which may be rotated based on the
// parent cylindrical window.
m.transformContainer->SetTransform(aParent->m.transformContainer->GetTransform());
}
m.UpdateResizerTransform();
}
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/cpp/Widget.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class Widget {
float GetCylinderDensity() const;
void SetBorderColor(const vrb::Color& aColor);
void SetProxifyLayer(const bool aValue);
void LayoutQuadWithCylinderParent(const CylinderPtr& aCylinder);
void LayoutQuadWithCylinderParent(const WidgetPtr& aParent);
protected:
struct State;
Widget(State& aState, vrb::RenderContextPtr& aContext);
Expand Down

0 comments on commit 9ae3472

Please sign in to comment.